EE308 Lab 2-2

m0_51284439 m0_51284439 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

EE306 Lab 2-2

Description of problem-solving ideas

First of all, for this homework, we should know that the last game is a game, so we chose the unity engine that may be used in the final project to complete this homework.

The game is a BoBing game.The BoBing game has two steps: throwing dice and judging rewards.

The first first step is to throw the dice. The throwing dice function will rely on random number generation. Clicking the throw button will generate six dice and random numbers, and pass the random numbers to the dice, the dice completes the preset animation based on the accepted random number, and then destroyed. The above is the solution to finish throwing the dice.

The second part is the judgment reward,There are initially two ideas for the realization of this function, first with regular expressions for judgment, and second with if nesting.Given only the less effort to judge six dice, the second method was chosen to achieve functionality.We count the points by establishing the counter, and judge the reward by the number of points within the counter.

Finally, the multiplayer part. For this part of the function we used photon pun2 to implement.
Here we make the prefabricated dice that need to be synchronized in the room and put them into the photon's resource file to easily synchronize the object at the interface of all players when throwing. Then you rely on the PhotonView components to synchronize the animation.We plan to use photon RPC to achieve simple message transfer in the same room.

Design and implementation process

——————————————Overall structural design————————————————————

请添加图片描述


The overall structure mainly includes the main menu and the UI design of the game interface.

The main menu section will include both the exit and login features.

The main game interface will contain most of the important features. Like view the rules, throw the dice, view the scoreboard, empty the scoreboard, and return to the main menu.

———————Throw dice function—————————————————————————————

请添加图片描述


The partial functional implementation of throwing dice, is shown in Fig.
Specifically to obtain random numbers, transmit to the generated dice that play the animation and destroy in seconds.
The obtained numbers are stored in order and counted, and a series of judgments produce the results.(The implementation will be detailed in the code explanation section below)

—————————————Online part of the function implementation————————————

请添加图片描述


The online part is mainly implemented through photon, and through the photonview component, the dice prefabricated of the photon resource folder is generated in the game interface of the members of the same room.
Adding room functions also depends on photon. Details will be displayed in the code section.

Code description

Connect the Room section code

public void Start()
    {
        PhotonNetwork.ConnectUsingSettings();//Start the connection when the game starts
    }
   public override void OnConnectedToMaster()
   {
        play.SetActive(true);//Login is allowed when the connection is successful
    }

    public void playButton()
    {
        nameUI.SetActive(false);
        PhotonNetwork.NickName = playername.text;//Get the username
        loginUI.SetActive(true);
    }

    public void joinorcreate()//Get the room number and create or connect the room.
    {
       load.SetActive(true);
       SceneManager.LoadScene(1);
        if (roomID.text.Length < 2)
            return;
        loginUI.SetActive(false);

    RoomOptions options = new RoomOptions { MaxPlayers = 4 };
    PhotonNetwork.JoinOrCreateRoom(roomID.text, options,default);
    }

   public override void OnJoinedRoom()//Jump to the game interface after the successful connection
   {
    PhotonNetwork.LoadLevel(1);
   }

Generate the Dice section code

public void creatdice(int sc)
{
    diceplace.position = diceplace.position + Vector3.right * 100;//Modify the Dice Generation Location
    //Generate the dice on the full room via the photon server
    GameObject newdice = PhotonNetwork.Instantiate("dice", diceplace.position, diceplace.rotation);
    newdice.transform.parent = this.transform;
    newdice.GetComponent<dice>().setnumber(sc);//Accept random numbers
}

Throw part of the code

public void roll()
{
    int[] sct = new int[6];
    System.Random rd = new System.Random();

    for (int i = 0; i < 6; i++)
    {
        int sc = rd.Next(1, 7);//Get random numbers

        creatdice(sc);//Call the above method to generate the dice

        sct[i] = sc;
    }
    diceplace.position = diceplace.position + Vector3.left * 600;//Investment generation position is back to positive
    sortsct(sct);
    string kg = checkpoint(sct);// Judge the reward result
    newsc.text = kg;
    showsct(sct, kg); //Transfer the results to the scoreboard
    Invoke("cleansc", 5);

}

