示例#1
0
    void OnGUI()
    {
        GUI.Label(new Rect(Screen.width / 2 - 74, 10, 150, 50), "得分:", style1);
        GUI.Label(new Rect(Screen.width / 2 + 20, 10, 220, 50), action.GetScore().ToString(), style2);

        GUI.Label(new Rect(Screen.width / 2 - 92, 80, 50, 50), "生命值:", style1);
        GUI.Label(new Rect(Screen.width / 2 + 20, 80, 320, 50), action.GetLife().ToString(), style2);

        //游戏结束
        if (action.GetLife() <= 0)
        {
            action.GameOver();
            GUI.Label(new Rect(Screen.width / 2 - 96, Screen.height / 2 - 250, 150, 100), "Game Over!", style2);
            GUI.Label(new Rect(Screen.width / 2 - 76, Screen.height / 2 - 200, 150, 50), "得分:", style1);
            GUI.Label(new Rect(Screen.width / 2 + 15, Screen.height / 2 - 200, 50, 50), action.GetScore().ToString(), style1);
            if (GUI.Button(new Rect(Screen.width / 2 - 85, Screen.height / 2 - 150, 130, 66), "重新开始", buttonStyle))
            {
                action.ReStart();
            }
        }
        else
        {
            if (Input.GetButtonDown("Fire1"))
            {
                Vector3 pos = Input.mousePosition;
                action.Hit(pos);
            }
        }
    }
示例#2
0
        private void OnGUI()
        {
            if (Input.GetButtonDown("Fire1"))
            {
                Vector3 pos = Input.mousePosition;
                action.hit(pos);
            }

            GUI.Label(new Rect(1000, 0, 400, 400), action.GetScore().ToString());

            if (isFirst && GUI.Button(new Rect(700, 100, 90, 90), "Start"))
            {
                isFirst = false;
                action.setGameState(GameState.ROUND_START);
            }

            if (!isFirst && action.getGameState() == GameState.ROUND_FINISH && GUI.Button(new Rect(700, 100, 90, 90), "Next Round"))
            {
                action.setGameState(GameState.ROUND_START);
            }
            if (action.GameOver() == true)
            {
                GUI.color = Color.red;
                GUI.Label(new Rect(700, 300, 400, 400), "GAMEOVER");
            }
        }
示例#3
0
    void OnGUI()
    {
        bold_style.normal.textColor  = Color.red;
        bold_style.fontSize          = 20;
        round_style.normal.textColor = Color.red;
        round_style.fontSize         = 20;
        text_style.normal.textColor  = Color.red;
        text_style.fontSize          = 20;
        score_style.normal.textColor = Color.red;
        score_style.fontSize         = 20;
        over_style.normal.textColor  = new Color(1, 1, 1);
        over_style.fontSize          = 50;

        if (game_start)
        {
            //用户射击
            if (Input.GetButtonDown("Fire1"))
            {
                Vector3 pos = Input.mousePosition;
                action.Hit(pos);
            }

            GUI.Label(new Rect(10, 5, 200, 50), "Scores:", text_style);
            GUI.Label(new Rect(85, 5, 200, 50), action.GetScore().ToString(), score_style);

            GUI.Label(new Rect(350, 5, 200, 50), "round:  ", text_style);
            GUI.Label(new Rect(440, 5, 200, 50), action.GetRound().ToString(), round_style);

            GUI.Label(new Rect(Screen.width - 150, 5, 50, 50), "Health:", text_style);
            //显示当前血量
            for (int i = 0; i < life; i++)
            {
                GUI.Label(new Rect(Screen.width - 75 + 10 * i, 5, 50, 50), "♥", bold_style);
            }
            //游戏结束
            if (life == 0)
            {
                high_score = high_score > action.GetScore() ? high_score : action.GetScore();
                GUI.Label(new Rect(Screen.width / 2 - 120, Screen.width / 2 - 350, 100, 100), "GAME OVER", over_style);
                GUI.Label(new Rect(Screen.width / 2 - 110, Screen.width / 2 - 300, 50, 50), "Final Scores:", text_style);
                GUI.Label(new Rect(Screen.width / 2 + 50, Screen.width / 2 - 300, 50, 50), high_score.ToString(), text_style);
                if (GUI.Button(new Rect(Screen.width / 2 - 20, Screen.width / 2 - 150, 100, 50), "Restart"))
                {
                    life = 5;
                    action.ReStart();
                    return;
                }
                action.GameOver();
            }
        }
        else
        {
            GUI.Label(new Rect(Screen.width / 2 - 230, Screen.width / 2 - 200, 400, 100), "Click disks to shoot them down. You have only 5 lifes.", text_style);
            if (GUI.Button(new Rect(Screen.width / 2 - 80, Screen.width / 2 - 300, 100, 50), "START"))
            {
                game_start = true;
                action.BeginGame();
            }
        }
    }
示例#4
0
    void OnGUI()
    {
        GUIStyle textStyle   = new GUIStyle();
        GUIStyle buttonStyle = new GUIStyle();

        textStyle.fontSize   = 30;
        buttonStyle.fontSize = 15;
        if (start == 1)
        {
            if (GUI.Button(new Rect(Screen.width / 2 - 60, Screen.height / 2 + 150, 100, 30), "Start"))
            {
                chooseMode = 1;
                start      = 0;
            }
        }
        if (chooseMode == 1)
        {
            if (GUI.Button(new Rect(Screen.width / 2 - 120, Screen.height / 2 + 150, 100, 30), "KINEMATIC"))
            {
                action.SetMode(ActionMode.KINEMATIC);
                action.BeginGame();
                chooseMode = 0;
            }
            if (GUI.Button(new Rect(Screen.width / 2 - 0, Screen.height / 2 + 150, 100, 30), "PHYSICS"))
            {
                action.SetMode(ActionMode.PHYSICS);
                action.BeginGame();
                chooseMode = 0;
            }
        }
        if (action.GetBlood() > 0)
        {
            GUI.Label(new Rect(10, 5, 200, 50), "回合:");
            GUI.Label(new Rect(55, 5, 200, 50), action.GetRound().ToString());
            GUI.Label(new Rect(10, 25, 200, 50), "分数:");
            GUI.Label(new Rect(55, 25, 200, 50), action.GetScore().ToString());
            GUI.Label(new Rect(10, 45, 200, 50), "血量:");
            GUI.Label(new Rect(55, 45, 200, 50), action.GetBlood().ToString());
            if (Input.GetButtonDown("Fire1"))
            {
                Vector3 pos = Input.mousePosition;
                action.hit(pos);
                Debug.Log("hit: " + pos);
            }
        }
        if (action.GetBlood() <= 0)
        {
            action.GameOver();
            GUI.Label(new Rect(Screen.width / 2 - 60, Screen.height / 2 + 80, 100, 50), "You are dead!");
            GUI.Label(new Rect(Screen.width / 2 - 60, Screen.height / 2 + 100, 100, 50), "Your score: ");
            GUI.Label(new Rect(Screen.width / 2 + 10, Screen.height / 2 + 100, 100, 50), action.GetScore().ToString());
            if (GUI.Button(new Rect(Screen.width / 2 - 60, Screen.height / 2 + 190, 100, 30), "Restart"))
            {
                action.Restart();
                start = 1;
            }
        }
    }
