Inheritance: PlayerBase
Exemple #1
0
 /// <summary>
 /// Finds targets for waiting players
 /// </summary>
 public void UpdateTargetsOfWaitingPlayers()
 {
     foreach (PlayerBase player in _players)
     {
         if (player.PlayerRole != PlayerBase.PlayerRoles.GoalKeeper)
         {
             FieldPlayer fieldPlayer = player as FieldPlayer;
             if (fieldPlayer.StateMachine.IsInState(WaitState.Instance) ||
                 fieldPlayer.StateMachine.IsInState(ReturnToHomeRegionState.Instance))
             {
                 fieldPlayer.SteeringBehaviors.Target = fieldPlayer.HomeRegion.VectorCenter;
             }
         }
     }
 }
Exemple #2
0
        /// <summary>
        ///  This tests to see if a pass is possible between the requester and
        ///  the controlling player. If it is possible a message is sent to the
        ///  controlling player to pass the ball asap.
        ///
        /// </summary>
        /// <param name="requester"></param>
        public void RequestPass(FieldPlayer requester)
        {
            //maybe put a restriction here
            if (rng.NextDouble() > 0.1)
            {
                return;
            }

            if (IsPassSafeFromAllOpponents(ControllingPlayer.Position,
                                           requester.Position,
                                           requester,
                                           ParameterManager.Instance.MaxPassingForce))
            {
                //tell the player to make the pass
                //let the receiver know a pass is coming
                MessageDispatcher.Instance.DispatchMsg(new TimeSpan(0),
                                                       requester.ObjectId,
                                                       ControllingPlayer.ObjectId,
                                                       (int)SoccerGameMessages.PassToMe,
                                                       requester);
            }
        }
        /// <summary>
        ///  This tests to see if a pass is possible between the requester and
        ///  the controlling player. If it is possible a message is sent to the
        ///  controlling player to pass the ball asap.
        /// 
        /// </summary>
        /// <param name="requester"></param>
        public void RequestPass(FieldPlayer requester)
        {
            //maybe put a restriction here
            if (rng.NextDouble() > 0.1) return;

            if (IsPassSafeFromAllOpponents(ControllingPlayer.Position,
                                           requester.Position,
                                           requester,
                                           ParameterManager.Instance.MaxPassingForce))
            {

                //tell the player to make the pass
                //let the receiver know a pass is coming 
                MessageDispatcher.Instance.DispatchMsg(new TimeSpan(0),
                                      requester.ObjectId,
                                      ControllingPlayer.ObjectId,
                                      (int)SoccerGameMessages.PassToMe,
                                      requester);

            }
        }