public void Update() { var Upd = base.Update(); if (Visible) { if (MouseControl.IsLeftBtnClicked) { if (Upd == ButtonStates.CLICKED) { if (!Focused) { Focused = true; base.Text += "|"; } } else if (Focused) { Focused = false; base.Text = base.Text.Remove(base.Text.Length - 1); } } if (Focused) { var IsKeyFinded = false; string Symbol = ""; if (RealText.Length < MaxLength) { for (var i = 48; i < 58; i++) { if (KeyBindings.CheckKeyReleased((Keys)i) == true) { IsKeyFinded = true; Symbol = char.ConvertFromUtf32(i); break; } } if (!IsKeyFinded) { for (var i = 65; i < 91; i++) { if (KeyBindings.CheckKeyReleased((Keys)i) == true) { IsKeyFinded = true; Symbol = char.ConvertFromUtf32(i); break; } } } if (!IsKeyFinded) { for (var i = 96; i < 106; i++) { if (KeyBindings.CheckKeyReleased((Keys)i) == true) { IsKeyFinded = true; Symbol = char.ConvertFromUtf32(i - 48); break; } } } if (IsKeyFinded) { base.Text = base.Text.Remove(base.Text.Length - 1); if (!(KeyBindings.CheckKeyPressed(Keys.LeftShift) || KeyBindings.CheckKeyPressed(Keys.RightShift))) { Symbol = Symbol.ToLower(); } RealText += Symbol; if (IsMasked) { base.Text += "*"; } else { base.Text += Symbol; } base.Text += "|"; } } if (KeyBindings.CheckKeyReleased(Keys.Back)) { base.Text = base.Text.Remove(base.Text.Length - 1); if (base.Text.Length > 0) { base.Text = base.Text.Remove(base.Text.Length - 1); } if (RealText.Length > 0) { RealText = RealText.Remove(RealText.Length - 1); } base.Text += "|"; } } } }
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); } } }
public void Update(MainUI UI, GameState State, MainMenu menu) { if (KeyBindings.CheckKeyReleased("KEY_MENU")) { if (IsOptions) { ChangeOptionsState(); } else { if (_IsShown) { Hide(UI, State, menu); } else { Show(UI, State, menu); } } } if (_IsShown) { if (IsOptions) { if (Resolutions.Update() == false) { if (ScreenMode.Update() == ButtonStates.CLICKED) { if (Config.FullScreen) { Config.FullScreen = false; ScreenMode.Text = "Оконный"; } else { Config.FullScreen = true; ScreenMode.Text = "Полноэкранный"; } Parent.ApplyChanges(); } } } else { if (Continue.Update() == ButtonStates.CLICKED) { Hide(UI, State, menu); } else if (Surrender.Update() == ButtonStates.CLICKED) { //DONE: Surrender if (Parent.GlobalState == GlobalGameState.Game) { State.Surrender(); } Hide(UI, State, menu); } else if (Options.Update() == ButtonStates.CLICKED) { ChangeOptionsState(); } else if (Quit.Update() == ButtonStates.CLICKED) { if (CommandParser.GameServerInterface != null) { CommandParser.GameServerInterface.Disconnect(); } if (CommandParser.MasterServerInterface != null) { CommandParser.MasterServerInterface.Disconnect(); } Parent.Exit(); } } } }