Esempio n. 1
0
        private void PlayerTwoMove(FrameEventArgs e)
        {
            KeyboardState kb = Keyboard.GetState();

            Artillery artilleryTwo = (Artillery)gameObjects[1];

            Vector2 oldPosition = artilleryTwo.Transform.Position;

            if (kb.IsKeyDown(Key.Left) ^ kb.IsKeyDown(Key.Right))
            {
                if (kb.IsKeyDown(Key.Left))
                {
                    artilleryTwo.Move(Direction.Left, e.Time);
                }
                else
                {
                    artilleryTwo.Move(Direction.Right, e.Time);
                }

                if (CheckCollision(artilleryTwo))
                {
                    artilleryTwo.Transform.Position = oldPosition;
                }
            }
        }
 // Use this for initialization
 void Start()
 {
     data               = GameManager.instance.playerData;
     controls           = GameManager.instance.controls;
     motor              = GetComponent <Motor> ();
     motor.turretLimits = GameManager.instance.playerData.cannonVerticleLimit;
     cannon             = gameObject.GetComponent <Cannon> ();
     artillery          = gameObject.GetComponent <Artillery> ();
 }
Esempio n. 3
0
        public override Skill Clone(int value)
        {
            var tmp = new Artillery
            {
                Description = Description,
                MaxValue    = MaxValue,
                Name        = Name,
                Value       = value
            };

            return(tmp);
        }
Esempio n. 4
0
    protected override IEnumerator Shoot()
    {
        GameObject ar = Instantiate(bulletPrefab, transform.Find("Spawnpoint").position, transform.rotation);

        MuzzFlash.Play();
        Artillery artillery = ar.GetComponent <Artillery>();

        artillery.Target = Target;
        RoundsFired++;
        yield return(new WaitForSeconds(3f));

        RoundFired = false;
    }
        public Artillery Build(string name)
        {
            Artillery art = new Artillery();

            art.cost = new List <IResource>();
            art.cost.Add(new Ore(200));
            art.name        = name;
            art.isDestroyed = false;
            art.level       = 1;
            art.numShots    = 2;
            art.maxShots    = 2;
            return(art);
        }
Esempio n. 6
0
        private static void ArtyCompany()
        {
            Soldier joe     = new Enlisted();
            Soldier pl      = new Officer();
            Weapon  weapon  = new Artillery();
            Units   company = new Company();

            Console.WriteLine($"A typical Artillery platoon consists of: {company.strength} Personnel");
            Console.WriteLine("All the enlisted men say " + joe.Describe());
            Console.WriteLine("While the officer says " + pl.Describe());
            Console.WriteLine("Soldiers use the " + weapon.Name);
            Console.WriteLine("With a " + weapon.Load());
        }
Esempio n. 7
0
 public override void EquipUnit(Equipment input)
 {
     if (input is Artillery)
     {
         artillerypiece = input as Artillery;
     }
     else if (input is ArtilleryEngineer)
     {
         engineer = input as ArtilleryEngineer;
     }
     else
     {
         base.EquipUnit(input);
     }
 }
Esempio n. 8
0
 public override void RemoveEquipment(Equipment output)
 {
     if (output is Artillery)
     {
         artillerypiece = new NoArtillery();
     }
     else if (output is ArtilleryEngineer)
     {
         engineer = null;
     }
     else
     {
         base.RemoveEquipment(output);
     }
 }
Esempio n. 9
0
        Program()
        {
            gts = GridTerminalSystem;

            cockpit  = gts.GetBlockWithName(COCKPIT) as IMyCockpit;
            sound    = gts.GetBlockGroupWithName(SOUND) as IMySoundBlock;
            radar    = new Radar(RADAR);
            arta     = new Artillery(ARTA, cockpit, 1200, 900);
            Torpedos = new List <Torpedo>();
            InitializeTorpedos();
            WolfPackDelays = new List <int>();
            lcd            = gts.GetBlockWithName(LCD) as IMyTextPanel;
            if (lcd == null)
            {
                lcd = cockpit.GetSurface(0) as IMyTextPanel;
            }
        }
Esempio n. 10
0
    public void SetAsset(InputActionAsset newAsset)
    {
        if (newAsset == asset)
        {
            return;
        }
        var PilotTankCallbacks     = m_PilotTankActionsCallbackInterface;
        var ChiefControlsCallbacks = m_ChiefControlsActionsCallbackInterface;
        var ArtilleryCallbacks     = m_ArtilleryActionsCallbackInterface;

        if (m_Initialized)
        {
            Uninitialize();
        }
        asset = newAsset;
        PilotTank.SetCallbacks(PilotTankCallbacks);
        ChiefControls.SetCallbacks(ChiefControlsCallbacks);
        Artillery.SetCallbacks(ArtilleryCallbacks);
    }
