Esempio n. 1
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;
            }
        }
    }
Esempio n. 2
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();
            }
        }
    }
Esempio n. 3
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.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();
            }
        }
    }
Esempio n. 4
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();
            }
        }
    }
Esempio n. 5
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.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();
            }
        }
    }
Esempio n. 6
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();
            }
        }
    }
Esempio n. 7
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();
            }
        }
    }
Esempio n. 8
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();
            }
        }
    }
Esempio n. 9
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();
            }
        }
    }
Esempio n. 10
0
 private void OnGUI()
 {
     GUI.Label(new Rect(Screen.width / 2 + 50, Screen.width / 2 + 150, 100, 50), "待施救友军:" + action.GetFriend().ToString());
     if (!game_start)
     {
         if (GUI.Button(new Rect(Screen.width / 2 - 50, Screen.width / 2 - 150, 100, 50), "start"))
         {
             game_start = true;
             action.BeginGame();
         }
     }
 }
Esempio n. 11
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();
            }
        }
    }
Esempio n. 12
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();
            }
        }
    }
Esempio n. 13
0
 private void OnGUI()
 {
     if (game_start)
     {
         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 - 170, 30, 200, 50), "风向: ", text_style);
         GUI.Label(new Rect(Screen.width - 110, 30, 200, 50), action.GetWind(), text_style);
     }
     else
     {
         GUI.Label(new Rect(Screen.width / 2 - 60, Screen.width / 2 - 320, 100, 100), "简单打靶", text_style);
         if (GUI.Button(new Rect(Screen.width / 2 - 50, Screen.width / 2 - 150, 100, 50), "游戏开始"))
         {
             game_start = true;
             action.BeginGame();
         }
     }
 }
Esempio n. 14
0
    private void OnGUI()
    {
        if (game_start)
        {
            if (!action.GetGameover())
            {
                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 / 2 - 30, 8, 200, 50), "Aim Score:", text_style);
                GUI.Label(new Rect(Screen.width / 2 + 50, 8, 200, 50), action.GetTargetScore().ToString(), score_style);

                GUI.Label(new Rect(Screen.width - 170, 5, 50, 50), "Arrow:", text_style);
                for (int i = 0; i < action.GetResidueNum(); i++)
                {
                    GUI.Label(new Rect(Screen.width - 110 + 10 * i, 5, 50, 50), "I ", bold_style);
                }
                GUI.Label(new Rect(Screen.width - 170, 30, 200, 50), "Wind: ", text_style);
                GUI.Label(new Rect(Screen.width - 110, 30, 200, 50), action.GetWind(), text_style);
            }

            if (action.GetGameover())
            {
                GUI.Label(new Rect(Screen.width / 2 - 50, Screen.width / 2 - 250, 100, 100), "GAME OVER", over_style);
                if (GUI.Button(new Rect(Screen.width / 2 - 50, Screen.width / 2 - 150, 100, 50), "RESTRAT"))
                {
                    action.Restart();
                    return;
                }
            }
        }
        else
        {
            GUI.Label(new Rect(Screen.width / 2 - 150, Screen.width / 2 - 220, 400, 100), "WSAD or arrow keys to move bow, left click to shoot", text_style);
            if (GUI.Button(new Rect(Screen.width / 2 - 50, Screen.width / 2 - 150, 100, 50), "STRAT"))
            {
                game_start = true;
                action.BeginGame();
            }
        }
    }
Esempio n. 15
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();
            }
        }
    }
Esempio n. 16
0
 private void OnGUI()
 {
     if (game_start)
     {
         GUI.Label(new Rect(10, 10, 200, 50), "分数:", style1);
         GUI.Label(new Rect(55, 10, 200, 50), action.GetScore().ToString(), style1);
         GUI.Label(new Rect(Screen.width - 170, 30, 200, 50), "风向:", style1);
         GUI.Label(new Rect(Screen.width - 140, 30, 200, 50), action.GetWind(), style1);
         if (GUI.Button(new Rect(Screen.width - 170, 0, 100, 30), "重新开始"))
         {
             action.Restart();
             return;
         }
     }
     else
     {
         GUI.Label(new Rect(Screen.width / 2 - 80, Screen.width / 2 - 320, 100, 100), "Arrow Shooting", style2);
         if (GUI.Button(new Rect(Screen.width / 2 - 50, Screen.width / 2 - 200, 100, 50), "游戏开始"))
         {
             game_start = true;
             action.BeginGame();
         }
     }
 }
Esempio n. 17
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();
            }
        }
    }
Esempio n. 18
0
    void OnGUI()
    {
        bold_style.normal.textColor  = new Color(1, 0, 0);
        bold_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, 1, 1);
        score_style.fontSize         = 30;
        over_style.normal.textColor  = new Color(1, 0, 0);
        over_style.fontSize          = 50;
        wait_style.normal.textColor  = new Color(0, 0, 0);
        wait_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), "分数:", text_style);
            GUI.Label(new Rect(85, 5, 200, 50), action.GetScore().ToString(), score_style);

            GUI.Label(new Rect(Screen.width - 280, 5, 50, 50), "生命:", text_style);
            //显示当前血量
            for (int i = 0; i < life; i++)
            {
                GUI.Label(new Rect(Screen.width - 200 + 30 * i, 5, 50, 50), "❤️", bold_style);
            }
            for (int i = life; i < 6; i++)
            {
                GUI.Label(new Rect(Screen.width - 200 + 30 * i, 5, 50, 50), "❤️", wait_style);
            }

            if (action.GetCoolTimes() >= 0 && action.GetRound() == 1)
            {
                //    GUI.Label(new Rect(Screen.width / 2 - 100, 60, 200, 50), "", wait_style);
                if (action.GetCoolTimes() == 0)
                {
                    GUI.Label(new Rect(Screen.width / 2 - 200, 150, 200, 50), "ROUND 1", time_style);
                }
                else
                {
                    GUI.Label(new Rect(Screen.width / 2 - 30, 150, 200, 50), action.GetCoolTimes().ToString(), time_style);
                }
            }
            if (action.GetRound() == 2 && action.GetCoolTimes2() > 0)
            {
                GUI.Label(new Rect(Screen.width / 2 - 200, 150, 200, 50), "ROUND 2", time_style);
            }
            if (action.GetRound() == 3 && action.GetCoolTimes3() > 0)
            {
                GUI.Label(new Rect(Screen.width / 2 - 200, 150, 200, 50), "ROUND 3", time_style);
            }


            //游戏结束
            if (life == 0)
            {
                high_score = high_score > action.GetScore() ? high_score : action.GetScore();
                GUI.Label(new Rect(Screen.width / 2 - 100, 110, 100, 100), "游戏结束", over_style);
                GUI.Label(new Rect(Screen.width / 2 - 80, 200, 50, 50), "最高分:", 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), "重新开始"))
                {
                    life = 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), "游戏开始"))
            {
                game_start = true;

                action.BeginGame();
            }
        }
    }