Award Winning Judgment partial code

   public string checkpoint(int[] sct)//Reward judgment was made by the priority of the points
{
    string kg = "";
    string name = "";
    int[] total = new int[6];
    for (int i = 0; i < sct.Length; i++)
        total[sct[i] - 1]++;
    if (total[1] == 4)
    {
        kg = "JinShi";
        name = "SiJin";
    }
    else if (total[3] == 4 && total[0] == 2)
    {
        kg = "ZhuangYuan";
        name = "ZhuangYuanChaJinHua";
    }
    else if (total[3] == 6)
    {
        kg = "ZhuangYuan";
        name = "LiuBeiHong";
    }
    else if (total[5] == 6)
    {
        kg = "ZhuangYuan";
        name = "LiuBeiHei";
    }
    else if (total[3] == 5)
    {
        kg = "ZhuangYuan";
        name = "WuWang";
    }
    else if (total[5] == 5)
    {
        kg = "ZhuangYuan";
        name = "WuZiDengKe";
    }
    else if (total[3] == 4)
    {
        kg = "ZhuangYuan";
        name = "ZhuangYuan";
    }
    else if (total[3] == 3)
    {
        kg = "TanHua";
        name = "SanHong";
    }
    else if (total[3] == 2)
    {
        kg = "JuRen";
        name = "ErJu";
    }
    else if (total[3] == 1)
    {
        bool b = true;
        for (int i = 0; i < total.Length; i++)
        {
            if (total[i] != 1)
            {
                b = false;
                break;
            }
        }
        if (b == true)
        {
            kg = "BangYan";
            name = "DuiTang";
        }
        else
        {
            kg = "XiuCai";
            name = "YiJu";
        }
    }
    else
    {
        kg = "No Reward";
    }
    kg = string.Concat(kg, " ", name);
    return kg;
}

PSP

Personal SoftwareProcess StagesEstimated time (minutes)Real time (minutes)
Planning1020
Estimate--
Development300600
Analysis3040
Design Spec6090
Design Review3030
Coding Standard1010
Design3060
Coding600800
Code Review3060
Test6060
Reporting--
Test Report2020
Size Measurement1020
Postmortem & Process Improvement Plan2060
total12101870

summary

The project uses the basic operations of unity2d and how to achieve multiplayer games through photo. Exercise the project organization ability and teamwork ability.

The Link Your Class | https://bbs.csdn.net/forums/MUEE308FZU202201
| ----------- | ----------- |
The Link of Requirement of This Assignment | https://bbs.csdn.net/topics/608734907
MU STU ID and FZU STU ID | 20124635-832002210
Teammate's MU STU ID and FZU STU ID | 20122900-832002207
Teammate's blog link | https://blog.csdn.net/m0_54015927?type=bbs
GitHub link | https://github.com/Aiorang/Lab2
Video demo link | https://www.bilibili.com/video/BV1GW4y1x71B/?vd_source=3b4274550a75f47f7a429318c7bff80c

...全文

相关推荐

EE-308 LAB4 final version.7z

这是本次实验的压缩包

晨起剪桃花

战国BC472年世界历史地图矢量文件SHP格式.zip

本资源为《战国BC472年世界历史地图矢量文件SHP格式》压缩包,文件大小约 2.26 MB,便于集中下载、整理和使用。具体内容请结合压缩包内的实际文件与说明查看。 在当前可读取的目录中,可见属性表(.dbf)、投影说明文件(.prj)、Shapefile 主文件(.shp)、Shapefile 索引(.shx)。建议解压后保持原有目录结构,先浏览文件清单与说明,再选择需要的资料进行加载或整理。 应用方面,可根据实际资料用于学习练习、资料检索、研究整理或项目参考。使用时可先确定所需内容,建立清晰的文件分类,再按项目要求进行筛选、转换与汇总。 使用 Shapefile 数据时,请把实际配套的 .shp、.shx、.dbf 等文件保存在同一目录,并保持同名关联;加载后再检查坐标系与中文字段显示。如需叠加其它数据,请先统一坐标与字段口径。 数据来源、时间范围、坐标系、字段定义、精度和使用条件,请以实际文件及原始说明为准。本介绍不对文件名之外尚未核实的信息作额外承诺。

白水先森

地方科技局搭建区域性科技成果转化公共服务平台,哪家机构提供的数智化方案更成熟?.docx

科易网基于行业知识库+行业大数据+科技资源要素+AI模型,以AI,赋能技术转移、成果转化、技术经理人培训、知识产权管理、区域产业分析与布局、地方科技招商、创新创业大赛等场景,推出科技创新领域的AI工具、场景化服务和数智化解决方案,推动科技创新与产业创新智能化发展。

BIZKEEN

F500A 立式机触摸屏程序

F500A 立式机触摸屏程序

czhaii

汉语言文学22班 马旭 1243022203 现当代文学读书笔记.pdf

img_to_pdf_1796121273101.pdf

AAA-妙脆角批发
评论
收藏 已收藏
分享
返回顶部