Esempio n. 1
0
        /// <summary>
        /// Analyzes the situation and provides the footballer with a new action.
        /// </summary>

        /*
         * private void AcquireNewAction()
         * {
         *  // if player doesn't control ball, set to anticipate
         *  if (!_owner.BallInControlRange())
         *  {
         *      _currentAction = new ActionAnticipate(_owner);
         *      return;
         *  }
         *
         *  // pick a pass with high prob, dribble with some prob, shot with low prob
         *  RandomStuff randomator = _owner.InhabitedMap.Randomator;
         *  UInt32 decider = randomator.NSidedDice(20, 1);
         *
         *  if (decider < 10)
         *  {
         *      // pass
         *      Footballer target = this.LookForPass();
         *      _currentAction = new ActionPassToSpot(_owner, target.PositionDouble, (PassType)(decider % 2));
         *      return;
         *  }
         *  else if (decider < 15)
         *  {
         *      // dribble
         *      Vector2d delta = _owner.FacingDirection;
         *      delta.Rotate((Math.PI / 6) * decider);
         *      delta.ScaleToLength(250);
         *
         *      _currentAction = new ActionDribbleTo(_owner, _owner.PositionDouble + delta);
         *      return;
         *  }
         *  else
         *  {
         *      // take a shot
         *      _currentAction = new ActionTakeAShot(_owner);
         *      return;
         *  }
         * }
         */

        /// <summary>
        /// Sets up a kick off situation.
        /// </summary>
        private void AcquireNewActionKickOff()
        {
            List <Footballer> roster = _owner.Team.TeamRoster;

            if ((_owner.UniqueID - roster[0].UniqueID) < roster.Count - 2 || _owner.MyMatch.TeamInPossession != _owner.Team)
            {
                // if team isn't in possession, or is not one of the last 2 field players, go to default position.
                if (!_owner.IsNear(_owner.DefaultPositionInHalf()))
                {
                    SetAction(new ActionGoto(_owner, _owner.DefaultPositionInHalf()));
                    return;
                }
                else
                {
                    SetAction(new ActionWait(_owner, 10));
                    return;
                }
            }

            else
            {
                // have two guys take kick off
                if (!_owner.IsNear(Constants.CenterPoint))
                {
                    SetAction(new ActionGoto(_owner, Constants.CenterPoint));
                    return;
                }
                else
                {
                    // check to see if everything is ready to go.
                    if (_owner.Team.ReadyToTakeKickOff() && _owner.EnemyTeam.ReadyForOtherTeamToTakeKickOff())
                    {
                        // kick off
                        SetAction(new ActionPassToSpot(_owner, roster.Last().PositionDouble, PassType.Short));
                        _owner.Team.HasTakenSetPiece = true;
                        return;
                    }
                }
            }
            if (_currentAction == null)
            {
                SetAction(new ActionWait(_owner, 10));
            }
        }
Esempio n. 2
0
        public bool ReadyForOtherTeamToTakeKickOff()
        {
            for (int i = 0; i < _teamRoster.Count; ++i)
            {
                Footballer current = _teamRoster[i];
                if (!current.IsNear(current.DefaultPositionInHalf()))
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 3
0
        public bool ReadyToTakeKickOff()
        {
            for (int i = 0; i < _teamRoster.Count - 2; ++i)
            {
                Footballer current = _teamRoster[i];
                if (!current.IsNear(current.DefaultPositionInHalf()))
                {
                    return(false);
                }
            }

            for (int i = _teamRoster.Count - 2; i < _teamRoster.Count; ++i)
            {
                Footballer current = _teamRoster[i];
                if (!current.IsNear(Constants.CenterPoint))
                {
                    return(false);
                }
            }

            return(true);
        }