public SupportSpotCalculator(int numX, int numY, SoccerTeam team)
        {
            Region PlayingField = team.Pitch.PlayingArea;

            //calculate the positions of each sweet spot, create them and
            //store them in m_Spots
            double HeightOfSSRegion = PlayingField.Height * 0.8;
            double WidthOfSSRegion  = PlayingField.Width * 0.9;
            double SliceX           = WidthOfSSRegion / numX;
            double SliceY           = HeightOfSSRegion / numY;

            double left  = PlayingField.Left + (PlayingField.Width - WidthOfSSRegion) / 2.0 + SliceX / 2.0;
            double right = PlayingField.Right - (PlayingField.Width - WidthOfSSRegion) / 2.0 - SliceX / 2.0;
            double top   = PlayingField.Top + (PlayingField.Height - HeightOfSSRegion) / 2.0 + SliceY / 2.0;

            _team = team;
            for (int x = 0; x < (numX / 2) - 1; ++x)
            {
                for (int y = 0; y < numY; ++y)
                {
                    if (_team.Color == SoccerTeam.SoccerTeamColor.Blue)
                    {
                        _supportSpots.Add(new SupportSpot(new Vector2D(left + x * SliceX, top + y * SliceY), 0.0));
                    }

                    else
                    {
                        _supportSpots.Add(new SupportSpot(new Vector2D(right - x * SliceX, top + y * SliceY), 0.0));
                    }
                }
            }

            //create the regulator
            _regulator = new Regulator(ParameterManager.Instance.SupportSpotUpdateFreq);
        }
        public FieldPlayer(SoccerTeam homeTeam,
                      int homeRegionIndex,
                      State<FieldPlayer> startState,
                      Vector2D heading,
                      Vector2D velocity,
                      double mass,
                      double maxForce,
                      double maxSpeed,
                      double maxTurnRate,
                      double scale,
                      PlayerBase.PlayerRoles role)
            : base(homeTeam, homeRegionIndex, heading, velocity, mass, maxForce, maxSpeed, maxTurnRate, scale, role)
        {
            _stateMachine = new StateMachine<FieldPlayer>(this);

            if (startState != null)
            {
                _stateMachine.CurrentState = _stateMachine.PreviousState = startState;
                _stateMachine.GlobalState = GlobalPlayerState.Instance;
                _stateMachine.CurrentState.Enter(this);
            }

            _steeringBehaviors.Seperation = true;

            //set up the kick regulator
            _kickRegulator = new Regulator(ParameterManager.Instance.PlayerKickFrequency);
        }
Example #3
0
        public FieldPlayer(SoccerTeam homeTeam,
                           int homeRegionIndex,
                           State <FieldPlayer> startState,
                           Vector2D heading,
                           Vector2D velocity,
                           double mass,
                           double maxForce,
                           double maxSpeed,
                           double maxTurnRate,
                           double scale,
                           PlayerBase.PlayerRoles role)
            : base(homeTeam, homeRegionIndex, heading, velocity, mass, maxForce, maxSpeed, maxTurnRate, scale, role)
        {
            _stateMachine = new StateMachine <FieldPlayer>(this);

            if (startState != null)
            {
                _stateMachine.CurrentState = _stateMachine.PreviousState = startState;
                _stateMachine.GlobalState  = GlobalPlayerState.Instance;
                _stateMachine.CurrentState.Enter(this);
            }

            _steeringBehaviors.Seperation = true;

            //set up the kick regulator
            _kickRegulator = new Regulator(ParameterManager.Instance.PlayerKickFrequency);
        }
        public SupportSpotCalculator(int numX, int numY, SoccerTeam team)
        {
            Region PlayingField = team.Pitch.PlayingArea;

            //calculate the positions of each sweet spot, create them and 
            //store them in m_Spots
            double HeightOfSSRegion = PlayingField.Height * 0.8;
            double WidthOfSSRegion = PlayingField.Width * 0.9;
            double SliceX = WidthOfSSRegion / numX;
            double SliceY = HeightOfSSRegion / numY;

            double left = PlayingField.Left + (PlayingField.Width - WidthOfSSRegion) / 2.0 + SliceX / 2.0;
            double right = PlayingField.Right - (PlayingField.Width - WidthOfSSRegion) / 2.0 - SliceX / 2.0;
            double top = PlayingField.Top + (PlayingField.Height - HeightOfSSRegion) / 2.0 + SliceY / 2.0;

            _team = team;
            for (int x = 0; x < (numX / 2) - 1; ++x)
            {
                for (int y = 0; y < numY; ++y)
                {
                    if (_team.Color == SoccerTeam.SoccerTeamColor.Blue)
                    {
                        _supportSpots.Add(new SupportSpot(new Vector2D(left + x * SliceX, top + y * SliceY), 0.0));
                    }

                    else
                    {
                        _supportSpots.Add(new SupportSpot(new Vector2D(right - x * SliceX, top + y * SliceY), 0.0));
                    }
                }
            }

            //create the regulator
            _regulator = new Regulator(ParameterManager.Instance.SupportSpotUpdateFreq);

        }