Пример #1
0
        public bool KickOrTurn(GoalKeeper player, Position target, double speed = 100.0)
        {
            var    playerNumber         = player.playerNumber;
            var    playerPosition       = player.position;
            double playerDirection      = player.direction;
            double destinationDirection = Math.Round(playerPosition.getAngle(target), 3);

            if (playerDirection == destinationDirection)
            {
                this.playerNumber = player.playerNumber;
                this.action       = Action.Kick;
                this.destination  = target;
                this.speed        = speed;
                Logger.log("Player " + playerNumber + " Kicks to " + destination, Logger.LogLevel.INFO);
                return(true);
            }
            else
            {
                this.playerNumber = player.playerNumber;;
                this.action       = Action.Turn;
                this.direction    = destinationDirection;
                Logger.log("Player " + playerNumber + " Turns by " + direction, Logger.LogLevel.INFO);
                return(true);
            }
        }
Пример #2
0
        public override bool Enter(Team team)
        {
            Logger.log("Team " + team.teamNumber + " enters KickOff state", Logger.LogLevel.INFO);

            team.SetControllingPlayer(null);
            team.receivingPlayer     = null;
            team.supportingPlayer    = null;
            team.playerClosestToBall = null;


            //these define the home regions for this state of each of the players
            int[] RightRegions = new int[6] {
                16, 20, 13, 7, 9, 3
            };
            int[] LeftRegions = new int[6] {
                35, 31, 38, 44, 42, 48
            };

            //set up the player's home regions
            if (team.playingDirection == Team.DirectionType.LEFT)
            {
                team.ChangePlayerHomeRegions(team, LeftRegions);
            }
            else
            {
                team.ChangePlayerHomeRegions(team, RightRegions);
            }

            foreach (Player player in team.Members.Values)
            {
                if (player.playerType == "P")
                {
                    FieldPlayer fieldPlayer = player as FieldPlayer;
                    if (!fieldPlayer.stateMachine.IsInState(DeadState.instance))
                    {
                        fieldPlayer.stateMachine.ChangeState(WaitState.instance);
                    }
                }
                else
                {
                    GoalKeeper keeper = player as GoalKeeper;
                    keeper.stateMachine.ChangeState(KeeperWaitState.instance);
                }
            }
            //just not to call execute method in changestate method
            return(false);
        }