Ejemplo n.º 1
0
        // Turn the unit into a king by removing it from player's army and replacing it with a king in the player's army
        public void ConvertToKing(BoardCell cell)
        {
            Unit unit = this;

            Commander.ArmyUnits.Remove(this);

            unit         = new King(UnitCoords.X, UnitCoords.Y, Commander);
            unit.MoveDir = MoveDir;

            cell.FillCell(unit);
        }
Ejemplo n.º 2
0
        // clears the board and armies and replaces the pieces with ones stored in redo history item
        public void Redo()
        {
            Player p1 = Players[0];
            Player p2 = Players[1];

            for (int i = 0; i < p1.ArmyUnits.Count; i++)
            {
                Unit      unit = p1.ArmyUnits[i];
                BoardCell cell = Board.Cells[unit.UnitCoords.X, unit.UnitCoords.Y];

                cell.EmptyCell();
            }

            for (int i = 0; i < p2.ArmyUnits.Count; i++)
            {
                Unit      unit = p2.ArmyUnits[i];
                BoardCell cell = Board.Cells[unit.UnitCoords.X, unit.UnitCoords.Y];

                cell.EmptyCell();
            }

            p1.ArmyUnits = new List <Unit>();
            p1.Kills     = 0;

            p2.ArmyUnits = new List <Unit>();
            p2.Kills     = 0;

            m_history.Redo();

            HistoryItem item = m_history.CurrItem;

            p1.Kills = item.P1Kills;
            p2.Kills = item.P2Kills;
            for (int i = 0; i < item.P1UnitCoords.Count; i++)
            {
                BoardCell cell = Board.Cells[item.P1UnitCoords[i].X, item.P1UnitCoords[i].Y];
                switch (item.P1UnitTypes[i])
                {
                case 0:
                    Man man = new Man(item.P1UnitCoords[i].X, item.P1UnitCoords[i].Y, p1);
                    man.MoveDir = -1;

                    cell.FillCell(man);
                    break;

                case 1:
                    King king = new King(item.P1UnitCoords[i].X, item.P1UnitCoords[i].Y, p1);
                    king.MoveDir = -1;

                    cell.FillCell(king);
                    break;
                }
            }

            for (int i = 0; i < item.P2UnitCoords.Count; i++)
            {
                BoardCell cell = Board.Cells[item.P2UnitCoords[i].X, item.P2UnitCoords[i].Y];
                switch (item.P2UnitTypes[i])
                {
                case 0:
                    Man man = new Man(item.P2UnitCoords[i].X, item.P2UnitCoords[i].Y, p2);
                    man.MoveDir = 1;

                    cell.FillCell(man);
                    break;

                case 1:
                    King king = new King(item.P2UnitCoords[i].X, item.P2UnitCoords[i].Y, p2);
                    king.MoveDir = 1;

                    cell.FillCell(king);
                    break;
                }
            }

            Turn       = item.Turn;
            CurrPlayer = Players[Turn % 2];
        }