示例#5
0
文件: UserGUI.cs 项目: lllllljb/3D
    void OnGUI()
    {
        bold_style.normal.textColor  = new Color(1, 0, 0);
        bold_style.fontSize          = 16;
        text_style.normal.textColor  = new Color(0, 0, 0, 1);
        text_style.fontSize          = 16;
        score_style.normal.textColor = new Color(1, 0, 1, 1);
        score_style.fontSize         = 16;
        over_style.normal.textColor  = new Color(1, 0, 0);
        over_style.fontSize          = 25;

        if (game_start)
        {
            //用户射击
            if (Input.GetButtonDown("Fire1"))
            {
                Vector3 pos = Input.mousePosition;
                action.Hit(pos);
            }

            GUI.Label(new Rect(10, 5, 200, 50), "Score: ", text_style);
            GUI.Label(new Rect(70, 5, 200, 50), action.GetScore().ToString(), score_style);

            GUI.Label(new Rect(Screen.width - 150, 5, 20, 20), "Life:", text_style);

            //显示当前血量
            for (int i = 0; i < life; i++)
            {
                GUI.Label(new Rect(Screen.width - 100 + 15 * i, 5, 50, 50), "❤", bold_style);
            }

            //游戏结束
            if (life == 0)
            {
                high_score = high_score > action.GetScore() ? high_score : action.GetScore();
                GUI.Label(new Rect(Screen.width / 2 - 40, Screen.width / 2 - 250, 100, 100), "Game Over!", over_style);
                GUI.Label(new Rect(Screen.width / 2 - 30, Screen.width / 2 - 200, 50, 50), "Highest Score:", text_style);
                GUI.Label(new Rect(Screen.width / 2 + 75, Screen.width / 2 - 200, 50, 50), high_score.ToString(), text_style);
                if (GUI.Button(new Rect(Screen.width / 2 - 25, Screen.width / 2 - 150, 100, 50), "Restart"))
                {
                    life = 6;
                    action.ReStart();
                    return;
                }
                action.GameOver();
            }
        }
        else
        {
            GUI.Label(new Rect(Screen.width / 2 - 30, Screen.width / 2 - 350, 100, 100), "Welcome!", over_style);
            GUI.Label(new Rect(Screen.width / 2 - 100, Screen.width / 2 - 250, 150, 100), "点击飞碟并消灭它们,你有6条命!", text_style);
            if (GUI.Button(new Rect(Screen.width / 2 - 20, Screen.width / 2 - 150, 100, 50), "Start"))
            {
                game_start = true;
                action.BeginGame();
            }
        }
    }
示例#6
0
 void OnGUI()
 {
     text_style.normal.textColor  = new Color(1, 1, 1, 1);
     text_style.fontSize          = 16;
     text_style2.normal.textColor = new Color(1, 1, 1, 1);
     text_style2.fontSize         = 100;
     if (action.getModeSetting())
     {
         GUI.Label(new Rect(Screen.width / 2 - 40, Screen.height / 2 - 100, 50, 50), "游戏模式", text_style);
         if (GUI.Button(new Rect(Screen.width / 2 - 55, Screen.height / 2 + 20, 100, 50), "物理学模式"))
         {
             action.modeSet(true);
             action.gameBegin();
             return;
         }
         if (GUI.Button(new Rect(Screen.width / 2 - 55, Screen.height / 2 - 50, 100, 50), "运动学模式"))
         {
             action.modeSet(false);
             action.gameBegin();
             return;
         }
     }
     else
     {
         if (action.isCounting())
         {
             GUI.Label(new Rect(Screen.width / 2 - 40, Screen.height / 2 - 100, 50, 50), action.getEmitTime().ToString(), text_style2);
         }
         else
         {
             if (Input.GetButtonDown("Fire1"))
             {
                 Vector3 pos = Input.mousePosition;
                 action.Hit(pos);
             }
             GUI.Label(new Rect(10, 5, 200, 50), "score:", text_style);
             GUI.Label(new Rect(60, 5, 200, 50), action.GetScore().ToString(), text_style);
             GUI.Label(new Rect(10, 30, 50, 50), "hp:", text_style);
             for (int i = 0; i < life; i++)
             {
                 GUI.Label(new Rect(40 + 10 * i, 30, 50, 50), "X", text_style);
             }
             if (life == 0)
             {
                 GUI.Label(new Rect(Screen.width / 2 - 50, Screen.width / 2 - 300, 100, 100), "GameOver!", text_style);
                 if (GUI.Button(new Rect(Screen.width / 2 - 60, Screen.width / 2 - 250, 100, 50), "Restart"))
                 {
                     action.Restart();
                     return;
                 }
                 action.GameOver();
             }
             GUI.Label(new Rect(10, 55, 200, 50), "Round:", text_style);
             GUI.Label(new Rect(64, 55, 200, 50), action.GetRound().ToString(), text_style);
         }
     }
 }
