Exemplo n.º 1
0
 void Start()
 {
     boxer1Position           = FindObjectOfType <Boxer1Movement>();
     boxer2Position           = FindObjectOfType <Boxer2Movement>();
     boxer1HealthIncrease     = FindObjectOfType <Boxer1Health> ();
     boxer2HealthIncrease     = FindObjectOfType <Boxer2Health> ();
     boxer1MaxStaminaDecrease = FindObjectOfType <Boxer1Stamina> ();
     boxer2MaxStaminaDecrease = FindObjectOfType <Boxer2Stamina> ();
 }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        KnockedDown       = FindObjectOfType <Boxer2Health>();
        down              = KnockedDown.down;
        boxer1KnockedDown = FindObjectOfType <Boxer1Health>();
        boxer1Down        = boxer1KnockedDown.down;

        if (down == false && boxer1Down == false)
        {
            Vector3 direction = Vector3.zero;
            direction.z = Input.GetAxisRaw("Controller2Horizontal");
            direction.x = Input.GetAxisRaw("Controller2Vertical");

            transform.LookAt(lockOnBoxer);

            float xMovement = (Input.GetAxis("Controller2Horizontal") * playerSpeed) * Time.deltaTime;
            float zMovement = (Input.GetAxis("Controller2Vertical") * playerSpeed) * Time.deltaTime;

            Vector3 playerMovement = new Vector3(xMovement, 0.0f, zMovement);
            transform.Translate(playerMovement * playerSpeed);


            if (direction.x > 0)
            {
                anim.SetBool("MoveForward", true);
            }
            else
            {
                anim.SetBool("MoveForward", false);
            }
            if (direction.x < 0)
            {
                anim.SetBool("MoveBackward", true);
            }
            else
            {
                anim.SetBool("MoveBackward", false);
            }
            if (direction.z > 0)
            {
                anim.SetBool("MoveLeft", true);
            }
            else
            {
                anim.SetBool("MoveLeft", false);
            }
            if (direction.z < 0)
            {
                anim.SetBool("MoveRight", true);
            }
            else
            {
                anim.SetBool("MoveRight", false);
            }
        }
    }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        stamina           = FindObjectOfType <Boxer2Stamina> ();
        currentStamina    = stamina.currentStamina;
        boxer1KnockedDown = FindObjectOfType <Boxer1Health> ();
        boxer1Down        = boxer1KnockedDown.down;
        boxer2KnockedDown = FindObjectOfType <Boxer2Health> ();
        boxer2Down        = boxer2KnockedDown.down;
        boxer1Attacks     = FindObjectOfType <Boxer1Attacks> ();
        attackType        = boxer1Attacks.attack;
        pointIncrease     = FindObjectOfType <PointCounter> ();

        if (boxer1Down == false && boxer2Down == false && PauseMenu.gamePaused == false)
        {
            if (Input.GetButtonDown("Controller2LeftStick") && currentStamina >= 20f)
            {
                anim.SetBool("BackDodge", true);
                stamina.dodgeStamina();
                if (attackType != 0)
                {
                    pointIncrease.boxer2DefencePoints();
                }
            }
            else
            {
                anim.SetBool("BackDodge", false);
            }

            if (Input.GetButtonDown("Controller2RightStick") && currentStamina >= 5f)
            {
                anim.SetBool("CentreBlock", true);
                stamina.blockStamina();
                if (attackType != 0)
                {
                    pointIncrease.boxer2DefencePoints();
                }
            }
            else
            {
                anim.SetBool("CentreBlock", false);
            }
        }
    }