Esempio n. 11
0
    void AI_AimLogic(GameObject target)
    {
        for (int i = 0; i < Turrets.Length; i++)
        {
            if (weapons[i].Count > 0)
            {
                for (int j = 0; j < weapons[i].Count; j++)
                {
                    Artillery a = weapons[i][j] as Artillery;
                    if (a)
                    {
                        //Turrets[i].targetPos = a.CalculateLeadPos(target.transform.position, tarRig.velocity.magnitude*Time.deltaTime, target.transform.position, 1f, target.transform.position, float.MaxValue);
                    }
                }
            }


            Turrets[i].Fire();
        }
    }
Esempio n. 12
0
 public ArtilleryJewel2()
 {
     Name  = "Artillery Jewel 2";
     Skill = new Artillery(1);
     Type  = SlotType.Medium;
 }
Esempio n. 13
0
 private void AddEquipment()
 {
     artillerypiece = new NoArtillery();
 }
Esempio n. 14
0
 public override void Activate(ref Artillery artillery)
 {
     artillery = new IncreasedArmorArtillery(artillery);
 }
Esempio n. 15
0
        private static IUnit CreateUnit(UnitType type, int x, int y)
        {
            IUnit unit;

            switch (type)
            {
            case UnitType.Settlers: unit = new Settlers(); break;

            case UnitType.Militia: unit = new Militia(); break;

            case UnitType.Phalanx: unit = new Phalanx(); break;

            case UnitType.Legion: unit = new Legion(); break;

            case UnitType.Musketeers: unit = new Musketeers(); break;

            case UnitType.Riflemen: unit = new Riflemen(); break;

            case UnitType.Cavalry: unit = new Cavalry(); break;

            case UnitType.Knights: unit = new Knights(); break;

            case UnitType.Catapult: unit = new Catapult(); break;

            case UnitType.Cannon: unit = new Cannon(); break;

            case UnitType.Chariot: unit = new Chariot(); break;

            case UnitType.Armor: unit = new Armor(); break;

            case UnitType.MechInf: unit = new MechInf(); break;

            case UnitType.Artillery: unit = new Artillery(); break;

            case UnitType.Fighter: unit = new Fighter(); break;

            case UnitType.Bomber: unit = new Bomber(); break;

            case UnitType.Trireme: unit = new Trireme(); break;

            case UnitType.Sail: unit = new Sail(); break;

            case UnitType.Frigate: unit = new Frigate(); break;

            case UnitType.Ironclad: unit = new Ironclad(); break;

            case UnitType.Cruiser: unit = new Cruiser(); break;

            case UnitType.Battleship: unit = new Battleship(); break;

            case UnitType.Submarine: unit = new Submarine(); break;

            case UnitType.Carrier: unit = new Carrier(); break;

            case UnitType.Transport: unit = new Transport(); break;

            case UnitType.Nuclear: unit = new Nuclear(); break;

            case UnitType.Diplomat: unit = new Diplomat(); break;

            case UnitType.Caravan: unit = new Caravan(); break;

            default: return(null);
            }
            unit.X         = x;
            unit.Y         = y;
            unit.MovesLeft = unit.Move;
            return(unit);
        }
Esempio n. 16
0
 private protected ArtilleryDecorator(Artillery artillery)
     : base(artillery)
 {
     this.artillery = artillery;
 }