示例#7
0
    void OnGUI()
    {
        bold_style.normal.textColor  = new Color(1, 0, 0);
        bold_style.fontSize          = 20;
        text_style.normal.textColor  = new Color(1, 255, 255, 255);
        text_style.fontSize          = 20;
        score_style.normal.textColor = new Color(1, 0, 1, 1);
        score_style.fontSize         = 20;
        over_style.normal.textColor  = new Color(1, 255, 255, 255);
        over_style.fontSize          = 35;

        if (game_start)
        {
            //用户射击
            if (Input.GetButtonDown("Fire1"))
            {
                Vector3 pos = Input.mousePosition;
                action.Hit(pos);
            }

            GUI.Label(new Rect(10, 5, 200, 50), "分数:", text_style);
            GUI.Label(new Rect(55, 5, 200, 50), action.GetScore().ToString(), score_style);

            GUI.Label(new Rect(Screen.width - 150, 5, 50, 50), "生命:", text_style);

            //显示当前血量
            for (int i = 0; i < life; i++)
            {
                GUI.Label(new Rect(Screen.width - 105 + 10 * i, 5, 50, 50), "X", bold_style);
            }

            //游戏结束
            if (life == 0)
            {
                high_score = high_score > action.GetScore() ? high_score : action.GetScore();
                GUI.Label(new Rect(Screen.width / 2 - 30, Screen.width / 2 - 250, 100, 100), "游戏结束", over_style);
                GUI.Label(new Rect(Screen.width / 2 - 10, Screen.width / 2 - 200, 50, 50), "分数:", text_style);
                GUI.Label(new Rect(Screen.width / 2 + 50, Screen.width / 2 - 200, 50, 50), high_score.ToString(), text_style);
                if (GUI.Button(new Rect(Screen.width / 2 - 20, Screen.width / 2 - 150, 100, 50), "重新开始"))
                {
                    action.ReStart();
                    life = mxlife;
                    return;
                }
                action.GameOver();
            }
        }
        else
        {
            GUI.Label(new Rect(Screen.width / 2 - 30, Screen.width / 2 - 550, 100, 100), "Hit UFO", over_style);
            if (GUI.Button(new Rect(Screen.width / 2 - 20, Screen.width / 2 - 450, 100, 50), "游戏开始"))
            {
                game_start = true;
                action.BeginGame();
            }
        }
    }
示例#8
0
文件: UserGUI.cs 项目: Ernie1/unity3d
    void OnGUI()
    {
        float width  = Screen.width / 6;
        float height = Screen.height / 12;

        if (status == 0)
        {
            action.GameOver();
            if (GUI.Button(new Rect(Screen.width / 2 - width / 2, Screen.height / 2 - height / 2, width, height), "Game Over!\nRestart"))
            {
                action.Restart();
            }
        }
        if (status == 1)
        {
            action.GameOver();
            if (GUI.Button(new Rect(Screen.width / 2 - width / 2, Screen.height / 2 - height / 2, width, height), "Win!\nRestart"))
            {
                action.Restart();
            }
        }
        if (status == 2)
        {
            if (GUI.Button(new Rect(Screen.width / 2 - width / 2, Screen.height / 2 - height / 2, width, height), "Pause"))
            {
                action.Pause();
            }
            if (GUI.Button(new Rect(Screen.width / 2 - width / 2, Screen.height / 2 - height / 2 + height, width, height), "Restart"))
            {
                action.Restart();
            }
        }
        if (status == 3)
        {
            if (GUI.Button(new Rect(Screen.width / 2 - width / 2, Screen.height / 2 - height / 2, width, height), "Resume"))
            {
                action.Resume();
            }
            if (GUI.Button(new Rect(Screen.width / 2 - width / 2, Screen.height / 2 - height / 2 + height, width, height), "Restart"))
            {
                action.Restart();
            }
        }
    }
示例#9
0
文件: UserGUI.cs 项目: lvxm0/Unity3d
    void OnGUI()
    {
        bold_style.normal.textColor  = new Color(1, 0, 0);
        bold_style.fontSize          = 16;
        text_style.normal.textColor  = new Color(0, 0, 0, 1);
        text_style.fontSize          = 16;
        score_style.normal.textColor = new Color(1, 0, 1, 1);
        score_style.fontSize         = 16;
        over_style.normal.textColor  = new Color(1, 0, 0);
        over_style.fontSize          = 25;

        if (game_start)
        {
            //用户射击
            if (Input.GetButtonDown("Fire1"))
            {
                Vector3 pos = Input.mousePosition;
                action.hit(pos);
            }

            GUI.Label(new Rect(10, 5, 200, 50), "Score:", text_style);
            GUI.Label(new Rect(55, 5, 200, 50), action.GetScore().ToString(), score_style);

            GUI.Label(new Rect(Screen.width - 120, 5, 50, 50), "Life:", text_style);
            //显示当前血量
            for (int i = 0; i < life; i++)
            {
                GUI.Label(new Rect(Screen.width - 75 + 10 * i, 5, 50, 50), "x", bold_style);
            }
            //游戏结束
            if (life == 0)
            {
                high_score = high_score > action.GetScore() ? high_score : action.GetScore();
                GUI.Label(new Rect(Screen.width / 2 - 20, Screen.width / 2 - 250, 100, 100), "Game Over", over_style);
                GUI.Label(new Rect(Screen.width / 2 - 10, Screen.width / 2 - 200, 50, 50), "Your Score:", text_style);
                GUI.Label(new Rect(Screen.width / 2 + 50, Screen.width / 2 - 200, 50, 50), high_score.ToString(), text_style);
                if (GUI.Button(new Rect(Screen.width / 2 - 20, Screen.width / 2 - 150, 100, 50), "Restart"))
                {
                    life = 6;
                    action.ReStart();
                    return;
                }
                action.GameOver();
            }
        }
        else
        {
            GUI.Label(new Rect(Screen.width / 2 - 30, Screen.width / 2 - 350, 100, 100), "DiskGame!", over_style);
            GUI.Label(new Rect(Screen.width / 2 - 150, Screen.width / 2 - 220, 400, 100), "请用鼠标点击飞碟,即可使其消失", text_style);
            if (GUI.Button(new Rect(Screen.width / 2 - 20, Screen.width / 2 - 150, 100, 50), "Start!"))
            {
                game_start = true;
                action.BeginGame();
            }
        }
    }
