void OnGUI()
    {
        GUI.skin = skin;

        GUI.Box(new Rect(10, 10, 100, 120), "");

        //int health = PlayerInfo.GetMainFrogHealth();

        // This could probably be made better by using GUI groups.
        GUI.DrawTexture(new Rect(20, 20, heartSize, heartSize), flyTex, ScaleMode.ScaleToFit, true, 0.0f);
        GUI.DrawTexture(new Rect(20, 45, heartSize, heartSize), eggTex, ScaleMode.ScaleToFit, true, 0.0f);
        GUI.DrawTexture(new Rect(20, 70, heartSize, heartSize), snakeTex, ScaleMode.ScaleToFit, true, 0.0f);
        GUI.DrawTexture(new Rect(20, 95, heartSize, heartSize), scoreTex, ScaleMode.ScaleToFit, true, 0.0f);

        GUI.Label(new Rect(40, 20, 120, 20), ": " + FlyPlayerInfo.NumFlies);
        GUI.Label(new Rect(40, 45, 120, 20), ": " + FlyPlayerInfo.SelectedFliesResource1);
        GUI.Label(new Rect(40, 70, 120, 20), ": " + FlyPlayerInfo.SelectedFliesResource2);
        GUI.Label(new Rect(40, 95, 120, 20), ": " + FlyPlayerInfo.PlayerScore);

        // Draw the pause menu
        if (isPaused)
        {
            int menuWidth  = 300;
            int menuHeight = 220;

            // Center the menu on the screen.
            GUI.BeginGroup(new Rect(Screen.width / 2 - menuWidth / 2, Screen.height / 2 - menuHeight / 2, menuWidth, menuHeight));
            GUI.Box(new Rect(0, 0, menuWidth, menuHeight), "");
            GUI.Label(new Rect(79, 30, 100, 30), "Game Paused", pauseText);
            // Draw the button which will take the player back to the main menu.
            // And handle the situation in which it is pressed.
            if (GUI.Button(new Rect(100, 70, 100, 30), "Main Menu"))
            {
                UnPause();
                AStarTargeter.ClearGrids();
                FlyPlayerInfo.SetNewGame();
                Application.LoadLevel("MenuA2");
            }
            if (GUI.Button(new Rect(100, 110, 100, 30), "Resume"))
            {
                UnPause();
            }
            if (GUI.Button(new Rect(100, 150, 100, 30), "Exit Game"))
            {
                AppHelper.Quit();
            }
            GUI.EndGroup();
        }
    }
Exemple #2
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag.Equals("Fly"))
        {
            Flocking flocker = other.gameObject.GetComponent <Flocking>();

            if (flocker != null)
            {
                Destroy(other.gameObject.GetComponent <Flocking>());
                Flocking.DestroyFlockMember(other.gameObject);
            }

            Destroy(other.gameObject);

            transform.parent.gameObject.GetComponent <PlayerInfo>().IncrementScore();

            if (survivalMode)
            {
                FlyPlayerInfo.DecrementFlyCount();
            }
        }
    }