Example #1
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(Screen.width / 2 - 50, Screen.height / 2 + 200, 100, 100), "Go!"))
        {
            if (BoatController.count >= 1)
            {
                BoatController.if_move = true;
                run = false;
                int count = BoatController.boat.transform.childCount;
                if (BoatController.direction_left)
                {
                    for (int i = 0; i < count; ++i)
                    {
                        Click.decCount(BoatController.boat.transform.GetChild(i).name, 0);
                        Click.insCount(BoatController.boat.transform.GetChild(i).name, 1);
                    }
                }
                else
                {
                    for (int i = 0; i < count; ++i)
                    {
                        Click.decCount(BoatController.boat.transform.GetChild(i).name, 1);
                        Click.insCount(BoatController.boat.transform.GetChild(i).name, 0);
                    }
                }
            }
        }

        // 判断情况
        if (Judge.judgeEnd() == 2 || Judge.judgeEnd() == 1)
        {
            GUI.Label(new Rect(Screen.width / 2 - 100, Screen.height / 2 - 200, 200, 200), "Failed, reload after 2s", mstyle);
            Invoke("reset", Time.time + 2);
        }
        else if (Judge.judgeEnd() == 0)
        {
            GUI.Label(new Rect(Screen.width / 2 - 100, Screen.height / 2 - 200, 200, 200), "Success! reload after 2s", mstyle);
            Invoke("reset", Time.time + 2);
        }
    }
Example #2
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(Screen.width / 2 - 50, Screen.height / 2 + 200, 100, 100), "Go!"))
        {
            if (BoatController.count >= 1)
            {
                BoatController.if_move = true;
                run = false;
                int count = BoatController.boat.transform.childCount;
                if (BoatController.direction_left)
                {
                    for (int i = 0; i < count; ++i)
                    {
                        Click.decCount(BoatController.boat.transform.GetChild(i).name, 0);
                        Click.insCount(BoatController.boat.transform.GetChild(i).name, 1);
                    }
                }
                else
                {
                    for (int i = 0; i < count; ++i)
                    {
                        Click.decCount(BoatController.boat.transform.GetChild(i).name, 1);
                        Click.insCount(BoatController.boat.transform.GetChild(i).name, 0);
                    }
                }
                ++step;
            }
            tips = "";
        }

        if (GUI.Button(new Rect(Screen.width / 2 - 100, Screen.height / 2 + 260, 40, 40), "Tips"))
        {
            if (Coast.east_devil_count == 3 && Coast.east_priest_count == 3)
            {
                tips = "Tips\nDevil: left -> 2\tright -> 1\nPriest: left -> 0\t right-> 3";
            }
            else if (Coast.east_devil_count == 1 && Coast.east_priest_count == 3 && step == 1)
            {
                tips = "Tips\nDevil: left -> 1\tright -> 2\nPriest: left -> 0\t right-> 3";
            }
            else if (Coast.east_devil_count == 2 && Coast.east_priest_count == 3)
            {
                tips = "Tips\nDevil: left -> 3\tright -> 0\nPriest: left -> 0\t right-> 3";
            }
            else if (Coast.east_devil_count == 0 && Coast.east_priest_count == 3)
            {
                tips = "Tips\nDevil: left -> 2\tright -> 1\nPriest: left -> 0\t right-> 3";
            }
            else if (Coast.east_devil_count == 1 && Coast.east_priest_count == 3 && step == 4)
            {
                tips = "Tips\nDevil: left -> 2\tright -> 1\nPriest: left -> 2\t right-> 1";
            }
            else if (Coast.east_devil_count == 1 && Coast.east_priest_count == 1)
            {
                tips = "Tips\nDevil: left -> 1\tright -> 2\nPriest: left -> 1\t right-> 2";
            }
            else if (Coast.east_devil_count == 2 && Coast.east_priest_count == 2)
            {
                tips = "Tips\nDevil: left -> 1\tright -> 2\nPriest: left -> 3\t right-> 0";
            }
            else if (Coast.east_devil_count == 2 && Coast.east_priest_count == 0 && step == 7)
            {
                tips = "Tips\nDevil: left -> 0\tright -> 3\nPriest: left -> 3\t right-> 0";
            }
            else if (Coast.east_devil_count == 3 && Coast.east_priest_count == 0)
            {
                tips = "Tips\nDevil: left -> 2\tright -> 1\nPriest: left -> 3\t right-> 0";
            }
            else if (Coast.east_devil_count == 1 && Coast.east_priest_count == 0)
            {
                tips = "Tips\nDevil: left -> 1\tright -> 2\nPriest: left -> 3\t right-> 0";
            }
            else if (Coast.east_devil_count == 2 && Coast.east_priest_count == 0)
            {
                tips = "Tips\nDevil: left -> 3\tright -> 0\nPriest: left -> 3\t right-> 0";
            }
            else
            {
                tips = "";
            }
            Debug.Log(step);
        }
        GUI.Label(new Rect(Screen.width / 5, Screen.height / 5, 200, 200), tips, mstyle);

        // success or lose or normal condition
        if (Judge.judgeEnd() == 2 || Judge.judgeEnd() == 1)   // lose
        {
            GUI.Label(new Rect(Screen.width / 2 - 100, Screen.height / 2 - 200, 200, 200), "Failed, reload after 2s", mstyle);
            Invoke("reset", Time.time + 2);
        }
        else if (Judge.judgeEnd() == 0)     // success
        {
            GUI.Label(new Rect(Screen.width / 2 - 100, Screen.height / 2 - 200, 200, 200), "Success! reload after 2s", mstyle);
            Invoke("reset", Time.time + 2);
        }
    }