Esempio n. 17
0
 private void Uninitialize()
 {
     if (m_PilotTankActionsCallbackInterface != null)
     {
         PilotTank.SetCallbacks(null);
     }
     m_PilotTank = null;
     m_PilotTank_MoveRightLever = null;
     if (m_PilotTankMoveRightLeverActionStarted != null)
     {
         m_PilotTank_MoveRightLever.started -= m_PilotTankMoveRightLeverActionStarted.Invoke;
     }
     if (m_PilotTankMoveRightLeverActionPerformed != null)
     {
         m_PilotTank_MoveRightLever.performed -= m_PilotTankMoveRightLeverActionPerformed.Invoke;
     }
     if (m_PilotTankMoveRightLeverActionCancelled != null)
     {
         m_PilotTank_MoveRightLever.cancelled -= m_PilotTankMoveRightLeverActionCancelled.Invoke;
     }
     m_PilotTank_MoveLeftLever = null;
     if (m_PilotTankMoveLeftLeverActionStarted != null)
     {
         m_PilotTank_MoveLeftLever.started -= m_PilotTankMoveLeftLeverActionStarted.Invoke;
     }
     if (m_PilotTankMoveLeftLeverActionPerformed != null)
     {
         m_PilotTank_MoveLeftLever.performed -= m_PilotTankMoveLeftLeverActionPerformed.Invoke;
     }
     if (m_PilotTankMoveLeftLeverActionCancelled != null)
     {
         m_PilotTank_MoveLeftLever.cancelled -= m_PilotTankMoveLeftLeverActionCancelled.Invoke;
     }
     m_PilotTank_StopLeft = null;
     if (m_PilotTankStopLeftActionStarted != null)
     {
         m_PilotTank_StopLeft.started -= m_PilotTankStopLeftActionStarted.Invoke;
     }
     if (m_PilotTankStopLeftActionPerformed != null)
     {
         m_PilotTank_StopLeft.performed -= m_PilotTankStopLeftActionPerformed.Invoke;
     }
     if (m_PilotTankStopLeftActionCancelled != null)
     {
         m_PilotTank_StopLeft.cancelled -= m_PilotTankStopLeftActionCancelled.Invoke;
     }
     m_PilotTank_StopRight = null;
     if (m_PilotTankStopRightActionStarted != null)
     {
         m_PilotTank_StopRight.started -= m_PilotTankStopRightActionStarted.Invoke;
     }
     if (m_PilotTankStopRightActionPerformed != null)
     {
         m_PilotTank_StopRight.performed -= m_PilotTankStopRightActionPerformed.Invoke;
     }
     if (m_PilotTankStopRightActionCancelled != null)
     {
         m_PilotTank_StopRight.cancelled -= m_PilotTankStopRightActionCancelled.Invoke;
     }
     m_PilotTank_StopAll = null;
     if (m_PilotTankStopAllActionStarted != null)
     {
         m_PilotTank_StopAll.started -= m_PilotTankStopAllActionStarted.Invoke;
     }
     if (m_PilotTankStopAllActionPerformed != null)
     {
         m_PilotTank_StopAll.performed -= m_PilotTankStopAllActionPerformed.Invoke;
     }
     if (m_PilotTankStopAllActionCancelled != null)
     {
         m_PilotTank_StopAll.cancelled -= m_PilotTankStopAllActionCancelled.Invoke;
     }
     m_PilotTank_repair = null;
     if (m_PilotTankRepairActionStarted != null)
     {
         m_PilotTank_repair.started -= m_PilotTankRepairActionStarted.Invoke;
     }
     if (m_PilotTankRepairActionPerformed != null)
     {
         m_PilotTank_repair.performed -= m_PilotTankRepairActionPerformed.Invoke;
     }
     if (m_PilotTankRepairActionCancelled != null)
     {
         m_PilotTank_repair.cancelled -= m_PilotTankRepairActionCancelled.Invoke;
     }
     if (m_ChiefControlsActionsCallbackInterface != null)
     {
         ChiefControls.SetCallbacks(null);
     }
     m_ChiefControls        = null;
     m_ChiefControls_RClick = null;
     if (m_ChiefControlsRClickActionStarted != null)
     {
         m_ChiefControls_RClick.started -= m_ChiefControlsRClickActionStarted.Invoke;
     }
     if (m_ChiefControlsRClickActionPerformed != null)
     {
         m_ChiefControls_RClick.performed -= m_ChiefControlsRClickActionPerformed.Invoke;
     }
     if (m_ChiefControlsRClickActionCancelled != null)
     {
         m_ChiefControls_RClick.cancelled -= m_ChiefControlsRClickActionCancelled.Invoke;
     }
     m_ChiefControls_LClick = null;
     if (m_ChiefControlsLClickActionStarted != null)
     {
         m_ChiefControls_LClick.started -= m_ChiefControlsLClickActionStarted.Invoke;
     }
     if (m_ChiefControlsLClickActionPerformed != null)
     {
         m_ChiefControls_LClick.performed -= m_ChiefControlsLClickActionPerformed.Invoke;
     }
     if (m_ChiefControlsLClickActionCancelled != null)
     {
         m_ChiefControls_LClick.cancelled -= m_ChiefControlsLClickActionCancelled.Invoke;
     }
     if (m_ArtilleryActionsCallbackInterface != null)
     {
         Artillery.SetCallbacks(null);
     }
     m_Artillery         = null;
     m_Artillery_RotateY = null;
     if (m_ArtilleryRotateYActionStarted != null)
     {
         m_Artillery_RotateY.started -= m_ArtilleryRotateYActionStarted.Invoke;
     }
     if (m_ArtilleryRotateYActionPerformed != null)
     {
         m_Artillery_RotateY.performed -= m_ArtilleryRotateYActionPerformed.Invoke;
     }
     if (m_ArtilleryRotateYActionCancelled != null)
     {
         m_Artillery_RotateY.cancelled -= m_ArtilleryRotateYActionCancelled.Invoke;
     }
     m_Artillery_RotateX = null;
     if (m_ArtilleryRotateXActionStarted != null)
     {
         m_Artillery_RotateX.started -= m_ArtilleryRotateXActionStarted.Invoke;
     }
     if (m_ArtilleryRotateXActionPerformed != null)
     {
         m_Artillery_RotateX.performed -= m_ArtilleryRotateXActionPerformed.Invoke;
     }
     if (m_ArtilleryRotateXActionCancelled != null)
     {
         m_Artillery_RotateX.cancelled -= m_ArtilleryRotateXActionCancelled.Invoke;
     }
     m_Artillery_Fire = null;
     if (m_ArtilleryFireActionStarted != null)
     {
         m_Artillery_Fire.started -= m_ArtilleryFireActionStarted.Invoke;
     }
     if (m_ArtilleryFireActionPerformed != null)
     {
         m_Artillery_Fire.performed -= m_ArtilleryFireActionPerformed.Invoke;
     }
     if (m_ArtilleryFireActionCancelled != null)
     {
         m_Artillery_Fire.cancelled -= m_ArtilleryFireActionCancelled.Invoke;
     }
     m_Artillery_Reload = null;
     if (m_ArtilleryReloadActionStarted != null)
     {
         m_Artillery_Reload.started -= m_ArtilleryReloadActionStarted.Invoke;
     }
     if (m_ArtilleryReloadActionPerformed != null)
     {
         m_Artillery_Reload.performed -= m_ArtilleryReloadActionPerformed.Invoke;
     }
     if (m_ArtilleryReloadActionCancelled != null)
     {
         m_Artillery_Reload.cancelled -= m_ArtilleryReloadActionCancelled.Invoke;
     }
     m_Initialized = false;
 }
