SimpleSoccer.Net.PlayerBase.FindSupport C# (CSharp) Method

FindSupport() public method

public FindSupport ( ) : void
return void
        public void FindSupport()
        {
            PlayerBase BestSupportPly;

            //if there is no support we need to find a suitable player.
            if (Team.SupportingPlayer == null)
            {
                BestSupportPly = Team.DetermineBestSupportingAttacker();

                Team.SupportingPlayer = BestSupportPly;

                MessageDispatcher.Instance.DispatchMsg(new TimeSpan(0),
                                        ObjectId,
                                        Team.SupportingPlayer.ObjectId,
                                        (int)SoccerGameMessages.SupportAttacker,
                                        null);
            }

            BestSupportPly = Team.DetermineBestSupportingAttacker();

            //if the best player available to support the attacker changes, update
            //the pointers and send messages to the relevant players to update their
            //states
            if (BestSupportPly != null && (BestSupportPly != Team.SupportingPlayer))
            {

                if (Team.SupportingPlayer != null)
                {
                    MessageDispatcher.Instance.DispatchMsg(new TimeSpan(0),
                                            ObjectId,
                                            Team.SupportingPlayer.ObjectId,
                                            (int)SoccerGameMessages.GoHome,
                                            null);
                }



                Team.SupportingPlayer = BestSupportPly;

                MessageDispatcher.Instance.DispatchMsg(new TimeSpan(0),
                                        ObjectId,
                                        Team.SupportingPlayer.ObjectId,
                                        (int)SoccerGameMessages.SupportAttacker,
                                        null);
            }
        }
        #endregion