Unity2d 提示对话框的智能化显示

提示框主体

智能提示的应用场景:

任务完成、角色死亡、子弹不足、游戏超时

一、任务完成

二、角色死亡

三、子弹不足

四、游戏超时

代码

    public void tip()
    {
        //tiptimer = tiptime;

        if(showflag==1)
        {
            int index = SceneManager.GetActiveScene().buildIndex;
            if(index==1)
            {
                tipsframe.SetActive(true);
                tips.text = "Tips:\n快前往城堡,进行下一关吧!";
            }
            else if(index==2)
            {
                tipsframe.SetActive(true);
                tips.text = "Tips:\n亲亲、你已经通关了,请五星好评哦!";
            }
        }
        else if(currentHealth==0)
        {
            tipsframe.SetActive(true);
            int index = SceneManager.GetActiveScene().buildIndex;
            if(index==1)
            {
                tips.text = "Tips:\n该长教训了吧,哈哈!";
            }
            else if(index==2 && RobotControl.isFixed%2==1)
            {
                tips.text = "Tips:\n机器人被激怒,会主动攻击人哦。尝试着对它连续完成两次攻击吧!";
            }
            else if (index == 2 && RobotControl.isFixed % 2 != 1)
            {
                tips.text = "Tips:\n你可长点教训吧,哈哈!";
            }
            else
            {
                return;
            }
        }
        else if(curBulletCount==0 && currentHealth!=0)
        {
            tipsframe.SetActive(true);
            tips.text = "Tips:\n没有子弹了,快去拾取子弹吧!";
        }
        else if(gametime>180)
        {
            tipsframe.SetActive(true);
            tips.text = "Tips:\n游戏超时了哦";
        }
    }

附完整教程:

Unity2d Rubys Adventure 课程设计报告

猜你喜欢

转载自blog.csdn.net/weixin_43673589/article/details/106573900