Ejemplo n.º 1
0
 private List<Tile> GetSeaAttackableTiles(SeaCombatUnit seaUnit, Tile tile)
 {
     List<Tile> tiles = new List<Tile>();
     switch(seaUnit.EquipmentClassEnum)
     {
         case EquipmentClassEnum.Submarine:
             tiles = GetAdjacentTiles(tile, 1, true);
             tiles = tiles.Where(t => t.GroundUnit != null).ToList();
             tiles = tiles.Where(t => t.GroundUnit.SideEnum != seaUnit.SideEnum).ToList();
             tiles = tiles.Where(t => t.Terrain.TerrainGroupEnum != TerrainGroupEnum.Land).ToList();
             tiles = tiles.Where(t => t.GroundUnit.EquipmentClassEnum != EquipmentClassEnum.Submarine).ToList();
             break;
         case EquipmentClassEnum.Destroyer:
             tiles = GetAdjacentTiles(tile, 1, true);
             tiles = tiles.Where(t => t.GroundUnit != null).ToList();
             tiles = tiles.Where(t => t.GroundUnit.SideEnum != seaUnit.SideEnum).ToList();
             tiles = tiles.Where(t => t.Terrain.TerrainGroupEnum != TerrainGroupEnum.Land).ToList();
             break;
         case EquipmentClassEnum.CapitalShip:
             tiles = GetAdjacentTiles(tile, seaUnit.Equipment.Range, true);
             tiles = tiles.Where(t => t.GroundUnit != null).ToList();
             tiles = tiles.Where(t => t.GroundUnit.SideEnum != seaUnit.SideEnum).ToList();
             tiles = tiles.Where(t => t.GroundUnit.EquipmentClassEnum != EquipmentClassEnum.Submarine).ToList();
             break;
     }
     return tiles;
 }
 private void MoveSeaCombatUnit(SeaCombatUnit seaCombatUnit, Tile currentTile)
 {
     Tile targetTile = null;
     TargetAndJumpOffTile targetAndJumpOffTile = null;
     targetAndJumpOffTile = DetermineSeaAttackJumpOffTile(seaCombatUnit, currentTile);
     if (seaCombatUnit.CanAttack && targetAndJumpOffTile != null)
     {
         Game.BoardFactory.ActiveTile = currentTile;
         Game.BoardFactory.ActiveUnit = seaCombatUnit;
         Game.BoardFactory.MoveUnitForComputerPlayer(seaCombatUnit, currentTile, targetAndJumpOffTile.JumpOffTile);
         Game.BoardFactory.ActiveTile = targetAndJumpOffTile.JumpOffTile;
         if (seaCombatUnit.CanAttack)
         {
             Game.BoardFactory.CalculateBattleForComputerPlayer(targetAndJumpOffTile.TargetTile);
         }
         return;
     }
     targetTile = DetermineSeaWithdrawlTile(seaCombatUnit);
     if (targetTile != null)
     {
         Game.BoardFactory.ActiveTile = currentTile;
         Game.BoardFactory.ActiveUnit = seaCombatUnit;
         Game.BoardFactory.MoveUnitForComputerPlayer(seaCombatUnit, currentTile, targetTile);
         return;
     }
 }
        private TargetAndJumpOffTile DetermineSeaAttackJumpOffTile(SeaCombatUnit seaCombatUnit, Tile currentTile)
        {
            List<Tile> adjacentTiles = null;
            List<TargetAndJumpOffTile> targetAndJumpOffTiles = new List<TargetAndJumpOffTile>();
            TargetAndJumpOffTile targetAndJumpOffTile = null;

            foreach (Tile tile in seaCombatUnit.MoveableTiles)
            {
                Game.TileFactory.SetAttackableTiles(seaCombatUnit, tile);
                adjacentTiles = seaCombatUnit.AttackableTiles;
                adjacentTiles = adjacentTiles.Where(t => t.GroundUnit != null).ToList();
                adjacentTiles = adjacentTiles.Where(t => t.GroundUnit.SideEnum == SideEnum.Axis).ToList();
                foreach (Tile potentialTargetTile in adjacentTiles)
                {
                    targetAndJumpOffTile = new TargetAndJumpOffTile();
                    targetAndJumpOffTile.TargetTile = potentialTargetTile;
                    targetAndJumpOffTile.JumpOffTile = tile;
                    targetAndJumpOffTiles.Add(targetAndJumpOffTile);
                }
            }

            return DetermineTarget(targetAndJumpOffTiles, TargetTypeEnum.SoftGround);
        }
        private Tile DetermineSeaWithdrawlTile(SeaCombatUnit seaCombatUnit)
        {
            Tile targetTile = null;
            List<Tile> adjacentTiles = null;

            foreach (Tile tile in seaCombatUnit.MoveableTiles)
            {
                adjacentTiles = Game.TileFactory.GetAdjacentTiles(tile, 1, false);
                adjacentTiles = adjacentTiles.Where(t => t.VictoryIndicator).ToList();
                targetTile = adjacentTiles.Where(t => t.GroundUnit.SideEnum == SideEnum.Allies).FirstOrDefault();
                if (targetTile != null)
                {
                    return targetTile;
                }
            }
            return null;
        }
Ejemplo n.º 5
0
        public SeaCombatUnit CreateSeaCombatUnit(int unitId, ScenarioUnit scenarioUnit)
        {
            SeaCombatUnit unit = new SeaCombatUnit();
            unit.UnitId = unitId;
            unit.Equipment = EquipmentFactory.GetEquipment(scenarioUnit.EquipmentId);
            unit.UnitName = String.Format("{0} {1}", unitId, unit.Equipment.EquipmentDescription);
            unit.CoreIndicator = scenarioUnit.CordInd;
            unit.CurrentExperience = scenarioUnit.Experience;
            unit.CurrentStrength = scenarioUnit.Strength;
            unit.CurrentAttackPoints = scenarioUnit.Strength;
            unit.Nation = Game.NationFactory.GetNation(scenarioUnit.NationId);
            unit.CoreIndicator = scenarioUnit.CordInd;
            unit.CurrentAmmo = unit.Equipment.MaxAmmo;
            unit.CurrentFuel = unit.Equipment.MaxFuel;
            unit.CanMove = true;
            unit.CanAttack = true;
            unit.CurrentTileId = scenarioUnit.StartingScenarioTileId;

            return unit;
        }