Inheritance: MonoBehaviour
Exemplo n.º 1
0
    void Awake()
    {
        // cache components to save on performance
        _transform = transform;
        _animator = this.GetComponent<Animator>();
        character = this.GetComponent<Player2Controls>();

        _animState = _p2AnimState;
    }
Exemplo n.º 2
0
    public void OnTriggerEnter2D(Collider2D collision)
    {
        player1 = GameObject.Find("Player1CatFighter").GetComponent <Player1Controls>();
        player2 = GameObject.Find("Player2CatFighter").GetComponent <Player2Controls>();

        if (collision.CompareTag("Player1Movement"))
        {
            player1.moveLeft = false;
        }

        if (collision.CompareTag("Player2Movement"))
        {
            player2.moveLeft = false;
        }
    }
Exemplo n.º 3
0
    void Start()
    {
        rb = GetComponent <Rigidbody2D>();
        GameObject      player2       = GameObject.Find("Gooey_Player2");
        Player2Controls player2Script = player2.GetComponent <Player2Controls>();

        if (player2Script.facingRight == true)
        {
            rb.velocity = new Vector2(xTrajectory, yTrajectory) * gooBombSpeed;
        }
        if (player2Script.facingRight == false)
        {
            rb.velocity = new Vector2(-xTrajectory, yTrajectory) * gooBombSpeed;
        }
    }
