Exemplo n.º 1
0
 private void OnGUI()
 {
     if (!ss)
     {
         S = Time.time;
     }
     GUI.Label(new Rect(1000, 50, 500, 500), "Score: " + UserActionController.GetScore().ToString() + "  Time:  " + ((int)(Time.time - S)).ToString() + "  Round:  " + round);
     if (!ss && GUI.Button(new Rect(Screen.width / 2 - 30, Screen.height / 2 - 30, 100, 50), "Start"))
     {
         S  = Time.time;
         ss = true;
         UserActionController.Restart();
     }
     if (ss)
     {
         round = UserActionController.GetRound();
         if (Input.GetButtonDown("Fire1"))
         {
             Vector3 pos = Input.mousePosition;
             UserActionController.Hit(pos);
         }
         if (round > 3)
         {
             round = 3;
             if (UserActionController.RoundStop())
             {
                 ss = false;
             }
         }
     }
 }
Exemplo n.º 2
0
 void Update()
 {
     if (!ss)
     {
         S = Time.time;
     }
     btnStart.SetActive(!ss);
     text.text = "Score: " + UserActionController.GetScore().ToString() + "  Time:  " + ((int)(Time.time - S)).ToString() + "  Round:  " + round;
     if (ss)
     {
         round = UserActionController.GetRound();
         if (Input.GetButtonDown("Fire1"))
         {
             Vector3 pos = Input.mousePosition;
             UserActionController.Hit(pos);
         }
         if (round > 3)
         {
             round = 3;
             if (UserActionController.RoundStop())
             {
                 ss = false;
             }
         }
     }
 }
Exemplo n.º 3
0
    private void OnGUI()
    {
        if (!ss)
        {
            S = Time.time;
        }

        if (!ss && GUI.Button(new Rect(Screen.width / 2 - 30, Screen.height / 2 - 30, 100, 50), "Start"))
        {
            S  = Time.time;
            ss = true;
            UserActionController.Restart();
            controller.LoadResources();
        }
        if (ss)
        {
            GUI.Button(new Rect(0, 0, 100, 50), "Round: " + round);
            GUI.Button(new Rect(0, 55, 100, 50), "Score: " + UserActionController.GetScore().ToString());
            GUI.Button(new Rect(0, 110, 100, 50), "Time: " + ((int)(Time.time - S)).ToString());
            if (GUI.Button(new Rect(0, 165, 100, 50), "Reset"))
            {
                S = Time.time;
                UserActionController.Restart();
            }
            round = UserActionController.GetRound();
            if (Input.GetButtonDown("Fire1"))
            {
                Vector3 pos = Input.mousePosition;
                UserActionController.Hit(pos);
            }
            if (round > 10)
            {
                round = 10;
                if (UserActionController.RoundStop())
                {
                    ss = false;
                }
            }
        }
    }
Exemplo n.º 4
0
    private void OnGUI()
    {
        if (userAction.GetScore() > maxScore)
        {
            maxScore = userAction.GetScore();
        }
        if (!isPlaying)
        {
            S = Time.time;
        }
        //分数、时间、回合
        string text = "分数: " + userAction.GetScore().ToString() + "  时间:  " + ((int)(Time.time - S)).ToString() + "  回合:  " + round;

        GUI.Label(new Rect(10, 10, Screen.width, 50), text);

        if (!isPlaying && GUI.Button(new Rect(Screen.width / 2 - 75, Screen.height / 2 - 25, 150, 50), "开始游戏"))
        {
            S         = Time.time;
            isPlaying = true;
            userAction.Restart();   //点击开始游戏,FirstSceneController开始游戏
        }
        if (isPlaying)
        {
            round = userAction.GetRound();
            if (Input.GetButtonDown("Fire1"))
            {
                //把鼠标点击的位置传给FirstScenceController,处理点击事件
                Vector3 pos = Input.mousePosition;
                userAction.Hit(pos);
            }
            if (round > 3)  //round>3要等待飞碟都用完了
            {
                round = 3;
                if (userAction.RoundStop())
                {
                    isPlaying = false;
                }
            }
        }
    }