2021-11-13

本文介绍了Unity中构建的象棋游戏UI面板,包括主游戏、单机和联网模式,并详细阐述了UIManager、AudioManager和GameManager的实现,用于管理游戏的不同方面。通过这些管理者,实现了游戏界面的切换和基本操作,如单机模式、联网模式的进入及退出游戏功能。
摘要由CSDN通过智能技术生成

unity-象棋


前言

本文主要是关于自己的一个游戏项目的UI管理界面构建的总结


一、UI面板

在这里插入图片描述
UI面板的构造我分为:主游戏界面、单机模式界面、联网游戏界面、

二、管理者的设定

初步建立起游戏内的三个管理者:UI管理者、声音管理者、游戏主要管理者

1.UIManager

代码如下(示例):

public class UIManager : MonoBehaviour
{
    public static UIManager Instance { get; private set; }

    public GameObject[] panels;
    //0.主菜单 1.单机 2.模式选择 3.难度选择 4.单机游戏面板 5.联网游戏面板

    // Start is called before the first frame update

    public Text tipUIText;// 当前需要改变具体文本的显示UI

    public Text[] tipUITexts;//两个对应显示UI的引用
    
    private GameManager gameManager;
    void Start()
    {
        Instance = this;
        gameManager = GameManager.Instance;
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    /// <summary>
    /// 单机模式
    /// </summary>
    /// 
    public void StandaloneMode()
    {
        panels[0].SetActive(false);
        panels[1].SetActive(true);
        //单机选择面板的显示
    }

    /// <summary>
    /// 联网模式
    /// </summary>
    /// 
    public void NetWorkingMode()
    {

    }

    /// <summary>
    /// t退出游戏
    /// </summary>
    /// 
    public void ExitGame()
    {
        Application.Quit();
    }
}


2.AudioManager

代码如下(示例):

public class AudioManager : MonoBehaviour
{
    public static AudioManager Instance { get; private set; }
    // Start is called before the first frame update
    void Start()
    {
        Instance = this;
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

3.GameManager

代码如下(示例):

public class GameManager : MonoBehaviour
{
    public static GameManager Instance { get; private set; }//单例
    
     void Awake()
    {
        Instance =this;
    }
    // Start is called before the first frame update
    void Start()
    {
    }  

    // Update is called once per frame
    void Update()
    {
    }
}


总结

例如:以上就是今天做的内容,之后也会不定时更新关于象棋游戏这个项目的内容。有兴趣的可以给个小小的关注。你的关注就是我的动力

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值