示例#10
0
    void OnGUI()
    {
        boldStyle.normal.textColor  = new Color(1, 0, 0);
        boldStyle.fontSize          = 20;
        textStyle.normal.textColor  = new Color(0, 0, 0, 1);
        textStyle.fontSize          = 20;
        scoreStyle.normal.textColor = new Color(1, 0, 1, 1);
        scoreStyle.fontSize         = 20;
        overStyle.normal.textColor  = new Color(1, 0, 0);
        overStyle.fontSize          = 25;

        if (gameStart)
        {
            //用户射击
            if (Input.GetButtonDown("Fire1"))
            {
                Vector3 pos = Input.mousePosition;
                action.Hit(pos);
            }

            GUI.Label(new Rect(10, 5, 200, 50), "Score:", textStyle);
            GUI.Label(new Rect(55, 5, 200, 50), action.GetScore().ToString(), scoreStyle);

            GUI.Label(new Rect(Screen.width - 120, 5, 50, 50), "Life:", textStyle);
            //显示当前血量
            for (int i = 0; i < life; i++)
            {
                GUI.Label(new Rect(Screen.width - 75 + 10 * i, 5, 50, 50), "X", boldStyle);
            }
            //游戏结束
            if (life == 0)
            {
                score = action.GetScore();
                GUI.Label(new Rect(Screen.width / 2 - 20, Screen.width / 2 - 250, 100, 100), "Game Over", overStyle);
                GUI.Label(new Rect(Screen.width / 2 - 10, Screen.width / 2 - 200, 50, 50), "Score:", textStyle);
                GUI.Label(new Rect(Screen.width / 2 + 50, Screen.width / 2 - 200, 50, 50), score.ToString(), textStyle);
                if (GUI.Button(new Rect(Screen.width / 2 - 20, Screen.width / 2 - 150, 100, 50), "Restart"))
                {
                    life = 10;
                    action.Restart();
                    return;
                }
                action.GameOver();
            }
        }
        else
        {
            GUI.Label(new Rect(Screen.width / 2 - 30, Screen.width / 2 - 350, 100, 100), "Hit UFO!", overStyle);
            if (GUI.Button(new Rect(Screen.width / 2 - 25, Screen.width / 2 - 250, 100, 50), "Game Start"))
            {
                gameStart = true;
                action.BeginGame();
            }
        }
    }
示例#11
0
 //游戏结束
 public void gameOver()
 {
     if (action.GameOver())
     {
         if (!re.isActiveAndEnabled)
         {
             re.gameObject.SetActive(true);
         }
         gg.text = "Game Over!";
     }
 }
示例#12
0
    void OnGUI()
    {
        if (game_start)
        {
            //用户射击
            if (Input.GetButtonDown("Fire1"))
            {
                Vector3 pos = Input.mousePosition;
                action.Hit(pos);
            }

            GUI.Label(new Rect(10, 5, 200, 50), "分数:", text_style);
            GUI.Label(new Rect(55, 5, 200, 50), action.GetScore().ToString(), score_style);

            GUI.Label(new Rect(Screen.width - 120, 5, 50, 50), "生命:", text_style);
            //显示当前血量
            for (int i = 0; i < life; i++)
            {
                GUI.Label(new Rect(Screen.width - 75 + 10 * i, 5, 50, 50), "X", bold_style);
            }
            if (newround)
            {
                GUI.Label(new Rect(Screen.width / 2 - 30, Screen.width / 2 - 350, 100, 100), "ROUND " + round, newround_style);
            }
            //游戏结束
            if (life == 0)
            {
                high_score = high_score > action.GetScore() ? high_score : action.GetScore();
                GUI.Label(new Rect(Screen.width / 2 - 20, Screen.width / 2 - 250, 100, 100), "游戏结束", over_style);
                GUI.Label(new Rect(Screen.width / 2 - 10, Screen.width / 2 - 200, 50, 50), "最高分:", text_style);
                GUI.Label(new Rect(Screen.width / 2 + 50, Screen.width / 2 - 200, 50, 50), high_score.ToString(), text_style);
                if (GUI.Button(new Rect(Screen.width / 2 - 20, Screen.width / 2 - 150, 100, 50), "重新开始"))
                {
                    life     = 6;
                    newround = true;
                    round    = 0;
                    action.ReStart();
                    return;
                }
                action.GameOver();
            }
        }
        else
        {
            GUI.Label(new Rect(Screen.width / 2 - 30, Screen.width / 2 - 350, 100, 100), "Hit UFO!", over_style);
            GUI.Label(new Rect(Screen.width / 2 - 150, Screen.width / 2 - 220, 400, 100), "大量UFO出现,点击它们,即可消灭,快来加入战斗吧", text_style);
            if (GUI.Button(new Rect(Screen.width / 2 - 20, Screen.width / 2 - 150, 100, 50), "游戏开始"))
            {
                game_start = true;
                round      = 0;
                action.BeginGame();
            }
        }
    }
示例#13
0
 private void OnGUI()
 {
     if (action.getGameState() == GameState.WIN)
     {
         GUI.Label(new Rect(700, 300, 400, 400), "you win");
         GUI.color = Color.red;
     }
     if ((action.getGameState() == GameState.FAILED))
     {
         action.GameOver();
     }
 }
示例#14
0
    void OnGUI()
    {
        text_style.normal.textColor        = new Color(0, 0, 0, 1);
        text_style.fontSize                = 16;
        score_style.normal.textColor       = new Color(1, 0, 1, 1);
        score_style.fontSize               = 16;
        over_style.normal.textColor        = new Color(1, 0, 0);
        over_style.fontSize                = 25;
        description_style.fontSize         = 25;
        description_style.normal.textColor = new Color(1, 0, 0);

        if (game_start)
        {
            //用户射击
            if (Input.GetButtonDown("Fire1"))
            {
                Vector3 pos = Input.mousePosition;
                action.Hit(pos);
            }
            GUI.Label(new Rect(10, 5, 200, 30), "Round:", text_style);
            GUI.Label(new Rect(65, 5, 200, 30), round.ToString(), score_style);
            GUI.Label(new Rect(10, 45, 200, 30), "分数:", text_style);
            GUI.Label(new Rect(55, 45, 200, 30), action.GetScore().ToString(), score_style);

            GUI.Label(new Rect(10, 25, 200, 30), "生命:", text_style);
            GUI.Label(new Rect(55, 25, 200, 30), life.ToString(), score_style);
            //游戏结束
            if (life == 0)
            {
                high_score = high_score > action.GetScore() ? high_score : action.GetScore();
                GUI.Label(new Rect(Screen.width / 2 - 20, Screen.width / 2 - 250, 100, 100), "游戏结束", over_style);
                GUI.Label(new Rect(Screen.width / 2 - 10, Screen.width / 2 - 200, 50, 50), "最高分:", text_style);
                GUI.Label(new Rect(Screen.width / 2 + 50, Screen.width / 2 - 200, 50, 50), high_score.ToString(), text_style);
                if (GUI.Button(new Rect(Screen.width / 2 - 20, Screen.width / 2 - 150, 100, 50), "重新开始"))
                {
                    life = 20;
                    action.ReStart();
                    return;
                }
                action.GameOver();
            }
        }
        else
        {
            GUI.Label(new Rect(Screen.width / 2 - 30, Screen.width / 2 - 350, 100, 100), "Hit UFO!", over_style);
            GUI.Label(new Rect(Screen.width / 2 - 150, Screen.width / 2 - 220, 400, 100), "点击出现的UFO即可销毁,加油!", description_style);
            if (GUI.Button(new Rect(Screen.width / 2 - 20, Screen.width / 2 - 150, 100, 50), "游戏开始"))
            {
                game_start = true;
                action.BeginGame();
            }
        }
    }
