Пример #1
0
        private void UpdateGameObjects(GameMenu Menu)
        {
            var IsMouseHandled = false;

            if (UI.IsPlayerTurnStarted)
            {
                for (var i = 0; i < Hand.CardsCount; i++)
                {
                    Hand[i].Enabled = false;
                }
            }
            if (UI.IsVs)
            {
                UI.Update(ref IsMouseHandled, Map, Hand, cam, Menu, OpponentSide);
                Hand.Update(ref IsMouseHandled, Map, cam, UI.UI_Bottom.Position.Y, IsNotLockClick, PlayerSide, this, UI.Player_Money);
            }
            else
            {
                Hand.Update(ref IsMouseHandled, Map, cam, UI.UI_Bottom.Position.Y, IsNotLockClick, PlayerSide, this, UI.Player_Money);
                UI.Update(ref IsMouseHandled, Map, Hand, cam, Menu, OpponentSide);
            }
            Map.Update(ref IsMouseHandled, Hand, cam, IsNotLockClick, OpponentSide, this);
        }
Пример #2
0
        public void Update(ref bool IsMouseHandled, Map map, Hand hand, Camera cam, GameMenu Menu, MapZones Opponent)
        {
            EnemyTurnMoveProcess();
            Br.UpdateAnims();
            if (_IsEndGame)
            {
                if (iteration < 300)
                {
                    iteration++;
                    if (iteration >= 60 && iteration < 90)
                    {
                        EndGame.Visible = true;
                        EndGame.Scale  -= new Vector2(0.0333f);
                    }
                }
                else
                {
                    if (iteration == 300)
                    {
                        Parent.EndGame();
                        iteration++;
                    }
                }
            }
            else
            if (_IsVs)
            {
                Cardchoose.Update();
                if (ChooseConfirm.Update() == ButtonStates.CLICKED)
                {
                    Parent.IsNotLockClick = false;
                    ChooseConfirm.Visible = false;
                    var replacedcards = Cardchoose.GetReplacedCards();
                    var command       = new List <string>();
                    for (var i = 0; i < replacedcards.Length; i++)
                    {
                        if (replacedcards[i] == true)
                        {
                            command.Add(i.ToString());
                        }
                    }
                    if (command.Count == 0)
                    {
                        command.Add("NONE");
                    }
                    CommandParser.SendCommandToGameServer(command.ToArray());
                }
                IsMouseHandled = true;
                if (iteration < 120)
                {
                    if (IsStartVs && iteration > 80)
                    {
                        PlayerIcon.Position   += new Vector2((_DestinationPointPlayer.X - PlayerIcon.Position.X) / 8, 0);
                        OpponentIcon.Position -= new Vector2((OpponentIcon.Position.X - _DestinationPointOpponent.X) / 8, 0);
                        PlayerName.Position    = new Vector2(PlayerIcon.Position.X + PlayerIcon.Texture.Width / 2 * PlayerIcon.Scale.X - PlayerName.Font.MeasureString(PlayerName.Text).X, PlayerIcon.Position.Y + PlayerIcon.Texture.Height * PlayerIcon.Scale.Y);
                        OpponentName.Position  = new Vector2(OpponentIcon.Position.X + OpponentIcon.Texture.Width / 2 * OpponentIcon.Scale.X - OpponentName.Font.MeasureString(OpponentName.Text).X, OpponentIcon.Position.Y + OpponentIcon.Texture.Height * OpponentIcon.Scale.Y);
                    }
                    if (IsStopVs && iteration > 80)
                    {
                        PlayerIcon.Position   -= _TmpPlDistance;
                        OpponentIcon.Position -= _TmpOpDistance;
                        PlayerIcon.Scale      -= _TmpIconScale;
                        OpponentIcon.Scale    -= _TmpIconScale;
                        PlayerName.Position   -= _TmpPlNameDistance;
                        OpponentName.Position -= _TmpOpNameDistance;
                        PlayerName.Scale      -= _TmpTextScale;
                        OpponentName.Scale    -= _TmpTextScale;
                        Vs.Visible             = false;
                    }
                    if (iteration == 119)
                    {
                        if (IsStartVs)
                        {
                            IsStartVs = false;
                            StopVS();
                        }
                        else
                        if (IsStopVs)
                        {
                            IsStopVs                = false;
                            PlayerIcon.Position     = Vector2.Zero;
                            OpponentIcon.Position   = new Vector2(_CurrentScreenRes.X - OpponentIcon.Texture.Width * OpponentIcon.Scale.X, 0);
                            PlayerIcon.Scale        = new Vector2(0.4f);
                            OpponentIcon.Scale      = new Vector2(0.4f);
                            PlayerName.Scale        = Vector2.One;
                            OpponentName.Scale      = Vector2.One;
                            PlayerName.Position     = PlayerIcon.Position + new Vector2(PlayerIcon.Texture.Width * PlayerIcon.Scale.X + 10, 0);
                            OpponentName.Position   = OpponentIcon.Position - new Vector2(OpponentName.Font.MeasureString(OpponentName.Text).X + 10, 0);
                            ChooseText.Visible      = true;
                            ChooseOrderText.Visible = true;
                            ChooseConfirm.Visible   = true;
                            var Cards = new Card[ShowingCards.Length];
                            for (var i = 0; i < ShowingCards.Length; i++)
                            {
                                Cards[i] = new Card(Vector2.One, GameContent.CardTexture, GameContent.UnitCards[ShowingCards[i]].Card_Decoration, new Vector2(16, 9), 200, 10, 0, 13, new Animation(14, 16, true), new Animation(2, 6, false), new Animation(7, 12, false), new Animation(1, 1, true), 0, GameContent.UI_InfoFont, Color.White, GameContent.UnitCards[ShowingCards[i]].Name, GameContent.UnitCards[ShowingCards[i]].Damage.ToString(), GameContent.UnitCards[ShowingCards[i]].Armor.ToString(), GameContent.UnitCards[ShowingCards[i]].AttackRadius.ToString(), GameContent.UnitCards[ShowingCards[i]].Speed.ToString(), GameContent.UnitCards[ShowingCards[i]].HP.ToString(), GameContent.UnitCards[ShowingCards[i]].Cost.ToString(), 141, 315, 4, 4, 37, true, Parent.PlayerSide, Layer: 0.001f);
                            }
                            Cardchoose.ShowCards(true,
                                                 Cards);
                        }
                        else
                        {
                            _IsVs = false;

                            ChooseText.Visible      = false;
                            ChooseOrderText.Visible = false;
                            ChooseText.Text         = "Выберите карту";
                            ChooseText.Position     = new Vector2((CurrentScreenRes.X - ChooseText.Font.MeasureString(ChooseText.Text).X) / 2, CurrentScreenRes.Y / 2 - 250);
                            hand.AddCards(20, Cardchoose.GetCards(true).ToArray());
                            Cardchoose.ClearCardList();
                            Br.ScreenBrUp();
                        }
                    }
                    iteration++;
                }
            }
            else
            if (IsPlayerTurnStarted)
            {
                if (iteration < 100)
                {
                    NewTurnText.Update();
                    if (iteration == 79)
                    {
                        NewTurnText.Disappear();
                    }
                    iteration++;
                }
                else
                {
                    if (!IsPlayerTurnCardShown)
                    {
                        IsPlayerTurnCardShown = true;
                        ChooseText.Visible    = true;

                        var Cards = new Card[ShowingCards.Length];
                        for (var i = 0; i < ShowingCards.Length; i++)
                        {
                            Cards[i] = new Card(Vector2.One, GameContent.CardTexture, GameContent.UnitCards[ShowingCards[i]].Card_Decoration, new Vector2(16, 9), 200, 10, 0, 13, new Animation(14, 16, true), new Animation(2, 6, false), new Animation(7, 12, false), new Animation(1, 1, true), 0, GameContent.UI_InfoFont, Color.White, GameContent.UnitCards[ShowingCards[i]].Name, GameContent.UnitCards[ShowingCards[i]].Damage.ToString(), GameContent.UnitCards[ShowingCards[i]].Armor.ToString(), GameContent.UnitCards[ShowingCards[i]].AttackRadius.ToString(), GameContent.UnitCards[ShowingCards[i]].Speed.ToString(), GameContent.UnitCards[ShowingCards[i]].HP.ToString(), GameContent.UnitCards[ShowingCards[i]].Cost.ToString(), 141, 315, 4, 4, 37, true, Parent.PlayerSide, Layer: 0.001f);
                        }
                        Cardchoose.ShowCards(false, Cards);
                    }
                    var Upd = Cardchoose.Update();
                    if (Upd != -1)
                    {
                        Cardchoose.Enabled = false;
                        //Отправить на серв данные
                        CommandParser.SendCommandToGameServer(new string[] { "CHOOSE", Upd.ToString() });
                    }
                }
            }
            else
            {
                if (!IsMouseHandled)
                {
                    if (MouseControl.X < UI_BottomLeft.Texture.Width)
                    {
                        if (MouseControl.Y > _CurrentScreenRes.Y - UI_BottomLeft.Texture.Height)
                        {
                            IsMouseHandled = true;
                        }
                    }
                    else
                    if (MouseControl.Y > _CurrentScreenRes.Y - UI_Bottom.Texture.Height)
                    {
                        IsMouseHandled = true;
                    }
                    else
                    if (MouseControl.Y < UI_UpLeft.Texture.Height)
                    {
                        IsMouseHandled = true;
                    }
                }

                var MoveUpd     = Btn_Move.Update();
                var AttackUpd   = Btn_Attack.Update();
                var EndTurnUpd  = Btn_EndTurn.Update();
                var StatsUpd    = Btn_Stats.Update();
                var ChatUpd     = Btn_Chat.Update();
                var GameMenuUpd = Btn_GameMenu.Update();
                _ShowInf = false;

                if (!(map.IsPathFinding || map.IsAttack))
                {
                    Btn_EndTurn.Enabled = true;
                    if (!map.IsPathFinding)
                    {
                        Btn_Attack.Enabled = true;
                    }
                    if (!map.IsAttack)
                    {
                        Btn_Move.Enabled = true;
                    }
                    for (var i = 0; i < hand.CardsCount; i++)
                    {
                        hand[i].Enabled = true;
                    }
                }
                else
                {
                    for (var i = 0; i < hand.CardsCount; i++)
                    {
                        hand[i].Enabled = false;
                    }
                }

                if ((MoveUpd == ButtonStates.CLICKED || (Btn_Move.Enabled && KeyBindings.CheckKeyReleased("KEY_MOVEUNIT"))) && map.SelectedTile.X != -1)
                {
                    if (map.IsPathFinding)
                    {
                        map.IsPathFinding = false;
                        map.SetDefault();
                        map.UpdateAllTiles(cam);
                        map.CreatePathArrows(null, cam);
                    }
                    else
                    if ((map.GetTile(map.SelectedTile.X, map.SelectedTile.Y).TileContains == MapTiles.WITH_UNIT || map.GetTile(map.SelectedTile.X, map.SelectedTile.Y).TileContains == MapTiles.WITH_UNIT_AND_BUILDING) && map.GetTile(map.SelectedTile.X, map.SelectedTile.Y).UnitOnTile.side == Side.PLAYER)
                    {
                        Btn_Attack.Enabled   = false;
                        Btn_EndTurn.Enabled  = false;
                        map.IsPathFinding    = true;
                        map.ActionStartPoint = new Point(map.SelectedTile.X, map.SelectedTile.Y);
                        map.HighLiteTilesWithPF(Opponent);
                        map.UpdateAllTiles(cam);
                    }
                }
                else
                if (MoveUpd == ButtonStates.ENTERED)
                {
                    Inf.Appear();
                    Inf.Text = "Перемещение/ближний бой";
                    _ShowInf = true;
                }

                if ((AttackUpd == ButtonStates.CLICKED || (Btn_Attack.Enabled && KeyBindings.CheckKeyReleased("KEY_ATTACKUNIT"))) && map.SelectedTile.X != -1)
                {
                    if (map.IsAttack)
                    {
                        map.IsAttack = false;
                        map.SetDefault();
                        map.UpdateAllTiles(cam);
                        map.CreatePathArrows(null, cam);
                    }
                    else
                    if ((map.GetTile(map.SelectedTile.X, map.SelectedTile.Y).TileContains == MapTiles.WITH_UNIT || map.GetTile(map.SelectedTile.X, map.SelectedTile.Y).TileContains == MapTiles.WITH_UNIT_AND_BUILDING) && map.GetTile(map.SelectedTile.X, map.SelectedTile.Y).UnitOnTile.side == Side.PLAYER && map.GetTile(map.SelectedTile.X, map.SelectedTile.Y).UnitOnTile.CanAttack)
                    {
                        Btn_EndTurn.Enabled  = false;
                        Btn_Move.Enabled     = false;
                        map.IsAttack         = true;
                        map.ActionStartPoint = new Point(map.SelectedTile.X, map.SelectedTile.Y);
                        map.HighLiteTilesWithEnemy();
                        map.UpdateAllTiles(cam);
                    }
                }
                else
                if (AttackUpd == ButtonStates.ENTERED)
                {
                    Inf.Appear();
                    Inf.Text = "Дальняя атака";
                    _ShowInf = true;
                }


                if (StatsUpd == ButtonStates.CLICKED || KeyBindings.CheckKeyReleased("KEY_STATS"))
                {
                    if (map.UI_VisibleState)
                    {
                        map.HideUnitStats();
                    }
                    else
                    {
                        map.ShowUnitStats();
                    }
                }
                else
                if (StatsUpd == ButtonStates.ENTERED)
                {
                    Inf.Appear();
                    Inf.Text = "Скрыть/показать\n характ. юнитов";
                    _ShowInf = true;
                }
                if (ChatUpd == ButtonStates.ENTERED)
                {
                    Inf.Appear();
                    Inf.Text = "Чат";
                    _ShowInf = true;
                }

                if (GameMenuUpd == ButtonStates.CLICKED)
                {
                    Menu.Show(this, Parent, null);
                }
                else
                if (GameMenuUpd == ButtonStates.ENTERED)
                {
                    Inf.Appear();
                    Inf.Text = "Игровое меню";
                    _ShowInf = true;
                }

                if (PlayerPoints.Update() == ButtonStates.ENTERED)
                {
                    Inf.Appear();
                    Inf.Text = "Очки/Необходимо\nдля победы";
                    _ShowInf = true;
                }
                if (OpponentPoints.Update() == ButtonStates.ENTERED)
                {
                    Inf.Appear();
                    Inf.Text = "Очки/Необходимо\nдля победы";
                    _ShowInf = true;
                }
                if (PlayerMoney.Update() == ButtonStates.ENTERED)
                {
                    Inf.Appear();
                    Inf.Text = "Ресурсы";
                    _ShowInf = true;
                }
                if (RoundTime.Update() == ButtonStates.ENTERED)
                {
                    Inf.Appear();
                    Inf.Text = "Время хода";
                    _ShowInf = true;
                }

                //*TEST
                if (EndTurnUpd == ButtonStates.CLICKED)
                {
                    //if(IsEnemyTurn)
                    //    SetPlayerTurn(1);
                    //else
                    //    SetEnemyTurn();
                    Parent.SetEnemyTurn();
                    CommandParser.SendCommandToGameServer(new string[] { "NEXTTURN" });
                    //DONE: Отправить на сервер команду смены хода
                }
                //*TEST

                if (!_ShowInf)
                {
                    Inf.Disappear();
                }
                else
                {
                    Inf.Position = new Vector2(MouseControl.X + 10, MouseControl.Y);
                }
                Inf.Update();
                if (map.ChoosedTileI != -1)
                {
                    var tmptile = map.GetTile(map.ChoosedTileI, map.ChoosedTileJ);
                    if (tmptile.UnitOnTile != null)
                    {
                        TileName.Text = tmptile.TileName + ", " + tmptile.UnitOnTile.Name;
                    }
                    else
                    {
                        TileName.Text = map.GetTile(map.ChoosedTileI, map.ChoosedTileJ).TileName;
                    }
                    TileName.Position = new Vector2(UI_BottomLeft.Position.X + UI_BottomLeft.Texture.Width / 2 - TileName.Font.MeasureString(TileName.Text).X / 2, UI_BottomLeft.Position.Y + 5);
                }
            }
        }
