Example #1
0
        Logic.UnitAction IPlayerAI.SelectAction(Logic.API.Info.UnitInfo unitInfo)
        {
            Array values = Enum.GetValues(typeof(Direction));
            Direction direction = (Direction)values.GetValue(Random.Next(Enum.GetValues(typeof(Direction)).Length));
            UnitAction action = null;
            double choice = Random.NextDouble() * 100;

            if (choice < 30) action = new ShootAction() { Direction = direction };
            else if (choice < 60) action = new ScanAction() { Direction = direction };
            else action = new MoveAction() { Direction = direction };

            return action;
        }
Example #2
0
        public void Shoot(Unit unit, ShootAction action)
        {
            Shot shot = new Shot();
            shot.Direction = action.Direction;
            shot.X = Tools.GetX(unit.X, action.Direction);
            shot.Y = Tools.GetY(unit.Y, action.Direction);

            Tile tile = Data.Map.Tiles[shot.Y][shot.X];
            if (tile.IsWall) return;

            shot.Tile = tile;
            tile.Shot = shot;
            ShotList.Add(shot);
        }