示例#15
0
    void OnGUI()
    {
        bold_style.normal.textColor  = new Color(1, 0, 0);
        bold_style.fontSize          = 20;
        text_style.normal.textColor  = new Color(1, 1, 1);
        text_style.fontSize          = 20;
        score_style.normal.textColor = new Color(0, 1, 0);
        score_style.fontSize         = 20;
        over_style.normal.textColor  = new Color(1, 0, 0);
        over_style.fontSize          = 25;

        if (game_start)
        {
            //射击
            if (Input.GetButtonDown("Fire1"))
            {
                Vector3 pos = Input.mousePosition;
                action.Hit(pos);
            }

            GUI.Label(new Rect(450, 400, 200, 50), "分数:", text_style);
            GUI.Label(new Rect(500, 400, 200, 50), action.GetScore().ToString(), score_style);
            GUI.Label(new Rect(Screen.width - 500, 400, 50, 50), "生命:", text_style);
            for (int i = 0; i < life; i++)
            {
                GUI.Label(new Rect(Screen.width - 450 + 10 * i, 400, 50, 50), "0", bold_style);
            }

            //游戏结束
            if (life == 0)
            {
                high_score = high_score > action.GetScore() ? high_score : action.GetScore();
                GUI.Label(new Rect(Screen.width / 2 - 20, Screen.width / 2 - 250, 100, 100), "游戏结束", over_style);
                GUI.Label(new Rect(Screen.width / 2 - 10, Screen.width / 2 - 200, 50, 50), "最高分:", text_style);
                GUI.Label(new Rect(Screen.width / 2 + 50, Screen.width / 2 - 200, 50, 50), high_score.ToString(), text_style);
                if (GUI.Button(new Rect(Screen.width / 2 - 20, Screen.width / 2 - 320, 100, 50), "重新开始"))
                {
                    life = 6;
                    action.ReStart();
                    return;
                }
                action.GameOver();
            }
        }
        else
        {
            if (GUI.Button(new Rect(Screen.width / 2 - 20, Screen.width / 2 - 300, 100, 50), "开始"))
            {
                game_start = true;
                action.BeginGame();
            }
        }
    }
示例#16
0
    void OnGUI()
    {
        bold_style.normal.textColor  = new Color(1, 0, 0);
        bold_style.fontSize          = 16;
        text_style.normal.textColor  = new Color(0, 0, 0, 1);
        text_style.fontSize          = 16;
        score_style.normal.textColor = new Color(1, 0, 1, 1);
        score_style.fontSize         = 16;
        over_style.normal.textColor  = new Color(1, 0, 0);
        over_style.fontSize          = 25;

        if (game_start)
        {
            //用户射击
            if (Input.GetButtonDown("Fire1"))
            {
                Vector3 pos = Input.mousePosition;
                action.HitUFO(pos);
            }

            GUI.Label(new Rect(10, 10, 200, 40), "分数: " + action.getScore().ToString(), text_style);
            GUI.Label(new Rect(10, 50, 100, 40), "生命: " + health.ToString(), text_style);

            //游戏结束
            if (health == 0)
            {
                high_score = high_score > action.getScore() ? high_score : action.getScore();
                GUI.Label(new Rect(Screen.width / 2 - 20, Screen.width / 2 - 250, 100, 100), "游戏结束", over_style);
                GUI.Label(new Rect(Screen.width / 2 - 10, Screen.width / 2 - 200, 50, 50), "最高分:", text_style);
                GUI.Label(new Rect(Screen.width / 2 + 50, Screen.width / 2 - 200, 50, 50), high_score.ToString(), text_style);
                if (GUI.Button(new Rect(Screen.width / 2 - 20, Screen.width / 2 - 150, 100, 50), "重新开始"))
                {
                    health = 6;
                    action.ReStart();
                    return;
                }
                action.GameOver();
            }
        }
        else
        {
            GUI.Label(new Rect(Screen.width / 2 - 30, Screen.width / 2 - 350, 100, 100), "HelloUFO!", over_style);
            GUI.Label(new Rect(Screen.width / 2 - 150, Screen.width / 2 - 220, 400, 100), "大量UFO出现,点击它们,即可消灭,快来加入战斗吧", text_style);
            if (GUI.Button(new Rect(Screen.width / 2 - 20, Screen.width / 2 - 150, 100, 50), "游戏开始"))
            {
                game_start = true;
                action.BeginGame();
            }
        }
    }