Пример #3
0
        public void Update(GameMenu menu)
        {
            //TODO: Esc bug меню
            if (menu.IsShown)
            {
                return;
            }
            if (IsLoginState)
            {
                if (LogIn.Update(MasterNI) == 1)
                {
                    IsLoginState     = false;
                    PlayerName.Text  = LogIn.PlayerName;
                    PlayerMoney.Text = LogIn.PlayerMoney.ToString();
                }
            }
            else
            {
                if (Home.Update() == ButtonStates.CLICKED)
                {
                    if (State != MenuState.HOME)
                    {
                        if (RollingBack.Position != RollingBack.DownPosition)
                        {
                            RollingBack.SetDown();
                        }
                        if (State == MenuState.COLLECTION)
                        {
                            collection.Hide();
                        }
                        else
                        if (State == MenuState.PLAY)
                        {
                            play.Hide();
                        }
                        State = MenuState.HOME;
                    }
                }
                if (Play.Update() == ButtonStates.CLICKED)
                {
                    if (State != MenuState.PLAY)
                    {
                        RollingBack.SetUp();
                        if (State == MenuState.COLLECTION)
                        {
                            collection.Hide();
                        }
                        State = MenuState.PLAY;
                    }
                }
                if (Collection.Update() == ButtonStates.CLICKED)
                {
                    if (State != MenuState.COLLECTION)
                    {
                        if (State == MenuState.PLAY)
                        {
                            play.Hide();
                        }
                        RollingBack.SetUp();
                        State = MenuState.COLLECTION;
                    }
                }
                if (OpenCardPack.Update() == ButtonStates.CLICKED)
                {
                    //    RollingBack.SetUp();
                    //    if (State == MenuState.COLLECTION)
                    //        collection.Hide();
                }
                if (Options.Update() == ButtonStates.CLICKED)
                {
                    menu.Show(null, null, this);
                    if (State == MenuState.COLLECTION)
                    {
                        collection.Hide();
                    }
                    else
                    if (State == MenuState.PLAY)
                    {
                        play.Hide();
                    }
                }

                if (State == MenuState.COLLECTION)
                {
                    if (!RollingBack.IsMoving && !collection.IsShown)
                    {
                        collection.Show(1, true);
                    }
                }
                if (State == MenuState.PLAY)
                {
                    if (!RollingBack.IsMoving && !play.IsShown)
                    {
                        play.Show();
                    }
                }
            }
            RollingBack.Update();
            collection.Update();
            play.Update();

            if (State == MenuState.CONNECTING)
            {
                play.Update();
                if (!GameNI.IsConnected)
                {
                    GameNI.ConnectTo(GameIP);
                }
                if (GameNI.IsConnected)
                {
                    Log.SendMessage("Подключено");
                    CommandParser.InitGameServer(GameNI);
                    State = MenuState.HOME;
                    play.IsSearchState = false;
                    play.ShowCancelButton();
                    Parent.CreateGame(GameNI);
                }
            }

            string[] CN;
            CommandParser.UpdateMasterServer(out CN);
            if (CN != null)
            {
                if (CN[0] == "CONNECT")
                {
                    GameNI = new NetworkInterface();
                    State  = MenuState.CONNECTING;
                    GameIP = CN[1];
                    play.HideCancelButton();
                }
            }
        }
