Example #1
0
    void Update()
    {
        thePlayer2 = objPlayer.getP2Reference();
        if (thePlayer2 != null)
        {
            objPlayer2 = thePlayer2.GetComponent <Player2Controller> ();
        }
        if (thePlayer2 != null)
        {
            if (!objPlayer.getGameOver() && !objPlayer2.getGameOver())
            {
                transform.Rotate(Quaternion.Euler(60, 0, 0) * Vector3.left, -240 * Time.deltaTime * speed);
            }
        }
        else
        {
            if (!objPlayer.getGameOver())
            {
                transform.Rotate(Quaternion.Euler(60, 0, 0) * Vector3.left, -240 * Time.deltaTime * speed);
            }
        }

        CheckRopePosition();
        CheckPlayerJumps();
    }
Example #2
0
    void OnGUI()
    {
        GUIStyle style = new GUIStyle();

        style.normal.textColor = Color.red;
        style.fontSize         = 40;
        style.fontStyle        = FontStyle.Bold;

        GUI.skin.font          = pixelFont;
        style.normal.textColor = Color.green;
        //GUI.Label(new Rect(20, 20, 100, 100), scoreText, style);

        AdvancedTextRendering.DrawOutline(new Rect(0, 40, 100, 100),
                                          scoreText,
                                          style,
                                          Color.black,
                                          Color.green,
                                          0.9f);

        AdvancedTextRendering.DrawOutline(new Rect(0, 80, 100, 100),
                                          highScoreText,
                                          style,
                                          Color.black,
                                          Color.white,
                                          0.9f);

        string gameOverMessage = "Try again";
        Color  colorGameOver   = Color.cyan;

        if (numPlayers == 2)
        {
            gameOverMessage = "P2 Win";
            colorGameOver   = Color.magenta;
            if (objPlayer2.getGameOver())
            {
                gameOverMessage = "Draw";
                colorGameOver   = Color.cyan;
            }
        }
        Color c = GUI.backgroundColor;

        GUI.backgroundColor = Color.clear;


        if (!gameOver && !paused)
        {
            if (numPlayers == 2)
            {
                if (!objPlayer2.getGameOver())
                {
                    Rect rectP1 = new Rect(0, 0, (Screen.width / 2), (Screen.height));
                    if (GUI.Button(rectP1, ""))
                    {
                        if (!paused)
                        {
                            Jump();
                        }
                    }
                    Rect rectP2 = new Rect((Screen.width / 2), 0, (Screen.width / 2), (Screen.height));
                    if (GUI.Button(rectP2, ""))
                    {
                        if (!paused)
                        {
                            objPlayer2.Jump();
                        }
                    }
                }
            }
        }

        if (gameOver)
        {
            style.fontSize         = 60;
            style.normal.textColor = Color.cyan;
            Rect rect = new Rect((Screen.width) / 2 - 150, (Screen.height) / 2 - 50, 0, 0);
            //GUI.Label(rect, "Try again",style);
            AdvancedTextRendering.DrawOutline(rect,
                                              gameOverMessage,
                                              style,
                                              Color.black,
                                              colorGameOver,
                                              0.9f);
            StopTime();
            Rect rect3 = new Rect(0, 0, Screen.width, Screen.height);
            GUI.depth = 1;
            if (GUI.Button(rect3, ""))
            {
                ResumeTime();
                Jump();
            }
        }
        //GUI.backgroundColor = c;
    }