Exemplo n.º 4
0
 // Update is called once per frame
 void Update()
 {
     boxer1Position    = FindObjectOfType <Boxer1Movement>();
     boxer2Position    = FindObjectOfType <Boxer2Movement>();
     boxer1KnockedDown = FindObjectOfType <Boxer1Health> ();
     boxer1Down        = boxer1KnockedDown.down;
     boxer2KnockedDown = FindObjectOfType <Boxer2Health> ();
     boxer2Down        = boxer2KnockedDown.down;
     rounds            = FindObjectOfType <Rounds> ();
     gameOver          = rounds.gameOver;
     if (boxer1Down == true)
     {
         if (boxer1RoundKDs >= 2)
         {
             player2Wins.enabled = true;
             if (Input.GetButtonDown("Controller1AButton") || Input.GetButtonDown("Controller2AButton"))
             {
                 SceneManager.LoadScene(0);
             }
         }
         boxer2Position.resetPosition();
         aButton.enabled         = true;
         aButtonProgress.enabled = true;
         KDCText.enabled         = true;
         if (Input.GetButtonDown("Controller1AButton") && cTime < 10)
         {
             if (boxer1TotalKDs >= 1)
             {
                 progressAmount = progressAmount + (0.1f / (boxer1TotalKDs + 1));
             }
             else
             {
                 progressAmount = progressAmount + 0.1f;
             }
         }
         if (progressAmount >= 1)
         {
             boxer1KnockedDown.boxer1Up();
             aButton.enabled         = false;
             aButtonProgress.enabled = false;
             progressAmount          = 0;
             cTime           = sTime;
             KDCText.enabled = false;
             boxer1TotalKDs++;
             boxer1RoundKDs++;
             score.boxer1KnockedDown();
         }
         ProgressBar.GetComponent <Image> ().fillAmount = progressAmount;
         cTime       += 1 * Time.deltaTime;
         KDCText.text = cTime.ToString("0");
         if (cTime >= 10)
         {
             player2Wins.enabled = true;
             if (Input.GetButtonDown("Controller1AButton") || Input.GetButtonDown("Controller2AButton"))
             {
                 SceneManager.LoadScene(0);
             }
         }
     }
     else if (boxer2Down == true)
     {
         if (boxer2RoundKDs >= 2)
         {
             player1Wins.enabled = true;
             if (Input.GetButtonDown("Controller1AButton") || Input.GetButtonDown("Controller2AButton"))
             {
                 SceneManager.LoadScene(0);
             }
         }
         boxer1Position.resetPosition();
         aButton.enabled         = true;
         aButtonProgress.enabled = true;
         KDCText.enabled         = true;
         if (Input.GetButtonDown("Controller2AButton") && cTime < 10)
         {
             if (boxer2TotalKDs >= 1)
             {
                 progressAmount = progressAmount + (0.1f / (boxer2TotalKDs + 1));
             }
             else
             {
                 progressAmount = progressAmount + 0.1f;
             }
         }
         if (progressAmount >= 1)
         {
             boxer2KnockedDown.boxer2Up();
             aButton.enabled         = false;
             aButtonProgress.enabled = false;
             progressAmount          = 0;
             cTime           = sTime;
             KDCText.enabled = false;
             boxer2TotalKDs++;
             boxer2RoundKDs++;
             score.boxer2KnockedDown();
         }
         ProgressBar.GetComponent <Image> ().fillAmount = progressAmount;
         cTime       += 1 * Time.deltaTime;
         KDCText.text = cTime.ToString("0");
         if (cTime >= 10)
         {
             player1Wins.enabled = true;
             if (Input.GetButtonDown("Controller1AButton") || Input.GetButtonDown("Controller2AButton"))
             {
                 SceneManager.LoadScene(0);
             }
         }
     }
     else if (gameOver == true)
     {
         if (Input.GetButtonDown("Controller1AButton") || Input.GetButtonDown("Controller2AButton"))
         {
             SceneManager.LoadScene(0);
         }
     }
 }
