Ejemplo n.º 1
0
 public override void Execute()
 {
     //give receiving player possession of the ball.
     ballGame.playerInPossession = player;
     config.activeGoalDirectionIndicator.source = player.transform;
     config.activeGoalDirectionIndicator.target = player.team.goal.transform;
     //if this player's team is not being controlled by a user
     if (player.IsAI)
     {
         Vector3 target = player.team.goal.transform.position;
         //if goal is more than 20 units away, pass to closer player.
         if ((target - player.transform.position).magnitude > 20)
         {
             var other = ballGame.GetClosestPlayer(player.team.players, Vector3.Lerp(target, player.transform.position, 0.5f));
             if (other != player)
             {
                 var nv = Simulation.Schedule <PrepareToPassBall>(Fuzzy.Value(0.5f));
                 nv.target   = other.transform.position;
                 nv.player   = player;
                 nv.receiver = other;
             }
         }
         else
         {
             var nv = Simulation.Schedule <PrepareToLaunchBall>(0);
             nv.target = target;
             nv.player = player;
         }
     }
 }
Ejemplo n.º 2
0
        public override void Execute()
        {
            var A = ballGame.GetClosestPlayer(ballGame.awayTeam.players, targetPosition);
            var B = ballGame.GetClosestPlayer(ballGame.homeTeam.players, targetPosition);

            A.OnBallWillLandNearMe(targetPosition);
            B.OnBallWillLandNearMe(targetPosition);

            //all players look at the player that launched the ball,
            //except for the player that launched the ball, who looks
            //at the target position.
            playerThatLaunchedBall.OnLaunchBall(targetPosition);
            foreach (var p in ballGame.players)
            {
                if (p != playerThatLaunchedBall)
                {
                    p.OnOtherPlayerLaunchedBall(playerThatLaunchedBall, targetPosition);
                }
            }
        }
Ejemplo n.º 3
0
        public override void Execute()
        {
            ballGame.ball.impactAudio.Play(collision, config.ballBounceAudio);
            if (config.ballBounceParticles)
            {
                var particles = ComponentPool <ParticleSystem> .Take(config.ballBounceParticles);

                particles.transform.position = ballGame.ball.transform.position;
                particles.Play();
                ComponentPool <ParticleSystem> .Return(particles, 1);
            }

            //if the ballgame is not in possession, notifiy closer players towards the ball.
            if (!ballGame.ball.IsPossessed)
            {
                var position = ballGame.ball.transform.position;
                var A        = ballGame.GetClosestPlayer(ballGame.awayTeam.players, position);
                var B        = ballGame.GetClosestPlayer(ballGame.homeTeam.players, position);
                A.OnBallBounceNearMe(position);
                B.OnBallBounceNearMe(position);
            }
        }