Esempio n. 1
0
    private void StageShooting()
    {
        if (FootballPlayerCloseToPosition(movePointBall.position))
        {
            footballPlayer.animator.SetBool("canShoot", true);
            footballPlayer.animator.SetBool("shooting", false);

            // Ball kick delay
            m_Timer += Time.deltaTime;
            if (m_Timer >= 0.35f)
            {
                // Play kick sounds
                AudioManager.Instance.PlaySound(Sounds.kick);

                // Calculate ball direction
                var direction = (gateHitBox.GetRandomPosition(difficulty) - football.transform.position).normalized;

                // Kick ball
                var force = 7.5f + difficulty * FOOTBALL_FORCE_INCREMENT;
                football.rigidbody.AddForce(direction * force, ForceMode.Impulse);
                football.SetGravity(true);

                // Enable trail renderer
                football.trailRenderer.enabled = true;

                // Ready next stage
                m_Timer   = 0;
                m_Action += StageDefending;
                m_Action -= StageShooting;
            }
        }
        else
        {
            footballPlayer.agent.Move(Vector3.zero);
        }
    }