Exemplo n.º 5
0
    // Update is called once per frame
    void Update()
    {
        stamina           = FindObjectOfType <Boxer1Stamina> ();
        currentStamina    = stamina.currentStamina;
        boxer1KnockedDown = FindObjectOfType <Boxer1Health> ();
        boxer1Down        = boxer1KnockedDown.down;
        boxer2KnockedDown = FindObjectOfType <Boxer2Health> ();
        boxer2Down        = boxer2KnockedDown.down;

        if (boxer1Down == false && boxer2Down == false && PauseMenu.gamePaused == false)
        {
            if (Input.GetButtonDown("Controller1AButton") && currentStamina >= 10f)
            {
                anim.SetBool("Jab", true);
                attack            = 1;
                currentDelayTimer = delayTimer;
                stamina.jabStamina();
            }
            else
            {
                anim.SetBool("Jab", false);
                if (currentDelayTimer > 0)
                {
                    currentDelayTimer -= Time.deltaTime;
                    if (currentDelayTimer <= 0)
                    {
                        currentDelayTimer = 0;
                        if (currentDelayTimer == 0)
                        {
                            attack = 0;
                        }
                    }
                }
            }

            if (Input.GetButtonDown("Controller1XButton") && currentStamina >= 12f)
            {
                anim.SetBool("Cross", true);
                attack            = 2;
                currentDelayTimer = delayTimer;
                stamina.crossStamina();
            }
            else
            {
                anim.SetBool("Cross", false);
                if (currentDelayTimer > 0)
                {
                    currentDelayTimer -= Time.deltaTime;
                    if (currentDelayTimer <= 0)
                    {
                        currentDelayTimer = 0;
                        if (currentDelayTimer == 0)
                        {
                            attack = 0;
                        }
                    }
                }
            }

            if (Input.GetButtonDown("Controller1BButton") && currentStamina >= 8f)
            {
                anim.SetBool("BodyJab", true);
                attack            = 5;
                currentDelayTimer = delayTimer;
                stamina.bodyJabStamina();
            }
            else
            {
                anim.SetBool("BodyJab", false);
                if (currentDelayTimer > 0)
                {
                    currentDelayTimer -= Time.deltaTime;
                    if (currentDelayTimer <= 0)
                    {
                        currentDelayTimer = 0;
                        if (currentDelayTimer == 0)
                        {
                            attack = 0;
                        }
                    }
                }
            }

            if (Input.GetButtonDown("Controller1YButton") && currentStamina >= 10f)
            {
                anim.SetBool("BodyCross", true);
                attack            = 6;
                currentDelayTimer = delayTimer;
                stamina.bodyCrossStamina();
            }
            else
            {
                anim.SetBool("BodyCross", false);
                if (currentDelayTimer > 0)
                {
                    currentDelayTimer -= Time.deltaTime;
                    if (currentDelayTimer <= 0)
                    {
                        currentDelayTimer = 0;
                        if (currentDelayTimer == 0)
                        {
                            attack = 0;
                        }
                    }
                }
            }

            /*if (Mathf.Round (Input.GetAxisRaw ("Controller1Triggers")) > 0) {
             * anim.SetBool ("LeftHook", true);
             * attack = 3;
             * stamina.hookStamina();
             * } else if (Mathf.Round (Input.GetAxisRaw ("Controller1Triggers")) < 0) {
             * anim.SetBool ("RightUppercut", true);
             * attack = 4;
             * } else {
             * anim.SetBool ("LeftHook", false);
             * anim.SetBool ("RightUppercut", false);
             * if (currentDelayTimer > 0)
             * {
             *      currentDelayTimer -= Time.deltaTime;
             *      if (currentDelayTimer <= 0)
             *      {
             *              currentDelayTimer = 0;
             *              if(currentDelayTimer == 0)
             *              {
             *                      attack = 0;
             *                      currentDelayTimer = delayTimer;
             *              }
             *      }
             * }
             * }*/

            if (Input.GetButtonDown("Controller1LeftBumper") && currentStamina >= 15f)
            {
                anim.SetBool("LeftHook", true);
                attack            = 3;
                currentDelayTimer = delayTimer;
                stamina.hookStamina();
            }
            else
            {
                anim.SetBool("LeftHook", false);
                if (currentDelayTimer > 0)
                {
                    currentDelayTimer -= Time.deltaTime;
                    if (currentDelayTimer <= 0)
                    {
                        currentDelayTimer = 0;
                        if (currentDelayTimer == 0)
                        {
                            attack = 0;
                        }
                    }
                }
            }

            if (Input.GetButtonDown("Controller1RightBumper") && currentStamina >= 18f)
            {
                anim.SetBool("RightUppercut", true);
                attack            = 4;
                currentDelayTimer = delayTimer;
                stamina.uppercutStamina();
            }
            else
            {
                anim.SetBool("RightUppercut", false);
                if (currentDelayTimer > 0)
                {
                    currentDelayTimer -= Time.deltaTime;
                    if (currentDelayTimer <= 0)
                    {
                        currentDelayTimer = 0;
                        if (currentDelayTimer == 0)
                        {
                            attack = 0;
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 6
0
 // Use this for initialization
 void Start()
 {
     damage = FindObjectOfType <Boxer1Health>();
 }