示例#17
0
    void OnGUI()
    {
        bold_style.normal.textColor  = new Color(0, 0, 0);
        bold_style.fontSize          = 20;
        text_style.normal.textColor  = new Color(0, 0, 1);
        text_style.fontSize          = 20;
        score_style.normal.textColor = new Color(0, 1, 0);
        score_style.fontSize         = 20;
        over_style.normal.textColor  = new Color(0, 1, 1);
        over_style.fontSize          = 25;

        if (game_start)
        {
            //射击
            if (Input.GetButtonDown("Fire1"))
            {
                Vector3 pos = Input.mousePosition;
                action.Hit(pos);
            }

            GUI.Label(new Rect(300, 300, 200, 50), "Score:", text_style);
            GUI.Label(new Rect(370, 300, 200, 50), action.GetScore().ToString(), score_style);
            GUI.Label(new Rect(Screen.width - 500, 300, 50, 50), "Blood:", text_style);
            GUI.Label(new Rect(Screen.width - 440, 300, 50, 50), life.ToString(), bold_style);

            //游戏结束
            if (life == 0)
            {
                high_score = high_score > action.GetScore() ? high_score : action.GetScore();
                GUI.Label(new Rect(Screen.width / 2 - 20, Screen.width / 2 - 250, 100, 100), "GameOver", over_style);
                GUI.Label(new Rect(Screen.width / 2 - 10, Screen.width / 2 - 200, 50, 50), "Best Score:", text_style);
                GUI.Label(new Rect(Screen.width / 2 + 50, Screen.width / 2 - 200, 50, 50), high_score.ToString(), text_style);
                if (GUI.Button(new Rect(Screen.width / 2 - 20, Screen.width / 2 - 320, 100, 50), "Restart"))
                {
                    life = 6;
                    action.ReStart();
                    return;
                }
                action.GameOver();
            }
        }
        else
        {
            if (GUI.Button(new Rect(Screen.width / 2 - 20, Screen.width / 2 - 300, 100, 50), "Start"))
            {
                game_start = true;
                action.BeginGame();
            }
        }
    }
示例#18
0
    void OnGUI()
    {
        if (action.isEnd())
        {
            string mes;
            if (action.GetHP() <= 0)
            {
                mes = "You lost!";
            }
            else
            {
                mes = "You win!";
            }
            GUI.Label(new Rect(Screen.width / 2 - 50, Screen.height / 2 - 100, 100, 100), mes, header_style);
            GUI.Label(new Rect(Screen.width / 2 - 30, Screen.height / 2 - 50, 50, 50), "Your score:" + action.GetScore().ToString(), text_style);
            if (GUI.Button(new Rect(Screen.width / 2 - 20, Screen.height / 2, 100, 50), "Restart"))
            {
                action.Restart();
                return;
            }
            action.GameOver();
        }
        else if (started)
        {
            GUI.Label(new Rect(10, 5, 50, 50), "Round:" + action.GetRound().ToString(), header_style);
            GUI.Label(new Rect(10, 55, 50, 50), "Trial:" + action.GetTrial().ToString(), header_style);
            GUI.Label(new Rect(10, 105, 50, 50), "Score:" + action.GetScore().ToString(), header_style);
            GUI.Label(new Rect(10, 155, 50, 50), "HP   :" + action.GetHP().ToString(), header_style);
        }
        else
        {
            GUI.Label(new Rect(Screen.width / 2 - 70, 100, 100, 100), "Hit UFO", header_style);
            GUI.Label(new Rect(Screen.width / 2 - 150, 143, 100, 100), "Rule: use the mouse to hit UFO.", text_style);
            GUI.Label(new Rect(Screen.width / 2 - 100, 166, 100, 100), "if you miss 5 UFO, you will lost.", text_style);
            if (GUI.Button(new Rect(Screen.width / 2 - 100, 200, 100, 50), "Physic"))
            {
                action.setPhysic(true);
                started = true;
                action.Restart();
            }

            if (GUI.Button(new Rect(Screen.width / 2, 200, 100, 50), "tradition"))
            {
                action.setPhysic(false);
                started = true;
                action.Restart();
            }
        }
    }
示例#19
0
 private void OnGUI()
 {
     if (GUI.Button(new Rect(700, 100, 90, 90), "GO") && action.getGameState() == GameState.NOT_ENDED)
     {
         action.MoveBoat();
     }
     if (action.getGameState() == GameState.WIN)
     {
         GUI.Label(new Rect(700, 300, 400, 400), "you win");
         GUI.color = Color.red;
     }
     if ((action.getGameState() == GameState.FAILED))
     {
         action.GameOver();
     }
 }
示例#20
0
    void OnGUI()
    {
        float width  = Screen.width / 6;
        float height = Screen.height / 12;

        if (GUI.Button(new Rect(0, 0, width, height), "Game Over!"))
        {
            action.GameOver();
        }

        string paused_title = SSDirector.getInstance().Paused ? "Resume" : "Pause!";

        if (GUI.Button(new Rect(width, 0, width, height), paused_title))
        {
            SSDirector.getInstance().Paused = !SSDirector.getInstance().Paused;
        }
    }
示例#21
0
    private void OnGUI()
    {
        if (GUI.Button(new Rect(450, 100, 100, 40), "GO") && action.getGameState() == GameState.NOT_ENDED)
        {
            action.MoveBoat();
        }

        if (action.getGameState() == GameState.WIN)
        {
            GUI.Label(new Rect(490, 50, 800, 450), "Win!");
        }

        if (action.getGameState() == GameState.FAILED)
        {
            action.GameOver();
        }
    }
示例#22
0
 void OnGUI()
 {
     if (isStart == false)
     {
         if (GUI.Button(new Rect(200, 200, 240, 80), "Start Game"))
         {
             controller.LoadResources();
             isStart = true;
         }
     }
     else
     {
         if (isPause == true)
         {
             GUI.Label(new Rect(310, 400, 120, 20), "waiting!!!");
         }
         if (GUI.Button(new Rect(570, 5, 60, 20), "Resume"))
         {
             controller.Resume();
             isPause = false;
         }
         if (GUI.Button(new Rect(505, 5, 60, 20), "Pause"))
         {
             controller.Pause();
             isPause = true;
         }
         if (isPause == false)
         {
             if (GUI.Button(new Rect(5, 5, 100, 20), "Speed Up"))
             {
                 action.SpeedUp();
             }
             if (GUI.Button(new Rect(110, 5, 100, 20), "Speed Down"))
             {
                 action.SpeedDown();
             }
             if (GUI.Button(new Rect(215, 5, 100, 20), "Restart"))
             {
                 isStart = false; isPause = false;
                 action.GameOver();
             }
         }
     }
 }
