Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        /*
         * print(anim.GetBool("Running"));
         * if (anim.GetBool("Running"))
         * {
         *  if (PLAYER_NUMBER == 1)
         *  {
         *      PM.StartRunParticlesP1();
         *
         *  }
         *  else PM.StartRunParticlesP2();
         *
         * }
         * else
         * {
         *  PM.EndRunParticlesP1();
         *
         * }
         */
        if (PLAYER_NUMBER == 1)
        {
            if (anim.GetBool("Running"))
            {
                PM.StartRunParticlesP1();
            }
            else
            {
                PM.EndRunParticlesP1();
            }
        }
        else
        {
            if (anim.GetBool("Running"))
            {
                PM.StartRunParticlesP2();
            }
            else
            {
                PM.EndRunParticlesP2();
            }
        }

        if (Input.GetButtonDown(FireCtrl) && !defeated)
        {
            anim.SetTrigger("BaseballHit");
            //isHitting = true;
            //AM.Play("PlayerHits");
            //AM.PlayRandomPitch("PlayerHits");
            GameObject.FindObjectOfType <AudioManager>().PlayRandomPitch("PlayerHits");
        }

        if (ballSript.playerNear && isHitting)
        {
            GM.ShakeCameraPlayerHits();
            GameObject.FindObjectOfType <AudioManager>().PlayRandomPitch("HitBall");
            PM.PlayerHitsBall(ball.transform);

            ballSript.ChangeMaterial(this.gameObject.name);
            //ball.transform.rotation = transform.rotation;
            ballSript.changeDirection(transform.rotation);
            ballSript.ballStopped = false;
            ballSript.hitted      = true;

            if (PLAYER_NUMBER == 1)
            {
                if (ballSript.CheckIfCrossField())
                {
                    GameObject.FindObjectOfType <GroundEffectManagerScript>().StartLeftEffect(transform);
                }
            }
            else
            {
                if (ballSript.CheckIfCrossField())
                {
                    GameObject.FindObjectOfType <GroundEffectManagerScript>().StartRightEffect(transform);
                }
            }

            if (GamMan.state == GamMan.stateOfMatch.running)
            {
                ballSript.IncreaseSpeed();
            }
            isHitting = false;
        }
    }