Esempio n. 18
0
        public void TestMethod2()
        {
            BaseUnitType gUnit = new Infantry();
            var          inf1  = new Infantry();
            var          inf2  = new Infantry();
            var          inf3  = new Infantry();

            var eng1 = new Engineer();
            var eng2 = new Engineer();
            var eng3 = new Engineer();

            var scout1 = new Scout();
            var scout2 = new Scout();
            var scout3 = new Scout();

            var mar1 = new Marine();
            var mar2 = new Marine();
            var mar3 = new Marine();

            var light1 = new Light();
            var light2 = new Light();
            var light3 = new Light();

            var heavy1 = new Heavy();
            var heavy2 = new Heavy();
            var heavy3 = new Heavy();

            var mort1 = new Mortar();
            var mort2 = new Mortar();
            var mort3 = new Mortar();

            var art1 = new Artillery();
            var art2 = new Artillery();
            var art3 = new Artillery();

            var air1 = new Airborn();
            var air2 = new Airborn();
            var air3 = new Airborn();

            var snip1 = new Sniper();
            var snip2 = new Sniper();
            var snip3 = new Sniper();

            inf1.Dispose();
            eng2.Dispose();
            scout1.Dispose();
            mar3.Dispose();
            light2.Dispose();
            heavy1.Dispose();
            mort3.Dispose();
            art2.Dispose();
            air3.Dispose();
            snip1.Dispose();

            inf1.DisplayString();
            inf2.DisplayString();
            inf3.DisplayString();
            eng1.DisplayString();
            eng2.DisplayString();
            eng3.DisplayString();
            scout1.DisplayString();
            scout2.DisplayString();
            scout3.DisplayString();
            mar1.DisplayString();
            mar2.DisplayString();
            mar3.DisplayString();
            light1.DisplayString();
            light2.DisplayString();
            light3.DisplayString();
            heavy1.DisplayString();
            heavy2.DisplayString();
            heavy3.DisplayString();
            mort1.DisplayString();
            mort2.DisplayString();
            mort3.DisplayString();
            art1.DisplayString();
            art2.DisplayString();
            art3.DisplayString();
            air1.DisplayString();
            air2.DisplayString();
            air3.DisplayString();
            snip1.DisplayString();
            snip2.DisplayString();
            snip3.DisplayString();
        }
Esempio n. 19
0
 /// <summary>
 /// Create artillery special attack selection state.
 /// </summary>
 /// <param name="ui">UI reference.</param>
 /// <param name="player">Player info reference.</param>
 /// <param name="unit">Selected unit.</param>
 /// <exception cref="System.ArgumentNullException">Thrown when any parameter is null.</exception>
 /// <exception cref="System.InvalidCastException">Thrown when unit is not Artillery.</exception>
 internal ArtillerySpecialAttackSelectedState(InGameUI ui, PlayerInfo player, Unit unit) : base(ui, player, unit)
 {
     artillery = (Artillery)unit;
 }
