Software Engineering Laboratory2_2

The Link Your Classhttps://bbs.csdn.net/forums/MUEE308FZU202201
The Link of Requirement of This Assignmenthttps://bbs.csdn.net/topics/608859318?spm=1001.2014.3001.6377
MU STU ID and FZU STU ID20122535_832001312
Teammate’s MU STU ID and FZU STU ID20122888_832001328
Video demo linkhttps://pan.baidu.com/s/1qXnlmgLumB80Vl0aQbn6Mg?pwd=ve58
Project fileThe file is too large to upload to Github so we ues Baidu Netdisk
Teammate’s Bloghttps://blog.csdn.net/nothing_i_can_do/article/details/127931515

I. Overview of our Bobing software

In lab2_1, we used the ink knife to design the prototype of the pancake software. In this lab, we used unity to complete the realization of the software. We didn’t learn anything about game development before that 😦. We spent a week learning the basics of unity and C#. 😃 After unremitting efforts, we have achieved the single-player mode and multiplayer mode, but due to the lack of time, we haven’t realized the function of networking 😗. After studying in detail, we will try to implement the networking function and update our software.
The main functions of our software include background music adjustment ▶️, single-player mode, and multiplayer mode (2 or 3 players) which can be specified by the player.

II. Key Techniques and Relevant Programming Thinking

1. Main function

1.1 Modulation of BGM

We implemented the volume control for the background music using the DontDestroyOnLoad method provided by unity. Using this method, the official notes clearly state that when loading a new scene, the object will not be destroyed and will exist in the next scene.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class misicplay : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        
    }
    private static misicplay instance = null;
    public static misicplay Instance
    {
        get { return instance; }
    }
    void Awake()
    {
        if(instance != null && instance!=this)
        {
            Destroy(this.gameObject);
            return;
        }
        else
        {
            instance = this;
        }
        DontDestroyOnLoad(this.gameObject);
    }
    // Update is called once per frame   
}

DontDestroyOnLoad

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
 
public class DontDestroyMusicClass : MonoBehaviour
{
 
    void Awake()
    {
        GameObject[] musicObj = GameObject.FindGameObjectsWithTag("Global");
        if(musicObj.Length>1)
        {
            Destroy(this.gameObject);
        }
        DontDestroyOnLoad(this.gameObject);
    }
}

AudioManager

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class Audiomanager : MonoBehaviour
{
    public float totalVolume;
    public float audioVolume;
    public float bgmVolume;
    public AudioClip ad;
    List<AudioSource> ads = new List<AudioSource>();
    // Start is called before the first frame update
    void Start()
    {
        totalVolume = PlayerPrefs.GetFloat("totalVolume", 1);
    }
 
    // Update is called once per frame
    void Update()
    {
        AudioListener.volume = audioVolume * totalVolume;
 
        
 
    }
    public void SetTotal(System.Single val)
    {
        totalVolume = val;
        PlayerPrefs.SetFloat("totalVolume", totalVolume);
 
    }
    public void SetAudio(System.Single val)
    {
        audioVolume = val;
        PlayerPrefs.SetFloat("audioVolume", audioVolume);
    }
 
    public void SetBGM(System.Single val)
    {
        bgmVolume = val;
        PlayerPrefs.SetFloat("bgmVolume", bgmVolume);
    }
}

1.2 Random results of six dice

We modeled the dice and bowl using unity 3D, applying torque to the dice and making them drop at will. We were going to use the trigger in unity 3D to identify the roll of the die, but we kept getting errors, so it never happened. The final decision was to use code to generate random points.
在这里插入图片描述
We chose to apply a random torque to the sieve.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
public class niu : MonoBehaviour
{
    public Rigidbody Rig;
    // Start is called before the first frame update
    void Start()
    {
        float x = Random.Range(0, 500);
        float y = Random.Range(0, 500);
        float z = Random.Range(0, 500);
        Rig.AddTorque(x, y, z);
 
    }
 
    // Update is called once per frame
    void Update()
    {
        
    }
}

1.3 Multiplayer mode

In lab3, we originally intended to implement online mode, but due to the short experiment time and lack of ability, we decided to use multiple people to play games with one mobile phone. The number of players in the game is optional
在这里插入图片描述

III. Big Events during Developing

  1. As for BGM, it can keep the volume set at the beginning and keep playing when switching scenes, I found through consulting the materials that the maintenance object of cross-scene can be realized by the DontDestroyOnLoad. After binding the plug-in and script, it was found in the test process that multi-scene switching would lead to many AudioSourc When e is played together, after consulting the data, it is found that this function is to backup the object to different scenes to realize the function, so it only needs to detect whether the same Object exists in the current scene.
  2. Since we are unity beginners, we did not understand the function of UnityEngine.UI, and made mistakes repeatedly without finding it. For us, this problem gave me greater difficulty in this experiment. 🤤
  3. About using the physics engine to add a random torque to the dice and Trigger to generate and read the dice roll; We successfully read one die at the beginning, but when we read the six-sided die and concentrated the reading, the script made an error. Now I think it was either UnityEngine.UI forgot to add it, or it was because we were not familiar with the relationship between the script and the object. We will try to improve it later.

V. PSP Form

Personal Software Process StagesEstimated Time/minutesCompleted Time/minutes
Planning3030
Estimate2020
Developmemt--
Analysis120250
Design Spec4040
Design Review2030
Coding Standard1010
Design200200
Coding10001900
Code ReviewPlanning6045
Test120150
Reporting100100
Test Report--
Size Measurement1010
Postmortem&Process Improvement120100
total18502905

IV. Pair-Programing Experience

Working late at night
在这里插入图片描述

Video link

链接:https://pan.baidu.com/s/1qXnlmgLumB80Vl0aQbn6Mg?pwd=ve58
提取码:ve58

Our project file

Because our file is too large to be uploaded to Github, we have to upload it to Baidu Netdisk
链接:https://pan.baidu.com/s/15_Va6Mhdk5sw-OqrFYJrCg?pwd=jr0e
提取码:jr0e

Download our app

链接:https://pan.baidu.com/s/1cpO6t5-Q6_3nWKDPXhdQWQ?pwd=im90
提取码:im90

VI. Summary

This experiment was really challenging for me, because I had almost no knowledge of 3D modeling,unity3D and C# before this. Through this experiment, I got a basic understanding of game development. Although we have not realized the networking function, I will try my best to learn web knowledge in the following study and strive to realize the software upgrade 💪
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值