示例#23
0
 void OnGUI()
 {
     ScoreText.text = "Score: " + score.getScore().ToString();
     GUI.Label(new Rect(4 * Screen.width / 5, 2 * Screen.height / 5, Screen.width / 8, Screen.height / 2), "巡逻兵在设定范围内感知到玩家,会自动追击玩家计分:玩家每次甩掉一个巡逻兵计一分,与巡逻兵碰撞游戏结束;");
     if (!actions.GameStart())
     {
         if (GUI.Button(new Rect(4 * Screen.width / 5, Screen.height / 5, Screen.width / 9, Screen.width / 16), "Start"))
         {
             actions.StartGame();
         }
     }
     if (actions.GameOver() && actions.GameStart())
     {
         if (GUI.Button(new Rect(4 * Screen.width / 5, Screen.height / 5, Screen.width / 9, Screen.width / 16), "Restart"))
         {
             actions.Restart();
         }
     }
 }
示例#24
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(300, 50, 150, 50), "RESTART"))
        {
            action.Restart();
        }
        if (state != 0)
        {
            if (state == 1)
            {
                GUI.color = Color.green;
                GUI.Label(new Rect(400, 105, 50, 50), "Win.");
            }
            else
            {
                GUI.color = Color.red;
                GUI.Label(new Rect(400, 105, 50, 50), "Lose.");
            }
            return;
        }
        if (Input.GetMouseButtonDown(0))
        {
            flag = true;
        }
        else if (Input.GetMouseButtonUp(0) && flag)
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hitInfo;

            if (Physics.Raycast(ray, out hitInfo))
            {
                GameObject gameObj = hitInfo.collider.gameObject;
                //action.Clicked (gameObj);
                state = action.Check();
                if (state != 0)
                {
                    action.GameOver();
                }
            }
        }
    }
示例#25
0
    void OnGUI()
    {
        style2.fontSize = 30;
        style1.fontSize = 30;
        style3.fontSize = 30;

        if (isGameStart)
        {
            if (Input.GetButtonDown("Fire1"))
            {
                Vector3 pos = Input.mousePosition;
                action.Hit(pos);
            }

            GUI.Label(new Rect(700, 10, 200, 50), "分数:", style2);
            GUI.Label(new Rect(780, 10, 200, 50), action.GetScore().ToString(), style1);

            if (XP == 0)
            {
                highestScore = highestScore > action.GetScore() ? highestScore : action.GetScore();
                GUI.Label(new Rect(700, 400, 100, 100), "游戏结束", style3);
                GUI.Label(new Rect(700, 500, 50, 50), "得分:", style2);
                GUI.Label(new Rect(820, 500, 50, 50), highestScore.ToString(), style2);
                if (GUI.Button(new Rect(Screen.width / 2 - 20, Screen.width / 2 - 150, 100, 50), "重新开始"))
                {
                    XP = 3;
                    action.Restart();
                    return;
                }
                action.GameOver();
            }
        }
        else
        {
            if (GUI.Button(new Rect(Screen.width / 2 - 20, Screen.width / 2 - 150, 100, 50), "游戏开始"))
            {
                isGameStart = true;
                action.StartGame();
            }
        }
    }
    void OnGUI()
    {
        GUIStyle style1 = new GUIStyle();
        GUIStyle style2 = new GUIStyle();
        GUIStyle style3 = new GUIStyle();
        GUIStyle style4 = new GUIStyle();
        GUIStyle style5 = new GUIStyle();

        style1.normal.textColor = style2.normal.textColor = style5.normal.textColor = Color.white;
        style3.normal.textColor = style4.normal.textColor = new Color(0.72f, 0.25f, 0.25f);
        style1.fontSize         = style4.fontSize = 60;
        style2.fontSize         = 40;
        style3.fontSize         = style5.fontSize = 20;

        if (index)
        {
            GUI.Label(new Rect(250, 80, 60, 300), "Hit UFO", style1);
            if (GUI.Button(new Rect(320, 200, 60, 50), "Play", style2))
            {
                index = false;
                userAction.ReStart();
            }
        }
        else
        {
            GUI.Label(new Rect(12, 12, 200, 50), "Round:" + userAction.GetRound(), style3);
            GUI.Label(new Rect(Screen.width - 90, 12, 200, 50), "Score:" + userAction.GetScore(), style3);

            if (userAction.isGameOver())
            {
                GUI.Label(new Rect(200, 80, 100, 100), "Game Over", style4);
                GUI.Label(new Rect(288, 170, 50, 50), "Your Score:" + userAction.GetScore().ToString(), style5);
                if (GUI.Button(new Rect(290, Screen.height / 2 + 30, 100, 50), "Replay", style2))
                {
                    userAction.ReStart();
                    return;
                }
                userAction.GameOver();
            }
        }
    }
示例#27
0
    void OnGUI()
    {
        bold_style.normal.textColor = new Color(1, 0, 0);
        bold_style.fontSize         = 16;
        text_style.normal.textColor = new Color(0, 0, 0, 1);
        text_style.fontSize         = 16;
        over_style.normal.textColor = new Color(1, 0, 0);
        over_style.fontSize         = 25;

        if (game_start)
        {
            GUI.Label(new Rect(Screen.width - 150, 5, 200, 50), "分数:" + action.GetScore().ToString(), text_style);
            GUI.Label(new Rect(100, 5, 50, 50), "Round:" + action.GetRound().ToString(), text_style);
            GUI.Label(new Rect(180, 5, 50, 50), "Trial:" + action.GetTrial().ToString(), text_style);

            if (action.GetRound() == 3 && action.GetTrial() == 10)
            {
                GUI.Label(new Rect(Screen.width / 2 - 20, Screen.height / 2 - 250, 100, 100), "游戏结束", over_style);
                GUI.Label(new Rect(Screen.width / 2 - 10, Screen.height / 2 - 200, 50, 50), "你的分数:" + action.GetScore().ToString(), text_style);
                if (GUI.Button(new Rect(Screen.width / 2 - 20, Screen.height / 2 - 150, 100, 50), "重新开始"))
                {
                    action.ReStart();
                    return;
                }
                action.GameOver();
            }
        }
        else
        {
            GUI.Label(new Rect(Screen.width / 2 - 50, 100, 100, 100), "简单打飞碟", over_style);
            GUI.Label(new Rect(Screen.width / 2 - 50, 150, 100, 100), "鼠标点击飞碟", text_style);
            if (GUI.Button(new Rect(Screen.width / 2 - 50, 200, 100, 50), "游戏开始"))
            {
                game_start = true;
                action.ReStart();
            }
        }
    }