Exemplo n.º 4
0
    void Update()
    {
        if (!paused)
        {
            if (p1Win || p2Win)
            {
                if (p1Win)
                {
                    if (catSelected.player2Cats[0].activeSelf)
                    {
                        p2StandFrame[0].SetActive(false);

                        if (endTimer > 4)
                        {
                            p2FirstStunFrame[0].SetActive(true);
                        }

                        else if (endTimer > 2)
                        {
                            p2FirstStunFrame[0].SetActive(false);
                            p2SecondStunFrame[0].SetActive(true);
                        }

                        else if (endTimer <= 0)
                        {
                            SceneManager.LoadScene("Game");
                        }

                        endTimer -= Time.deltaTime;
                    }

                    if (catSelected.player2Cats[1].activeSelf)
                    {
                        p2StandFrame[1].SetActive(false);

                        if (endTimer > 4)
                        {
                            p2FirstStunFrame[1].SetActive(true);
                        }

                        else if (endTimer > 2)
                        {
                            p2FirstStunFrame[1].SetActive(false);
                            p2SecondStunFrame[1].SetActive(true);
                        }

                        else if (endTimer <= 0)
                        {
                            SceneManager.LoadScene("Game");
                        }

                        endTimer -= Time.deltaTime;
                    }

                    if (catSelected.player2Cats[2].activeSelf)
                    {
                        p2StandFrame[2].SetActive(false);

                        if (endTimer > 4)
                        {
                            p2FirstStunFrame[2].SetActive(true);
                        }

                        else if (endTimer > 2)
                        {
                            p2FirstStunFrame[2].SetActive(false);
                            p2SecondStunFrame[2].SetActive(true);
                        }

                        else if (endTimer <= 0)
                        {
                            SceneManager.LoadScene("Game");
                        }

                        endTimer -= Time.deltaTime;
                    }

                    if (catSelected.player2Cats[3].activeSelf)
                    {
                        p2StandFrame[3].SetActive(false);

                        if (endTimer > 4)
                        {
                            p2FirstStunFrame[3].SetActive(true);
                        }

                        else if (endTimer > 2)
                        {
                            p2FirstStunFrame[3].SetActive(false);
                            p2SecondStunFrame[3].SetActive(true);
                        }

                        else if (endTimer <= 0)
                        {
                            SceneManager.LoadScene("Game");
                        }

                        endTimer -= Time.deltaTime;
                    }

                    if (catSelected.player2Cats[4].activeSelf)
                    {
                        p2StandFrame[4].SetActive(false);

                        if (endTimer > 4)
                        {
                            p2FirstStunFrame[4].SetActive(true);
                        }

                        else if (endTimer > 2)
                        {
                            p2FirstStunFrame[4].SetActive(false);
                            p2SecondStunFrame[4].SetActive(true);
                        }

                        else if (endTimer <= 0)
                        {
                            SceneManager.LoadScene("Game");
                        }

                        endTimer -= Time.deltaTime;
                    }

                    if (catSelected.player2Cats[5].activeSelf)
                    {
                        p2StandFrame[5].SetActive(false);

                        if (endTimer > 4)
                        {
                            p2FirstStunFrame[5].SetActive(true);
                        }

                        else if (endTimer > 2)
                        {
                            p2FirstStunFrame[5].SetActive(false);
                            p2SecondStunFrame[5].SetActive(true);
                        }

                        else if (endTimer <= 0)
                        {
                            SceneManager.LoadScene("Game");
                        }

                        endTimer -= Time.deltaTime;
                    }

                    if (catSelected.player2Cats[6].activeSelf)
                    {
                        p2StandFrame[6].SetActive(false);

                        if (endTimer > 4)
                        {
                            p2FirstStunFrame[6].SetActive(true);
                        }

                        else if (endTimer > 2)
                        {
                            p2FirstStunFrame[6].SetActive(false);
                            p2SecondStunFrame[6].SetActive(true);
                        }

                        else if (endTimer <= 0)
                        {
                            SceneManager.LoadScene("Game");
                        }

                        endTimer -= Time.deltaTime;
                    }

                    if (catSelected.player2Cats[7].activeSelf)
                    {
                        p2StandFrame[7].SetActive(false);

                        if (endTimer > 4)
                        {
                            p2FirstStunFrame[7].SetActive(true);
                        }

                        else if (endTimer > 2)
                        {
                            p2FirstStunFrame[7].SetActive(false);
                            p2SecondStunFrame[7].SetActive(true);
                        }

                        else if (endTimer <= 0)
                        {
                            SceneManager.LoadScene("Game");
                        }

                        endTimer -= Time.deltaTime;
                    }
                }

                else if (p2Win)
                {
                    if (catSelected.player1Cats[0].activeSelf)
                    {
                        p1StandFrame[0].SetActive(false);

                        if (endTimer > 4)
                        {
                            p1FirstStunFrame[0].SetActive(true);
                        }

                        else if (endTimer > 2)
                        {
                            p1FirstStunFrame[0].SetActive(false);
                            p1SecondStunFrame[0].SetActive(true);
                        }

                        else if (endTimer <= 0)
                        {
                            SceneManager.LoadScene("Game");
                        }

                        endTimer -= Time.deltaTime;
                    }

                    if (catSelected.player1Cats[1].activeSelf)
                    {
                        p1StandFrame[1].SetActive(false);

                        if (endTimer > 4)
                        {
                            p1FirstStunFrame[1].SetActive(true);
                        }

                        else if (endTimer > 2)
                        {
                            p1FirstStunFrame[1].SetActive(false);
                            p1SecondStunFrame[1].SetActive(true);
                        }

                        else if (endTimer <= 0)
                        {
                            SceneManager.LoadScene("Game");
                        }

                        endTimer -= Time.deltaTime;
                    }

                    if (catSelected.player1Cats[2].activeSelf)
                    {
                        p1StandFrame[2].SetActive(false);

                        if (endTimer > 4)
                        {
                            p1FirstStunFrame[2].SetActive(true);
                        }

                        else if (endTimer > 2)
                        {
                            p1FirstStunFrame[2].SetActive(false);
                            p1SecondStunFrame[2].SetActive(true);
                        }

                        else if (endTimer <= 0)
                        {
                            SceneManager.LoadScene("Game");
                        }

                        endTimer -= Time.deltaTime;
                    }

                    if (catSelected.player1Cats[3].activeSelf)
                    {
                        p1StandFrame[3].SetActive(false);

                        if (endTimer > 4)
                        {
                            p1FirstStunFrame[3].SetActive(true);
                        }

                        else if (endTimer > 2)
                        {
                            p1FirstStunFrame[3].SetActive(false);
                            p1SecondStunFrame[3].SetActive(true);
                        }

                        else if (endTimer <= 0)
                        {
                            SceneManager.LoadScene("Game");
                        }

                        endTimer -= Time.deltaTime;
                    }

                    if (catSelected.player1Cats[4].activeSelf)
                    {
                        p1StandFrame[4].SetActive(false);

                        if (endTimer > 4)
                        {
                            p1FirstStunFrame[4].SetActive(true);
                        }

                        else if (endTimer > 2)
                        {
                            p1FirstStunFrame[4].SetActive(false);
                            p1SecondStunFrame[4].SetActive(true);
                        }

                        else if (endTimer <= 0)
                        {
                            SceneManager.LoadScene("Game");
                        }

                        endTimer -= Time.deltaTime;
                    }

                    if (catSelected.player1Cats[5].activeSelf)
                    {
                        p1StandFrame[5].SetActive(false);

                        if (endTimer > 4)
                        {
                            p1FirstStunFrame[5].SetActive(true);
                        }

                        else if (endTimer > 2)
                        {
                            p1FirstStunFrame[5].SetActive(false);
                            p1SecondStunFrame[5].SetActive(true);
                        }

                        else if (endTimer <= 0)
                        {
                            SceneManager.LoadScene("Game");
                        }

                        endTimer -= Time.deltaTime;
                    }

                    if (catSelected.player1Cats[6].activeSelf)
                    {
                        p1StandFrame[6].SetActive(false);

                        if (endTimer > 4)
                        {
                            p1FirstStunFrame[6].SetActive(true);
                        }

                        else if (endTimer > 2)
                        {
                            p1FirstStunFrame[6].SetActive(false);
                            p1SecondStunFrame[6].SetActive(true);
                        }

                        else if (endTimer <= 0)
                        {
                            SceneManager.LoadScene("Game");
                        }

                        endTimer -= Time.deltaTime;
                    }

                    if (catSelected.player1Cats[7].activeSelf)
                    {
                        p1StandFrame[7].SetActive(false);

                        if (endTimer > 4)
                        {
                            p1FirstStunFrame[7].SetActive(true);
                        }

                        else if (endTimer > 2)
                        {
                            p1FirstStunFrame[7].SetActive(false);
                            p1SecondStunFrame[7].SetActive(true);
                        }

                        else if (endTimer <= 0)
                        {
                            SceneManager.LoadScene("Game");
                        }

                        endTimer -= Time.deltaTime;
                    }
                }
            }

            else if (roundFinished && roundTimer >= 0) //Reset Round (player's position and updated UI Look)
            {
                //Timer to Display Round Number
                roundTimer -= Time.deltaTime;
                roundText.SetActive(true);

                //Display Text
                if (roundTimer >= 2)
                {
                    numberOfRoundText.text = "ROUND " + roundNumber.ToString();
                    if (roundTimer == 2.1)
                    {
                        p1HappyCat.Play();
                    }
                }

                else if (roundTimer >= 0.5)
                {
                    player1 = GameObject.Find("Player1CatFighter").GetComponent <Player1Controls>();
                    player2 = GameObject.Find("Player2CatFighter").GetComponent <Player2Controls>();

                    numberOfRoundText.text = "READY";
                    if (roundTimer == 0.51)
                    {
                        p2HappyCat.Play();
                    }
                }

                else if (roundTimer >= 0)
                {
                    numberOfRoundText.text = "FIGHT";
                    if (roundTimer == 0.1)
                    {
                        p1HappyCat.Play();
                        p2HappyCat.Play();
                    }
                }

                timerText.color = new Color(1, 1, 1, 1);
                timerText.text  = timer.ToString("F0");
            }

            else
            {
                timer         -= Time.deltaTime;
                timerText.text = timer.ToString("F0");
                roundFinished  = false;
                roundText.SetActive(false);
            }

            #region Timer Color Change
            if (timer >= 18 && timer <= 23)
            {
                timerText.color = new Color(1, .8f, .8f, 1);
            }

            else if (timer >= 14 && timer <= 17)
            {
                timerText.color = new Color(1, .6f, .6f, 1);
            }

            else if (timer >= 9 && timer <= 13)
            {
                timerText.color = new Color(1, .4f, .4f, 1);
            }

            else if (timer >= 5 && timer <= 8)
            {
                timerText.color = new Color(1, .2f, .2f, 1);
            }

            else if (timer >= 0 && timer <= 4)
            {
                timerText.color = new Color(1, 0, 0, 1);
            }
            #endregion

            //Player 1 Rounds Display
            switch (player1Wins)
            {
            case 1:
                player1Round1.SetActive(false);
                player1Round2.SetActive(true);
                player1Round3.SetActive(true);

                player1Round1Won.SetActive(true);
                player1Round2Won.SetActive(false);
                player1Round3Won.SetActive(false);
                break;

            case 2:
                player1Round1.SetActive(false);
                player1Round2.SetActive(false);
                player1Round3.SetActive(true);

                player1Round1Won.SetActive(true);
                player1Round2Won.SetActive(true);
                player1Round3Won.SetActive(false);
                break;

            case 3:
                player1Round1.SetActive(false);
                player1Round2.SetActive(false);
                player1Round3.SetActive(false);

                player1Round1Won.SetActive(true);
                player1Round2Won.SetActive(true);
                player1Round3Won.SetActive(true);
                break;

            default:
                player1Round1.SetActive(true);
                player1Round2.SetActive(true);
                player1Round3.SetActive(true);

                player1Round1Won.SetActive(false);
                player1Round2Won.SetActive(false);
                player1Round3Won.SetActive(false);
                break;
            }

            //Player 2 Rounds Display
            switch (player2Wins)
            {
            case 1:
                player2Round1.SetActive(false);
                player2Round2.SetActive(true);
                player2Round3.SetActive(true);

                player2Round1Won.SetActive(true);
                player2Round2Won.SetActive(false);
                player2Round3Won.SetActive(false);
                break;

            case 2:
                player2Round1.SetActive(false);
                player2Round2.SetActive(false);
                player2Round3.SetActive(true);

                player2Round1Won.SetActive(true);
                player2Round2Won.SetActive(true);
                player2Round3Won.SetActive(false);
                break;

            case 3:
                player2Round1.SetActive(false);
                player2Round2.SetActive(false);
                player2Round3.SetActive(false);

                player2Round1Won.SetActive(true);
                player2Round2Won.SetActive(true);
                player2Round3Won.SetActive(true);
                break;

            default:
                player2Round1.SetActive(true);
                player2Round2.SetActive(true);
                player2Round3.SetActive(true);

                player2Round1Won.SetActive(false);
                player2Round2Won.SetActive(false);
                player2Round3Won.SetActive(false);
                break;
            }

            if (timer <= 0)
            {
                TimeoutRound();
            }

            else if (player1Wins >= 3)
            {
                EraseGameData();
                SceneManager.LoadScene("Player1W");
            }

            else if (player2Wins >= 3)
            {
                EraseGameData();
                SceneManager.LoadScene("Player2W");
            }

            #region SongPlaying
            if (stageSelected.stages[0].activeSelf)
            {
                if (timer > 15 && !parkTheme.isPlaying)
                {
                    parkTheme.Play();
                }

                else if (timer < 15 && !intenseParkTheme.isPlaying)
                {
                    parkTheme.Stop();
                    intenseParkTheme.Play();
                }
            }

            if (stageSelected.stages[1].activeSelf)
            {
                if (timer > 15 && !dojoTheme.isPlaying)
                {
                    dojoTheme.Play();
                }

                else if (timer < 15 && !intenseDojoTheme.isPlaying)
                {
                    dojoTheme.Stop();
                    intenseDojoTheme.Play();
                }
            }

            if (stageSelected.stages[2].activeSelf)
            {
                if (timer > 15 && !catClubTheme.isPlaying)
                {
                    catClubTheme.Play();
                }

                else if (timer < 15 && !intenseCatClubTheme.isPlaying)
                {
                    catClubTheme.Stop();
                    intenseCatClubTheme.Play();
                }
            }

            if (stageSelected.stages[3].activeSelf)
            {
                if (timer > 15 && !soccerFieldTheme.isPlaying)
                {
                    soccerFieldTheme.Play();
                }

                else if (timer < 15 && !intenseSoccerFieldTheme.isPlaying)
                {
                    soccerFieldTheme.Stop();
                    intenseSoccerFieldTheme.Play();
                }
            }
            #endregion

            if (Input.GetButtonDown("StartButton") || Input.GetKeyDown(KeyCode.LeftControl) || Input.GetKeyDown(KeyCode.RightControl))
            {
                paused         = true;
                Time.timeScale = 0f;
            }
        }

        else
        {
            if (!controlScreen.activeSelf)
            {
                pauseScreen.SetActive(true);

                if (Input.GetButtonDown("StartButton") || Input.GetKeyDown(KeyCode.LeftControl) || Input.GetKeyDown(KeyCode.RightControl))
                {
                    Time.timeScale = 1f;
                    pauseScreen.SetActive(false);
                    controlScreen.SetActive(false);
                    keyboardScreen.SetActive(false);
                    controllerScreen.SetActive(false);
                    paused = false;
                }
            }
        }
    }
Exemplo n.º 5
0
 void Start()
 {
     player2 = GetComponentInParent <Player2Controls>();
 }
Exemplo n.º 6
0
 private void Start()
 {
     gc = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>();
     p2 = GameObject.Find("Player2CatFighter").GetComponent <Player2Controls>();
 }