Esempio n. 20
0
        public void UIField()
        {
            Coordinate?addCoordinate = null;

            bool isToTrain = false;

            int numberOfUnitsToProduce = 0;

            string errorMessage = null;
            string option, coordinate = null;
            string strBuilding        = null;
            string unit               = null;
            string unitToTrain        = null;
            string optionalCoordinate = null;
            string isNewTurn          = null;

            Field field = new Field(gm);

            field.Show();
            int n_moves = 0;

            if (gm.PlayerTurn == null)
            {
                gm.PlayerTurn = gm.Player1;
            }


            do
            {
                if (isNewTurn == null)
                {
                    n_moves = gm.PlayerTurn.Resources.N_Moves;
                }
                else if (isNewTurn == "YES")
                {
                    n_moves = gm.PlayerTurn.Resources.N_Moves;
                }

                int nBarracks           = gm.PlayerTurn.Resources.CountBarracks();
                int nStables            = gm.PlayerTurn.Resources.CountStables();
                int nArtilleryFactories = gm.PlayerTurn.Resources.CountArtilleryFactories();

                Console.WriteLine("────────────────────────────────────────────");
                Console.ForegroundColor = gm.PlayerTurn.Color;
                Console.WriteLine("{0} its your turn", gm.PlayerTurn.Username);
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("You have {0} points to move", n_moves);
                Console.WriteLine("You have {0} coins", gm.PlayerTurn.Resources.Coins);
                Console.ResetColor();
                Console.WriteLine("────────────────────────────────────────────");
                Console.WriteLine("What is your next move?");
                Console.WriteLine("────────────────────────────────────────────");
                Console.WriteLine("ADD");
                if (nBarracks > 0 || nStables > 0 || nArtilleryFactories > 0)
                {
                    Console.WriteLine("TRAIN UNITS");
                }
                Console.WriteLine("MOVE");
                Console.WriteLine("ATTACK");
                Console.WriteLine("────────────────────────────────────────────");
                option = Console.ReadLine().ToUpper();



                if (option == "ADD")
                {
                    if (gm.PlayerTurn.Resources.HasAnyKindOfUnit())
                    {
                        Console.WriteLine("If you want to add a unit you don't need to specify the coordinate, you can write: b,2");
                    }
                    Console.WriteLine("Which coordinate do you want to add? Ex:(letter,number)");
                    coordinate = Console.ReadLine().ToUpper();



                    //TODO: Needs a try here
                    try
                    {
                        string[] coordinateSplit = coordinate.Split(',');

                        char letter = Convert.ToChar(coordinateSplit[0]);
                        int  number = Int32.Parse(coordinateSplit[1]);

                        addCoordinate = new Coordinate(letter, number);
                    }
                    catch (FormatException e)
                    {
                        Utils.ColorWrite(ConsoleColor.Red, "You need to write letter,number");
                        Console.WriteLine();
                    }
                }
                else if (option == "TRAIN UNITS")
                {
                    isToTrain = true;
                }
                else if (option == "MOVE" || option == "ATTACK")
                {
                    string firstTextMoveOrAttack = option == "MOVE"
                        ? "Which coordinate do you want to move? Ex:(letter,number)"
                        : "Select the unit that you want to attack with! (letter,number)";
                    string secondTextMoveOrAttack = option == "MOVE"
                        ? "Where do you want to replace it? Ex:(letter,number)"
                        : "Select the unit that you want to attack! (letter,number)";

                    Console.WriteLine(firstTextMoveOrAttack);
                    coordinate = Console.ReadLine().ToUpper();

                    try
                    {
                        string[] coordinateSplit = coordinate.Split(',');

                        char letter = Convert.ToChar(coordinateSplit[0]);
                        int  number = Int32.Parse(coordinateSplit[1]);

                        addCoordinate = new Coordinate(letter, number);

                        Console.WriteLine(secondTextMoveOrAttack);

                        optionalCoordinate = Console.ReadLine().ToUpper();
                    }
                    catch (FormatException e)
                    {
                        Utils.ColorWrite(ConsoleColor.Red, "You need to write letter,number");
                        Console.WriteLine();
                    }
                }
                else if (option == "EXIT")
                {
                    break;
                }

                if (isToTrain)
                {
                    Console.WriteLine("SELECT ONE OF THIS UNITS TO TRAIN");
                    Console.WriteLine("────────────────────────────────────────────");
                    if (nBarracks > 0)
                    {
                        Console.WriteLine("INFANTRY | You got {0}", gm.PlayerTurn.Resources.N_Infantry);
                    }
                    if (nStables > 0)
                    {
                        Console.WriteLine("CAVALRY  | You got {0}", gm.PlayerTurn.Resources.N_Cavalry);
                    }
                    if (nArtilleryFactories > 0)
                    {
                        Console.WriteLine("ARTILLERY| You got {0}", gm.PlayerTurn.Resources.N_Artillery);
                    }
                    Console.WriteLine("────────────────────────────────────────────");
                    unitToTrain = Console.ReadLine().ToUpper();

                    Console.WriteLine("How many units you want?");
                    numberOfUnitsToProduce = int.Parse(Console.ReadLine());
                }
                else if (optionalCoordinate == null && addCoordinate.HasValue)
                {
                    Console.WriteLine("Which type of unit you want to add?");
                    Console.WriteLine("────────────────────────────────────────────");
                    Console.WriteLine("BUILDING");
                    if (gm.PlayerTurn.Resources.HasAnyKindOfUnit())
                    {
                        Console.WriteLine("UNIT");
                    }
                    Console.WriteLine("────────────────────────────────────────────");

                    string isBuildingString = Console.ReadLine().ToUpper();
                    bool   isBuilding       = isBuildingString == "BUILDING" ? true : false;

                    if (isBuilding)
                    {
                        Console.WriteLine("SELECT ONE OF THIS BUILDINGS TO BUILD!");
                        Console.WriteLine("────────────────────────────────────────────");
                        Console.WriteLine("FARM");
                        Console.WriteLine("BARRACK");
                        Console.WriteLine("STABLE");
                        Console.WriteLine("ARTILLERY FACTORY");
                        Console.WriteLine("────────────────────────────────────────────");
                        strBuilding = Console.ReadLine().ToUpper();
                    }
                    else if (gm.PlayerTurn.Resources.HasAnyKindOfUnit())
                    {
                        Console.WriteLine("SELECT ONE OF THIS UNITS TO SPAWN");
                        Console.WriteLine("────────────────────────────────────────────");
                        Console.WriteLine("INFANTRY | You got {0}", gm.PlayerTurn.Resources.N_Infantry);
                        Console.WriteLine("CAVALRY  | You got {0}", gm.PlayerTurn.Resources.N_Cavalry);
                        Console.WriteLine("ARTILLERY| You got {0}", gm.PlayerTurn.Resources.N_Artillery);
                        Console.WriteLine("────────────────────────────────────────────");
                        unit = Console.ReadLine().ToUpper();
                    }
                }

                if (option == "MOVE" && optionalCoordinate != null && addCoordinate.HasValue && (!field.IsOutOfBorders(addCoordinate.Value)))
                {
                    char newLetter = ' ';
                    int  newNumber = 0;
                    try
                    {
                        string[] optionalCoordinateSplit = optionalCoordinate.Split(',');

                        newLetter = Convert.ToChar(optionalCoordinateSplit[0]);
                        newNumber = Int32.Parse(optionalCoordinateSplit[1]);
                    }
                    catch (FormatException e)
                    {
                        Utils.ColorWrite(ConsoleColor.Red, "You need to write letter,number");
                        Console.WriteLine();
                    }

                    Coordinate moveCoordinate = new Coordinate(newLetter, newNumber);

                    if (field.IsOutOfBorders(moveCoordinate))
                    {
                        Console.WriteLine("You can't move a unit to out of the field!");
                    }

                    //TODO : Remove this from where when the update doesn't needs the GameEntity
                    GameEntity ge = null;
                    if (gm.PlayerTurn == gm.Player1)
                    {
                        if (gm.PlayerTurn.Resources.IsCoordinateAvailable(addCoordinate.Value) != null)
                        {
                            if (gm.PlayerTurn.Resources.IsCoordinateAvailable(moveCoordinate) == null && gm.Player2.Resources.IsCoordinateAvailable(moveCoordinate) == null)
                            {
                                ge = gm.PlayerTurn.Resources.IsCoordinateAvailable(addCoordinate.Value);
                                if (ge is Building)
                                {
                                    errorMessage = "You cannot move buildings!";
                                }
                                else if (ge != null)
                                {
                                    Unit u = ge as Unit;

                                    int distance     = ge.Distance(moveCoordinate);
                                    int moveDistance = u.CanMove(distance, n_moves);
                                    if (moveDistance > 0)
                                    {
                                        n_moves -= moveDistance;
                                        gm.PlayerTurn.Resources.MoveEntity(ge, moveCoordinate);
                                        //field.Update();
                                    }
                                    else
                                    {
                                        errorMessage = "You don't have enough move points to do that!";
                                    }
                                }
                            }
                            else
                            {
                                errorMessage = "You can't do that!";
                            }
                        }
                        else
                        {
                            errorMessage = "You cannot move the unknown!";
                        }
                    }
                    else if (gm.PlayerTurn == gm.Player2)
                    {
                        if (gm.PlayerTurn.Resources.IsCoordinateAvailable(addCoordinate.Value) != null)
                        {
                            if (gm.PlayerTurn.Resources.IsCoordinateAvailable(moveCoordinate) == null && gm.Player1.Resources.IsCoordinateAvailable(moveCoordinate) == null)
                            {
                                ge = gm.PlayerTurn.Resources.IsCoordinateAvailable(addCoordinate.Value);
                                if (ge is Building)
                                {
                                    errorMessage = "You cannot move buildings!";
                                }
                                else if (ge != null)
                                {
                                    Unit u = ge as Unit;

                                    int distance     = ge.Distance(moveCoordinate);
                                    int moveDistance = u.CanMove(distance, n_moves);
                                    if (moveDistance > 0)
                                    {
                                        n_moves -= moveDistance;
                                        gm.PlayerTurn.Resources.MoveEntity(ge, moveCoordinate);
                                        //field.Update();
                                    }
                                    else
                                    {
                                        errorMessage = "You don't have enough move points to do that!";
                                    }
                                }
                            }
                            else
                            {
                                errorMessage = "You can't do that!";
                            }
                        }

                        else
                        {
                            errorMessage = "You cannot move the unknown!";
                        }
                    }

                    addCoordinate = null;

                    optionalCoordinate = null;

                    field.Update();

                    if (errorMessage != null)
                    {
                        Console.WriteLine(errorMessage);
                        errorMessage = null;
                    }

                    Console.WriteLine("Are you done? Do you want to finish the turn? (Yes or No)");
                    isNewTurn = Console.ReadLine().ToUpper();

                    if (isNewTurn == "YES")
                    {
                        isNewTurn = null;
                        gm.NewTurn();
                    }
                }
                else if (option == "ATTACK" && optionalCoordinate != null && addCoordinate.HasValue)
                {
                    string[] optionalCoordinateSplit = optionalCoordinate.Split(',');

                    char       newLetter      = Convert.ToChar(optionalCoordinateSplit[0]);
                    int        newNumber      = Int32.Parse(optionalCoordinateSplit[1]);
                    Coordinate moveCoordinate = new Coordinate(newLetter, newNumber);

                    if (gm.PlayerTurn.Resources.IsCoordinateAvailable(addCoordinate.Value) != null)
                    {
                        GameEntity playerEntity = gm.PlayerTurn.Resources.IsCoordinateAvailable(addCoordinate.Value);
                        if (playerEntity is Unit)
                        {
                            Unit playerUnit = playerEntity as Unit;

                            Player enemy = gm.PlayerTurn == gm.Player1 ? gm.Player2 : gm.Player1;

                            if (enemy.Resources.IsCoordinateAvailable(moveCoordinate) != null)
                            {
                                GameEntity enemyEntity = enemy.Resources.IsCoordinateAvailable(moveCoordinate);

                                int distanceToEnemy = playerEntity.Distance(moveCoordinate);
                                if (distanceToEnemy <= playerUnit.AttackRange)
                                {
                                    if (enemyEntity.TakeDamage(playerUnit.AttackValue))
                                    {
                                        gm.PlayerTurn.Resources.Score += enemyEntity.Score;
                                        enemy.Resources.RemoveEntity(enemyEntity);
                                        if (enemyEntity is PlayerBase)
                                        {
                                            gm.SetGameOver();
                                            return;
                                        }

                                        //gm.PlayerTurn.Resources.MoveEntity(playerEntity, moveCoordinate);
                                    }
                                }
                                else
                                {
                                    errorMessage = "That's to far for my range!";
                                }
                            }
                            else if (gm.PlayerTurn.Resources.IsCoordinateAvailable(moveCoordinate) != null)
                            {
                                errorMessage = "You can't attack your self!";
                            }
                        }
                        else
                        {
                            errorMessage = "You can't attack other unit with a building selected!";
                        }
                    }
                    else
                    {
                        errorMessage = "You need to select a unit!";
                    }

                    optionalCoordinate = null;

                    field.Update();

                    if (errorMessage != null)
                    {
                        Console.WriteLine(errorMessage);
                        errorMessage = null;
                    }

                    Console.WriteLine("Are you done? Do you want to finish the turn? (Yes or No)");
                    isNewTurn = Console.ReadLine().ToUpper();

                    if (isNewTurn == "YES")
                    {
                        isNewTurn = null;
                        gm.NewTurn();
                    }
                }
                else if (option == "TRAIN UNITS" && (nArtilleryFactories > 0 || nBarracks > 0 || nStables > 0) && unitToTrain != null)
                {
                    string buildingToWork = null;
                    switch (unitToTrain)
                    {
                    case "INFANTRY":
                        buildingToWork = "barrack";
                        break;

                    case "CAVALRY":
                        buildingToWork = "stable";
                        break;

                    case "ARTILLERY":
                        buildingToWork = "artillery_factory";
                        break;

                    default:
                        errorMessage = "You need to specify the unity!";
                        break;
                    }

                    if (gm.PlayerTurn.Resources.Coins <= 0)
                    {
                        errorMessage = "You don't have enough coins to train any kind of units";
                    }
                    else if (!gm.PlayerTurn.Resources.GetToWork(numberOfUnitsToProduce, buildingToWork))
                    {
                        errorMessage = "You don't have enough coins to train that unit";
                    }

                    isToTrain = false;

                    if (errorMessage != null)
                    {
                        Console.WriteLine(errorMessage);
                        errorMessage = null;
                    }

                    Console.WriteLine("Are you done? Do you want to finish the turn? (Yes or No)");
                    isNewTurn = Console.ReadLine().ToUpper();

                    if (isNewTurn == "YES")
                    {
                        isNewTurn = null;
                        gm.NewTurn();
                    }
                }
                else if (option == "ADD" && optionalCoordinate == null && addCoordinate.HasValue && (!field.IsOutOfBorders(addCoordinate.Value)))
                {
                    GameEntity ge = null;

                    if (unit != null)
                    {
                        switch (unit)
                        {
                        case "INFANTRY":
                            if (gm.PlayerTurn.Resources.N_Infantry > 0)
                            {
                                ge = new Infantry(addCoordinate.Value, gm.PlayerTurn.Color);
                            }
                            break;

                        case "CAVALRY":
                            if (gm.PlayerTurn.Resources.N_Cavalry > 0)
                            {
                                ge = new Cavalry(addCoordinate.Value, gm.PlayerTurn.Color);
                            }
                            break;

                        case "ARTILLERY":
                            if (gm.PlayerTurn.Resources.N_Artillery > 0)
                            {
                                ge = new Artillery(addCoordinate.Value, gm.PlayerTurn.Color);
                            }
                            break;

                        default:
                            errorMessage = "You need to specify the unit!";
                            continue;
                        }

                        if (ge != null)
                        {
                            Building building = null;
                            if (ge is Cavalry)
                            {
                                building = gm.PlayerTurn.Resources.GetRandomBuilding <Stable>();
                            }
                            else if (ge is Artillery)
                            {
                                building = gm.PlayerTurn.Resources.GetRandomBuilding <ArtilleryFactory>();
                            }
                            else if (ge is Infantry)
                            {
                                building = gm.PlayerTurn.Resources.GetRandomBuilding <Barrack>();
                            }
                            if (gm.PlayerTurn.Resources.CanPlaceAroundBuilding(building, gm.GetEnemyPlayer()) != null)
                            {
                                //CanPlaceAroundBuilding needs the enemyPlayer to check if the enemy player has the coordinate free!
                                Coordinate?coordinateFree = gm.PlayerTurn.Resources.CanPlaceAroundBuilding(building, gm.GetEnemyPlayer());
                                if (coordinateFree.HasValue)
                                {
                                    ge.Position = coordinateFree.Value;
                                    gm.PlayerTurn.Resources.AddEntity(ge);
                                }
                                else
                                {
                                    errorMessage = "I can't place the unit around the building!";
                                }
                            }
                        }

                        unit = null;
                    }
                    else if (strBuilding != null)
                    {
                        char firstLetter = addCoordinate.Value.Letter;
                        int  firstNumber = addCoordinate.Value.Number;
                        List <Coordinate> listCoordinates = new List <Coordinate>();

                        Coordinate secondCoordinate = new Coordinate(++firstLetter, firstNumber);
                        Coordinate thirdCoordinate  = new Coordinate(firstLetter, ++firstNumber);
                        Coordinate fourthCoordinate = new Coordinate(--firstLetter, firstNumber);

                        listCoordinates.Add(secondCoordinate);
                        //listCoordinates.Add(thirdCoordinate);
                        //listCoordinates.Add(fourthCoordinate);
                        switch (strBuilding)
                        {
                        case "FARM":
                            ge = new Farm(addCoordinate.Value, listCoordinates, gm.PlayerTurn.Color);
                            break;

                        case "BARRACK":
                            ge = new Barrack(addCoordinate.Value, listCoordinates, gm.PlayerTurn.Color);
                            break;

                        case "STABLE":
                            ge = new Stable(addCoordinate.Value, listCoordinates, gm.PlayerTurn.Color);
                            break;

                        case "ARTILLERY FACTORY":
                            ge = new ArtilleryFactory(addCoordinate.Value, listCoordinates, gm.PlayerTurn.Color);
                            break;

                        default:
                            errorMessage = "You need to specify the building!";
                            continue;
                        }
                        if (gm.PlayerTurn.Resources.IsCoordinateAvailable(addCoordinate.Value) != null ||
                            gm.PlayerTurn.Resources.IsCoordinateAvailable(secondCoordinate) != null)
                        {
                            errorMessage = "There's a unit on that coordinate!";
                        }
                        else if (gm.PlayerTurn == gm.Player1 && gm.Player2.Resources.IsCoordinateAvailable(addCoordinate.Value) != null ||
                                 gm.Player2.Resources.IsCoordinateAvailable(secondCoordinate) != null)
                        {
                            errorMessage = "Enemy collision!";
                        }
                        else if (gm.PlayerTurn == gm.Player2 && gm.Player1.Resources.IsCoordinateAvailable(addCoordinate.Value) != null ||
                                 gm.Player1.Resources.IsCoordinateAvailable(secondCoordinate) != null)
                        {
                            errorMessage = "Enemy collision!";
                        }
                        else
                        {
                            Building b = ge as Building;
                            if (gm.PlayerTurn.Resources.Coins >= b.CostToBuild)
                            {
                                bool hasBuildingClose = gm.PlayerTurn.Resources.HasBuildingClose(b);
                                if (hasBuildingClose)
                                {
                                    gm.PlayerTurn.Resources.AddEntity(ge);
                                }
                                else
                                {
                                    errorMessage = "There's no building around that coordinate!";
                                }
                            }
                            else
                            {
                                errorMessage = "You don't have enough coins to build that building!";
                            }
                        }
                        strBuilding = null;
                    }


                    field.Update();

                    if (errorMessage != null)
                    {
                        Console.WriteLine(errorMessage);
                        errorMessage = null;
                    }

                    Console.WriteLine("Are you done? Do you want to finish the turn? (Yes or No)");
                    isNewTurn = Console.ReadLine().ToUpper();

                    if (isNewTurn == "YES")
                    {
                        isNewTurn = null;
                        gm.NewTurn();
                    }
                }
            } while (option != "EXIT" || !gm.GameFinished);
        }