示例#28
0
    void OnGUI()
    {
        bold_style.normal.textColor = new Color(1, 0, 0);
        bold_style.fontSize         = 16;
        text_style.normal.textColor = new Color(0, 0, 0, 1);
        text_style.fontSize         = 16;
        over_style.normal.textColor = new Color(1, 0, 0);
        over_style.fontSize         = 25;

        if (game_start)
        {
            GUI.Label(new Rect(Screen.width - 150, 5, 200, 50), "Score:" + action.GetScore().ToString(), text_style);
            GUI.Label(new Rect(100, 5, 50, 50), "Round:" + action.GetRound().ToString(), text_style);
            GUI.Label(new Rect(180, 5, 50, 50), "Trial:" + action.GetTrial().ToString(), text_style);

            if (action.GetRound() == 3 && action.GetTrial() == 10)
            {
                GUI.Label(new Rect(Screen.width / 2 - 20, Screen.height / 2 - 100, 100, 100), "GameOver", over_style);
                GUI.Label(new Rect(Screen.width / 2 - 10, Screen.height / 2 - 50, 50, 50), "Your Score:" + action.GetScore().ToString(), text_style);
                if (GUI.Button(new Rect(Screen.width / 2 - 20, Screen.height / 2, 100, 50), "Restart"))
                {
                    action.ReStart();
                    return;
                }
                action.GameOver();
            }
        }
        else
        {
            GUI.Label(new Rect(Screen.width / 2 - 60, Screen.height / 2 - 100, 100, 100), "Hit UFO", over_style);
            GUI.Label(new Rect(Screen.width / 2 - 50, Screen.height / 2 - 50, 100, 100), "Hit the UFO by click mouse", text_style);
            if (GUI.Button(new Rect(Screen.width / 2 - 50, Screen.height / 2, 100, 50), "Start"))
            {
                game_start = true;
                action.ReStart();
            }
        }
    }
示例#29
0
    void OnGUI()
    {
        GUIStyle textStyle   = new GUIStyle();
        GUIStyle buttonStyle = new GUIStyle();

        textStyle.fontSize   = 30;
        buttonStyle.fontSize = 15;
        if (GUI.Button(new Rect(30, 50, 50, 30), "Start"))
        {
            action.BeginGame();
        }
        if (action.GetBlood() > 0)
        {
            GUI.Label(new Rect(10, 10, 300, 150), "回合:");
            GUI.Label(new Rect(50, 10, 300, 150), action.GetRound().ToString());
            GUI.Label(new Rect(90, 10, 300, 150), "分数:");
            GUI.Label(new Rect(130, 10, 300, 150), action.GetScore().ToString());
            GUI.Label(new Rect(170, 10, 300, 150), "血量:");
            GUI.Label(new Rect(210, 10, 300, 150), action.GetBlood().ToString());
            if (Input.GetButtonDown("Fire1"))
            {
                Vector3 pos = Input.mousePosition;
                action.hit(pos);
                Debug.Log("hit: " + pos);
            }
        }
        if (action.GetBlood() <= 0)
        {
            action.GameOver();
            GUI.Label(new Rect(Screen.width / 2 - 60, Screen.height / 2 + 80, 100, 50), "GameOver!");
            GUI.Label(new Rect(Screen.width / 2 - 60, Screen.height / 2 + 100, 100, 50), "Your score: ");
            GUI.Label(new Rect(Screen.width / 2 + 10, Screen.height / 2 + 100, 100, 50), action.GetScore().ToString());
            if (GUI.Button(new Rect(Screen.width / 2 - 60, Screen.height / 2, 100, 30), "Restart"))
            {
                action.Restart();
            }
        }
    }
示例#30
0
    void OnGUI()
    {
        chance_style.normal.textColor      = new Color(1, 0, 0);
        chance_style.fontSize              = 30;
        text_style.normal.textColor        = new Color(0, 0, 0, 1);
        text_style.fontSize                = 30;
        score_style.normal.textColor       = new Color(1, 0, 0);
        score_style.fontSize               = 30;
        over_style.normal.textColor        = new Color(1, 0, 0);
        over_style.fontSize                = 50;
        lost_chance_style.normal.textColor = new Color(1, 1, 1);
        lost_chance_style.fontSize         = 30;
        time_style.normal.textColor        = new Color(1, 0, 0);
        time_style.fontSize                = 100;

        if (game_start)
        {
            //用户射击
            if (Input.GetButtonDown("Fire1"))
            {
                Vector3 pos = Input.mousePosition;
                action.Hit(pos);
            }

            GUI.Label(new Rect(10, 5, 200, 50), "Score:", text_style);
            GUI.Label(new Rect(100, 5, 200, 50), action.GetScore().ToString(), score_style);

            GUI.Label(new Rect(Screen.width - 320, 5, 50, 50), "Chance:", text_style);
            //显示当前血量
            for (int i = 0; i < chance; i++)
            {
                GUI.Label(new Rect(Screen.width - 200 + 30 * i, 5, 50, 50), "✰", chance_style);
            }
            for (int i = chance; i < 6; i++)
            {
                GUI.Label(new Rect(Screen.width - 200 + 30 * i, 5, 50, 50), "✰", lost_chance_style);
            }
            //游戏结束
            if (chance == 0)
            {
                high_score = high_score > action.GetScore() ? high_score : action.GetScore();
                GUI.Label(new Rect(Screen.width / 2 - 100, 110, 100, 100), "GameOver", over_style);
                GUI.Label(new Rect(Screen.width / 2 - 80, 200, 50, 50), "Score:", text_style);
                GUI.Label(new Rect(Screen.width / 2 + 50, 200, 50, 50), high_score.ToString(), text_style);

                if (GUI.Button(new Rect(Screen.width / 2 - 60, 300, 100, 50), "Restart"))
                {
                    chance = 6;
                    action.ReStart();
                    return;
                }
                action.GameOver();
            }
        }
        else
        {
            GUI.Label(new Rect(Screen.width / 2 - 110, 110, 100, 100), "Hit UFO!", over_style);
            //    GUI.Label(new Rect(Screen.width / 2 - 150, Screen.width / 2 - 220, 400, 100), "大量UFO出现,点击它们,即可消灭,快来加入战斗吧", text_style);
            if (GUI.Button(new Rect(Screen.width / 2 - 60, 200, 100, 50), "Let's go!"))
            {
                game_start = true;

                action.BeginGame();
            }
        }
    }