Пример #4
0
        public void Update(GameMenu Menu)
        {
            UpdateGameObjects(Menu);

            //Window.Title = Convert.ToString(Hand.Cards[0].Layer) + " " + Convert.ToString(Hand.Cards[1].Layer) + " " + Convert.ToString(Hand.Cards[2].Layer);

            // TODO: Add your update logic here
            //Window.Title = Convert.ToString(Mouse.GetState().X) + "||" + Convert.ToString(Mouse.GetState().Y);
            //Window.Title = Convert.ToString(ScreenWidth) + "||" + Convert.ToString(ScreenHeight);
            //Window.Title = Convert.ToString(Mouse.GetState().X) + "||" + Convert.ToString(Mouse.GetState().Y) + "|---|" + Convert.ToString(arrow.EndPoint.X) + "||" + Convert.ToString(arrow.EndPoint.Y) + "|---|" + Convert.ToString(arrow._Rotation);
            watch.Stop();
            //Window.Title = CoordsConvert.WindowToWorldCoords(new Vector2(Mouse.GetState().X, Mouse.GetState().Y), cam).ToString();
            //if (MouseControl.IsLeftBtnClicked)
            //    Window.Title = "Left";
            //if (MouseControl.IsRightBtnClicked)
            //    Window.Title = "Right";
            //Window.Title = Hand.IsClick.ToString();
            //Window.Title = Map.Tiles[0][0].NotSelectedFrame.ToString() + " || " + Map.Tiles[1][0].NotSelectedFrame.ToString();

            /*PathFindingTest*/
            //            var Til = Map.GetTileIJByCoords(new Vector2(MouseControl.X, MouseControl.Y));
            //            List<Point> LastList = null;
            //            if (Til != null)
            //            {
            //                int PL;
            //                var TmpList = Map.PathFinding(1, 0, Til[0], Til[1], out PL);
            //                Map.CreatePathArrows(TmpList);
            //                if (TmpList != LastList)
            //                {
            //                    LastList = new List<Point>(TmpList);
            //                    Window.Title = PL.ToString();
            //                }
            //            }
            /*PathFindingTest End*/
            watch.Reset();
            UpdateCamera();
            //cam.Position += new Vector2(0.5f, 0.5f);
            //cam.Zoom = 0.25f;
            //cam.Rotation -= 0.01f;

            string[] CN;
            CommandParser.UpdateGameServer(out CN);
            if (CN != null)
            {
                if (CN[0] == "WIN")
                {
                    IsPlayerTurn = false;
                    UI.SetEndGame(true);
                }
                else
                if (CN[0] == "LOSE" || CN[0] == "DRAW")
                {
                    IsPlayerTurn = false;
                    UI.SetEndGame(false);
                }
                else
                if (CN[0] == "REPLACE")
                {
                    if (CN.Length == 1)
                    {
                        UI.ReplaceCards(null);
                    }
                    else
                    {
                        var CardsToReplace = new int[CN.Length - 1];
                        for (var i = 1; i < CN.Length; i++)
                        {
                            CardsToReplace[i - 1] = Convert.ToInt32(CN[i]);
                        }
                        UI.ReplaceCards(CardsToReplace);
                    }
                }
                else
                if (CN[0] == "START")
                {
                    UI.IterationReset();
                }
                else
                if (CN[0] == "TURN")
                {
                    foreach (var Tiles in Map.GetMap())
                    {
                        foreach (var Tile in Tiles)
                        {
                            if (Tile != null)
                            {
                                if (Tile.UnitOnTile != null)
                                {
                                    Tile.UnitOnTile.MovePointsLeft = Tile.UnitOnTile.Speed;
                                    Tile.UnitOnTile.CanAttack      = true;
                                }
                            }
                        }
                    }
                    if (CN[1] == "ENEMY")
                    {
                        UI.SetEnemyTurn();
                        UI.Opponent_Points = Convert.ToInt32(CN[2]);
                        IsPlayerTurn       = false;
                    }
                    else
                    {
                        var CardsToChoose = new int[CN.Length - 4];
                        UI.Player_Points = Convert.ToInt32(CN[2]);
                        UI.Player_Money  = Convert.ToInt32(CN[3]);
                        if (UI.Player_Money_Inc < 10)
                        {
                            UI.Player_Money_Inc += 1;
                        }
                        for (var i = 4; i < CN.Length; i++)
                        {
                            CardsToChoose[i - 4] = Convert.ToInt32(CN[i]);
                        }
                        UI.SetPlayerTurn(Convert.ToInt32(CN[1]), CardsToChoose);
                        IsPlayerTurn = true;
                    }
                }
                else
                if (CN[0] == "CHOOSE")
                {
                    if (CN[1] == "OK")
                    {
                        UI.ChooseCards(Hand);
                    }
                }
                else
                if (CN[0] == "SPAWN")
                {
                    if (IsPlayerTurn)
                    {
                        SetPlayerTurn();
                        UI.Player_Money -= GameContent.UnitCards[Convert.ToInt32(CN[2])].Cost;
                        Hand.CalculateCardPosition(20, true);
                    }
                    if (CN[1] == "ALLIED")
                    {
                        Map.GetTile(Convert.ToInt32(CN[3]), Convert.ToInt32(CN[4])).SpawnUnit(new Unit(Vector2.Zero, GameContent.UnitCards[Convert.ToInt32(CN[2])].UnitTexture, GameContent.UI_Info_Allied, GameContent.UI_InfoFont, Color.White, 392, 20, GameContent.UnitCards[Convert.ToInt32(CN[2])].Name, GameContent.UnitCards[Convert.ToInt32(CN[2])].Speed, GameContent.UnitCards[Convert.ToInt32(CN[2])].Damage, GameContent.UnitCards[Convert.ToInt32(CN[2])].HP, GameContent.UnitCards[Convert.ToInt32(CN[2])].Armor, GameContent.UnitCards[Convert.ToInt32(CN[2])].AttackRadius, Side.PLAYER, GameContent.UnitCards[Convert.ToInt32(CN[2])].UnitAttackScript, UnitAttEngine, new Point(Convert.ToInt32(CN[3]), Convert.ToInt32(CN[4])), new Animation(8, 17, false), 0.4f), PlayerSide, Map.UI_VisibleState);
                    }
                    else
                    {
                        Map.GetTile(Convert.ToInt32(CN[3]), Convert.ToInt32(CN[4])).SpawnUnit(new Unit(Vector2.Zero, GameContent.UnitCards[Convert.ToInt32(CN[2])].UnitTexture, GameContent.UI_Info_Enemy, GameContent.UI_InfoFont, Color.White, 392, 20, GameContent.UnitCards[Convert.ToInt32(CN[2])].Name, GameContent.UnitCards[Convert.ToInt32(CN[2])].Speed, GameContent.UnitCards[Convert.ToInt32(CN[2])].Damage, GameContent.UnitCards[Convert.ToInt32(CN[2])].HP, GameContent.UnitCards[Convert.ToInt32(CN[2])].Armor, GameContent.UnitCards[Convert.ToInt32(CN[2])].AttackRadius, Side.OPPONENT, GameContent.UnitCards[Convert.ToInt32(CN[2])].UnitAttackScript, UnitAttEngine, new Point(Convert.ToInt32(CN[3]), Convert.ToInt32(CN[4])), new Animation(8, 17, false), 0.4f), (PlayerSide == MapZones.RIGHT) ? MapZones.LEFT : MapZones.RIGHT, Map.UI_VisibleState);
                    }
                }
                else
                if (CN[0] == "MOVE")
                {
                    if (IsPlayerTurn)
                    {
                        SetPlayerTurn();
                    }
                    var          first = CN[1].Split();
                    var          last  = CN[2].Split();
                    int          PL;
                    List <Point> Marked;

                    var point = new Point(Convert.ToInt32(first[0]), Convert.ToInt32(first[1]));
                    for (var i = 0; i < Map.CPTiles.Count(); i++)
                    {
                        if (Map.CPTiles[i] == point)
                        {
                            if (Map.GetTile(Convert.ToInt32(first[0]), Convert.ToInt32(first[1])).UnitOnTile.side == Side.PLAYER)
                            {
                                Map.SetCPState(i, CapturePointStates.NEUTRAL);
                                UI.CPInfos[i].SetState(CapturePointStates.NEUTRAL);
                                UI.Player_Points_Inc -= 1;
                            }
                            else
                            {
                                Map.SetCPState(i, CapturePointStates.NEUTRAL);
                                UI.CPInfos[i].SetState(CapturePointStates.NEUTRAL);
                                UI.Opponent_Points_Inc -= 1;
                            }
                        }
                    }

                    point = new Point(Convert.ToInt32(last[0]), Convert.ToInt32(last[1]));
                    for (var i = 0; i < Map.CPTiles.Count(); i++)
                    {
                        if (Map.CPTiles[i] == point)
                        {
                            if (Map.GetTile(Convert.ToInt32(first[0]), Convert.ToInt32(first[1])).UnitOnTile.side == Side.PLAYER)
                            {
                                Map.SetCPState(i, CapturePointStates.ALLIED);
                                UI.CPInfos[i].SetState(CapturePointStates.ALLIED);
                                UI.Player_Points_Inc += 1;
                            }
                            else
                            {
                                Map.SetCPState(i, CapturePointStates.ENEMY);
                                UI.CPInfos[i].SetState(CapturePointStates.ENEMY);
                                UI.Opponent_Points_Inc += 1;
                            }
                            break;
                        }
                    }

                    Map.UnitMove(Map.PathFinding(Convert.ToInt32(first[0]), Convert.ToInt32(first[1]), Convert.ToInt32(last[0]), Convert.ToInt32(last[1]), Map.GetTile(Convert.ToInt32(first[0]), Convert.ToInt32(first[1])).UnitOnTile.MovePointsLeft, out PL, out Marked, OpponentSide), Convert.ToInt32(CN[3]));
                }
                else
                if (CN[0] == "ATTACK")
                {
                    if (IsPlayerTurn)
                    {
                        SetPlayerTurn();
                    }

                    bool IsPlayer = false;
                    if (Map.GetTile(Convert.ToInt32(CN[3]), Convert.ToInt32(CN[4])).UnitOnTile.side == Side.PLAYER)
                    {
                        IsPlayer = true;
                    }

                    Map.GetTile(Convert.ToInt32(CN[1]), Convert.ToInt32(CN[2])).UnitOnTile.Attack(Map.GetTile(Convert.ToInt32(CN[3]), Convert.ToInt32(CN[4])).UnitOnTile, Convert.ToInt32(CN[5]));

                    if (Map.GetTile(Convert.ToInt32(CN[3]), Convert.ToInt32(CN[4])).UnitOnTile.HP <= Convert.ToInt32(CN[5]))
                    {
                        var point = new Point(Convert.ToInt32(CN[3]), Convert.ToInt32(CN[4]));
                        for (var i = 0; i < Map.CPTiles.Count(); i++)
                        {
                            if (Map.CPTiles[i] == point)
                            {
                                Map.SetCPState(i, CapturePointStates.NEUTRAL);
                                UI.CPInfos[i].SetState(CapturePointStates.NEUTRAL);
                                if (IsPlayer)
                                {
                                    UI.Player_Points_Inc -= 1;
                                }
                                else
                                {
                                    UI.Opponent_Points_Inc -= 1;
                                }
                                break;
                            }
                        }
                    }
                }
                //if(CN[0] == "2")
                //{
                //	//Map.GetTile(Convert.ToInt32(CN[1]), Convert.ToInt32(CN[2])).SpawnUnit(new Unit(Vector2.Zero, GameContent.UnitTextures[0], GameContent.UI_Info_Allied, GameContent.UI_InfoFont, Color.White, 392, 20, 5, 3, 6, 1, 2, Side.PLAYER, GameContent.UnitAttackScripts[0], UnitAttEngine, new Point(Convert.ToInt32(CN[1]), Convert.ToInt32(CN[2])), new Animation(8, 17, false), 0.4f), MapZones.RIGHT, Map.UI_VisibleState);
                //}
            }
        }