Exemplo n.º 1
0
        public AirCombatUnit CreateAirCombatUnit(int unitId, ScenarioUnit scenarioUnit)
        {
            AirCombatUnit unit = new AirCombatUnit();
            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;
        }
Exemplo n.º 2
0
        private List<Tile> GetAirAttackableTiles(AirCombatUnit airUnit, Tile tile)
        {
            List<Tile> tiles = new List<Tile>();

            switch(airUnit.EquipmentClassEnum)
            {
                case EquipmentClassEnum.Fighter:
                    //Air Target
                    tiles = GetAdjacentTiles(tile, 1, true);
                    tiles = tiles.Where(t => t.AirUnit != null).ToList();
                    tiles = tiles.Where(t => t.AirUnit.SideEnum != airUnit.SideEnum).ToList();
                    //Ground Target
                    if (tile.GroundUnit != null)
                    {
                        if (tile.GroundUnit.SideEnum != airUnit.SideEnum)
                        {
                            tiles.Add(tile);
                        }
                    }
                    break;
                case EquipmentClassEnum.TacticalBomber:
                    //Air Target
                    tiles = GetAdjacentTiles(tile, 1, true);
                    tiles = tiles.Where(t => t.AirUnit != null).ToList();
                    tiles = tiles.Where(t => t.AirUnit.SideEnum != airUnit.SideEnum).ToList();
                    //Ground Target
                    if (tile.GroundUnit != null)
                    {
                        if (tile.GroundUnit.SideEnum != airUnit.SideEnum)
                        {
                            tiles.Add(tile);
                        }
                    }
                    break;
                case EquipmentClassEnum.StrategicBomber:
                    //Ground Target
                    if (tile.GroundUnit != null)
                    {
                        if (tile.GroundUnit.SideEnum != airUnit.SideEnum)
                        {
                            tiles.Add(tile);
                        }
                    }
                    //Victory Tile Target
                    if (tile.VictoryIndicator == true)
                    {
                        if (tile.Nation.SideEnum != airUnit.Nation.SideEnum)
                        {
                            tiles.Add(tile);
                        }
                    }
                    break;
            }
            return tiles;
        }
        private static TargetAndJumpOffTile DetermineAirAttackJumpOffTile(AirCombatUnit airCombatUnit, Tile currentTile)
        {
            List<Tile> adjacentTiles = null;
            List<TargetAndJumpOffTile> targetAndJumpOffTiles = new List<TargetAndJumpOffTile>();
            TargetAndJumpOffTile targetAndJumpOffTile = null;

            if (airCombatUnit.EquipmentClassEnum == EquipmentClassEnum.Fighter)
            {
                foreach (Tile tile in airCombatUnit.MoveableTiles)
                {
                    adjacentTiles = Game.TileFactory.GetAdjacentTiles(tile, 1, false);
                    adjacentTiles = adjacentTiles.Where(t => t.AirUnit != null).ToList();
                    adjacentTiles = adjacentTiles.Where(t => t.AirUnit.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.Air);
            }
            else if(airCombatUnit.EquipmentClassEnum == EquipmentClassEnum.TacticalBomber)
            {
                foreach (Tile tile in airCombatUnit.MoveableTiles)
                {
                    if (tile.GroundUnit != null)
                    {
                        if (tile.GroundUnit.SideEnum == SideEnum.Axis)
                        {
                            targetAndJumpOffTile = new TargetAndJumpOffTile();
                            targetAndJumpOffTile.TargetTile = tile;
                            targetAndJumpOffTile.JumpOffTile = tile;
                            targetAndJumpOffTiles.Add(targetAndJumpOffTile);
                        }
                    }
                }

            }
            else if (airCombatUnit.EquipmentClassEnum == EquipmentClassEnum.StrategicBomber)
            {
                foreach (Tile tile in airCombatUnit.MoveableTiles)
                {
                    if (tile.Nation.SideEnum == SideEnum.Axis && tile.VictoryIndicator == true)
                    {
                        targetAndJumpOffTile = new TargetAndJumpOffTile();
                        targetAndJumpOffTile.TargetTile = tile;
                        targetAndJumpOffTile.JumpOffTile = tile;
                        targetAndJumpOffTiles.Add(targetAndJumpOffTile);
                    }
                }
            }

            return null;
        }
 private static void MoveAirCombatUnit(AirCombatUnit airCombatUnit, Tile currentTile)
 {
     Tile targetTile = null;
     TargetAndJumpOffTile targetAndJumpOffTile = null;
     targetAndJumpOffTile = DetermineAirAttackJumpOffTile(airCombatUnit, currentTile);
     if (airCombatUnit.CanAttack && targetAndJumpOffTile != null && airCombatUnit.CurrentFuel >= airCombatUnit.Equipment.MaxFuel*.5)
     {
         Game.BoardFactory.ActiveTile = currentTile;
         Game.BoardFactory.ActiveUnit = airCombatUnit;
         Game.BoardFactory.MoveUnitForComputerPlayer(airCombatUnit, currentTile, targetAndJumpOffTile.JumpOffTile);
         Game.BoardFactory.ActiveTile = targetAndJumpOffTile.JumpOffTile;
         Game.BoardFactory.CalculateBattleForComputerPlayer(targetAndJumpOffTile.TargetTile);
         return;
     }
     targetTile = DetermineAirWithdrawlTile(airCombatUnit);
     if (targetTile != null)
     {
         Game.BoardFactory.ActiveTile = currentTile;
         Game.BoardFactory.ActiveUnit = airCombatUnit;
         Game.BoardFactory.MoveUnitForComputerPlayer(airCombatUnit, currentTile, targetTile);
         return;
     }
 }
        private static TargetAndJumpOffTile DetermineLandAttackJumpOffTile(AirCombatUnit airCombatUnit, Tile currentTile)
        {
            List<Tile> adjacentTiles = null;
            List<TargetAndJumpOffTile> targetAndJumpOffTiles = new List<TargetAndJumpOffTile>();
            TargetAndJumpOffTile targetAndJumpOffTile = null;

            foreach (Tile tile in airCombatUnit.MoveableTiles)
            {
                adjacentTiles = Game.TileFactory.GetAdjacentTiles(tile, 1, false);
                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 static Tile DetermineAirWithdrawlTile(AirCombatUnit airCombatUnit)
 {
     foreach (Tile tile in airCombatUnit.MoveableTiles)
     {
         if(tile.Terrain.TerrainTypeEnum == TerrainTypeEnum.Airfield && tile.Nation.SideEnum == SideEnum.Allies)
         {
             return tile;
         }
     }
     return null;
 }
 private void DisplayAirCombatUnitInformation(AirCombatUnit airCombatUnit)
 {
     SetCombatUnitTextBlock("Ammo", airCombatUnit.Equipment.MaxAmmo.ToString());
     SetCombatUnitTextBlock("Fuel", airCombatUnit.Equipment.MaxFuel.ToString());
     SetCombatUnitTextBlock("Movement Range", airCombatUnit.Equipment.BaseMovement.ToString());
     SetCombatUnitTextBlock("Hard Attack", airCombatUnit.Equipment.HardAttack.ToString());
     SetCombatUnitTextBlock("Soft Attack", airCombatUnit.Equipment.SoftAttack.ToString());
     SetCombatUnitTextBlock("Air Attack", airCombatUnit.Equipment.AirAttack.ToString());
     SetCombatUnitTextBlock("Sea Attack", airCombatUnit.Equipment.NavalAttack.ToString());
     SetCombatUnitTextBlock("Ground Defense", airCombatUnit.Equipment.GroundDefense.ToString());
     SetCombatUnitTextBlock("Air Defense", airCombatUnit.Equipment.AirDefense.ToString());
     SetCombatUnitTextBlock("Sea Defense", airCombatUnit.Equipment.SeaDefense.ToString());
     SetCombatUnitTextBlock("COST", airCombatUnit.Equipment.UnitCost.ToString());
 }