Beispiel #1
0
 // Update is called once per frame
 private void OnGUI()
 {
     if (GUI.Button(new Rect(0, 80, 80, 60), "RESTART"))
     {
         action.Restart();
     }
     if (GUI.Button(new Rect(0, 160, 80, 60), "Pause"))
     {
         action.Pause();
     }
     if (action.flag == 0)
     {
         fontstyle1.normal.textColor = Color.green;
         GUI.Label(new Rect(Screen.width / 2 - 150, 0, 300, 100), "Score: " +
                   action.score + ", Round: " + (Mathf.CeilToInt(FirstSceneController.times / 10) + 1), fontstyle1);
     }
     else if (action.flag == 1)
     {
         fontstyle1.normal.textColor = Color.red;
         GUI.Label(new Rect(Screen.width / 2 - 150, 0, 300, 100), "Your score is : " + action.score, fontstyle1);
     }
     else
     {
         fontstyle1.normal.textColor = Color.green;
         GUI.Label(new Rect(Screen.width / 2 - 150, 0, 300, 100), "Score: " +
                   action.score + ", Round: " + (Mathf.CeilToInt(FirstSceneController.times / 10) + 1), fontstyle1);
         fontstyle1.normal.textColor = Color.red;
         GUI.Label(new Rect(Screen.width / 2 - 150, Screen.height / 2 - 50, 300, 100), "Pause!", fontstyle1);
     }
 }
Beispiel #2
0
 // Update is called once per frame
 private void OnGUI()
 {
     if (GUI.Button(new Rect(0, 80, 80, 60), "RESTART"))
     {
         action.Restart();
     }
     if (GUI.Button(new Rect(0, 160, 80, 60), "Pause"))
     {
         action.Pause();
     }
     if (action.flag == 0)
     {
         fontstyle1.normal.textColor = Color.green;
         GUI.Label(new Rect(Screen.width / 2 - 150, 0, 300, 100), "Score: " + action.score, fontstyle1);
     }
     else if (action.flag == 1)
     {
         fontstyle1.normal.textColor = Color.red;
         GUI.Label(new Rect(Screen.width / 2 - 150, 0, 300, 100), "Your score is : " + action.score, fontstyle1);
     }
     else
     {
         fontstyle1.normal.textColor = Color.green;
         GUI.Label(new Rect(Screen.width / 2 - 150, 0, 300, 100), "Score: " + action.score, fontstyle1);
         fontstyle1.normal.textColor = Color.red;
         GUI.Label(new Rect(Screen.width / 2 - 150, Screen.height / 2 - 50, 300, 100), "Pause!", fontstyle1);
     }
 }
 // Update is called once per frame
 private void OnGUI()
 {
     if (GUI.Button(new Rect(0, 80, 80, 60), "RESTART"))
     {
         action.Restart();
     }
     if (GUI.Button(new Rect(0, 160, 80, 60), "Pause"))
     {
         action.Pause();
     }
     if (action.flag == 0 && GUI.Button(new Rect(0, 240, 80, 60), "Help"))
     {
         AI aI = new AI();
         aI.Run();
     }
     if (action.flag == 1)
     {
         fontstyle1.normal.textColor = Color.green;
         GUI.Label(new Rect(Screen.width / 2 - 150, Screen.height / 2 - 50, 300, 100), "You Win!", fontstyle1);
     }
     else if (action.flag == 2)
     {
         fontstyle1.normal.textColor = Color.red;
         GUI.Label(new Rect(Screen.width / 2 - 150, Screen.height / 2 - 50, 300, 100), "You Lose!", fontstyle1);
     }
 }
Beispiel #4
0
    private void OnGUI()
    {
        if (GUI.Button(new Rect(Screen.width / 2 + 100, 15, 100, 60), "重新开始"))
        {
            action.Restart();
        }

        if (GUI.Button(new Rect(Screen.width / 2 + 230, 15, 100, 60), "暂停"))
        {
            action.Pause();
        }

        if (action.flag == 0)
        {
            fontstyle1.normal.textColor = Color.black;
            GUI.Label(new Rect(Screen.width / 2 - 280, 30, 300, 100), "Score: " +
                      action.score, fontstyle1);
            GUI.Label(new Rect(Screen.width / 2 - 100, 30, 300, 100), "Round: " + (Mathf.CeilToInt(FirstSceneController.times / 10) + 1), fontstyle1);
        }
        else if (action.flag == 1)
        {
            fontstyle1.normal.textColor = Color.red;
            GUI.Label(new Rect(Screen.width / 2, Screen.height / 2, 300, 100), "最后得分 : " + action.score, fontstyle1);
        }
        else
        {
            fontstyle1.normal.textColor = Color.black;
            GUI.Label(new Rect(Screen.width / 2 - 280, 30, 300, 100), "Score: " +
                      action.score, fontstyle1);
            GUI.Label(new Rect(Screen.width / 2 - 100, 30, 300, 100), "Round: " + (Mathf.CeilToInt(FirstSceneController.times / 10) + 1), fontstyle1);

            fontstyle1.normal.textColor = Color.red;
            GUI.Label(new Rect(Screen.width / 2, Screen.height / 2, 300, 100), "暂停", fontstyle1);
        }
    }
Beispiel #5
0
    // Update is called once per frame
    private void OnGUI()
    {
        hintStyle = new GUIStyle {
            fontSize  = 20,
            fontStyle = FontStyle.Normal
        };

        //标题
        textStyle = new GUIStyle {
            fontSize  = 50,
            alignment = TextAnchor.MiddleCenter
        };
        textStyle.normal.textColor = Color.blue;
        GUI.Label(new Rect(Screen.width / 2 - 50, Screen.height / 2 - 150, 100, 50), "UFO小游戏!", textStyle);

        //button
        btnStyle = new GUIStyle("button")
        {
            fontSize = 15
        };
        btnStyle.normal.textColor = Color.black;
        if (GUI.Button(new Rect(0, 50, 80, 50), "重新开始", btnStyle))  //前两个参数是位置(左上角),后两个是大小
        {
            action.Restart();
        }
        if (GUI.Button(new Rect(0, 100, 80, 50), " 暂停 ", btnStyle))
        {
            action.Pause();
        }

        //得分
        if (action.flag == 0)
        {
            fontstyle1.normal.textColor = Color.red;
            GUI.Label(new Rect(0, 0, 300, 50), "得分: " +
                      action.score + ", 回合: " + (Mathf.CeilToInt(FirstSceneController.times / 10) + 1), fontstyle1);
        }
        //结束
        else if (action.flag == 1)
        {
            fontstyle1.normal.textColor = Color.red;
            GUI.Label(new Rect(0, 0, 300, 50), "你的得分是 : " + action.score, fontstyle1);
        }
        //暂停
        else
        {
            fontstyle1.normal.textColor = Color.green;
            GUI.Label(new Rect(0, 0, 300, 50), "得分: " +
                      action.score + ", 回合: " + (Mathf.CeilToInt(FirstSceneController.times / 10) + 1), fontstyle1);
            GUI.Label(new Rect(Screen.width / 2 - 150, Screen.height / 2 - 50, 300, 100), "暂停!", textStyle);
        }
    }