Ejemplo n.º 1
0
        public void Hide(MainUI UI, GameState State, MainMenu menu)
        {
            _IsShown            = false;
            MenuCaption.Visible = false;
            MainBack.Visible    = false;
            Continue.Visible    = false;
            Surrender.Visible   = false;
            Options.Visible     = false;
            Quit.Visible        = false;

            if (UI != null)
            {
                UI.EnableUI();
            }
            if (State != null)
            {
                if (State.IsPlayerTurn)
                {
                    State.SetPlayerTurn();
                }
            }
            if (menu != null)
            {
                menu.UnlockClicking();
            }
            MouseControl.Reset();
        }
Ejemplo n.º 2
0
 public void Update(ref bool IsMouseHandled, Map TiledMap, Camera cam, float CardAppearPos, bool IsPlayerTurn, MapZones PlayerZone, GameState state, int PlayerMoney)
 {
     ChooseArrow.Update();
     for (var i = 0; i < KilledNonTargetCards.Count; i++)
     {
         if (KilledNonTargetCards[i] != null)
         {
             if (KilledNonTargetCards[i].CurrAnimName == "NONE")
             {
                 KilledNonTargetCards.RemoveAt(i);
                 i--;
             }
             else
             {
                 KilledNonTargetCards[i].UpdateAnims();
             }
         }
     }
     if (_ChoosedCard == -1)
     {
         for (var i = 0; i < Cards.Count; i++)
         {
             if (Cards[i] != null)
             {
                 Cards[i].MoveUpdate();
                 Cards[i].UpdateAnims();
                 if (!IsMouseHandled && Cards[i].Update() != ButtonStates.NONE)
                 {
                     IsMouseHandled = true;
                     _ChoosedCard   = i;
                 }
                 else
                 {
                     Cards[i].StopAnimation(true);
                     //Cards[i].IterationReset();
                     Cards[i].Down();
                 }
             }
         }
     }
     else
     if (Cards[_ChoosedCard] != null)
     {
         IsMouseHandled = true;
         for (var i = 0; i < Cards.Count; i++)
         {
             Cards[i].MoveUpdate();
             Cards[i].UpdateAnims();
         }
         if (MouseControl.IsLeftBtnClicked)
         {
             if (IsClick)
             {
                 IsClick = false;
                 Cards[_ChoosedCard].IsPressed = false;
             }
             else
             {
                 IsClick = true;
                 Cards[_ChoosedCard].IsPressed = true;
             }
         }
         var Upd = Cards[_ChoosedCard].Update();
         if (IsPlayerTurn && (IsClick || Upd == ButtonStates.PRESSED))
         {
             CalculateCardPosition(10, true, _ChoosedCard);
             Cards[_ChoosedCard].Down();
             Cards[_ChoosedCard].SetUpLayer();
             Cards[_ChoosedCard].Position = new Vector2(MouseControl.X - (Cards[_ChoosedCard].FrameSize.X * 0.25f), MouseControl.Y - (Cards[_ChoosedCard].FrameSize.Y * 0.25f));
             if (MouseControl.Y < CardAppearPos)
             {
                 IsMouseHandled = false;
                 if (Cards[_ChoosedCard].IsTargeted)
                 {
                     if (!TiledMap.IsAnimsChanged)
                     {
                         TiledMap.ChangeTilesAnims(2, 1, new Animation(1, 1, true), TiledMap.GetTilesByAllowedZones(Cards[_ChoosedCard].AllowedZones, Cards[_ChoosedCard].AllowedTiles));
                     }
                     Cards[_ChoosedCard].Disappear();
                     ChooseArrow.Appear();
                     ChooseArrow.BeginPoint = new Vector2((300 + CurrentScreenRes.X) / 2, CurrentScreenRes.Y + 20);
                     ChooseArrow.EndPoint   = new Vector2(MouseControl.X, MouseControl.Y);
                 }
                 else
                 {
                     Cards[_ChoosedCard].PlayAnimation("Choosed");
                 }
             }
             else
             {
                 if (Cards[_ChoosedCard].IsTargeted)
                 {
                     TiledMap.SetDefault();
                     ChooseArrow.Disappear();
                     Cards[_ChoosedCard].Appear();
                     Cards[_ChoosedCard].IsDisappearing = false;
                 }
                 else
                 {
                     Cards[_ChoosedCard].CurrentFrame = 0;
                 }
             }
         }
         else
         if (Upd != ButtonStates.NONE)
         {
             if (Upd == ButtonStates.CLICKED)
             {
                 Cards[_ChoosedCard].Down();
                 if (Cards[_ChoosedCard].IsTargeted)
                 {
                     ChooseArrow.Disappear();
                     Cards[_ChoosedCard].Appear();
                     Cards[_ChoosedCard].IsDisappearing = false;
                 }
                 else
                 {
                     Cards[_ChoosedCard].StopAnimation(true);
                 }
                 if (MouseControl.Y < CardAppearPos)
                 {
                     var  Tmp = TiledMap.GetTileIJByCoords(MouseControl.MouseToWorldCoords(cam));
                     Tile TmpTile;
                     if (Tmp != null)
                     {
                         TmpTile = TiledMap.GetTile(Tmp[0], Tmp[1]);
                     }
                     else
                     {
                         TmpTile = null;
                     }
                     if (Cards[_ChoosedCard].IsTargeted)
                     {
                         if (TmpTile != null && PlayerMoney >= Convert.ToInt32(Cards[_ChoosedCard].MoneyInfo.Text) && TiledMap.CheckTileAllowed(new Point(Tmp[0], Tmp[1]), PlayerZone, Cards[_ChoosedCard].AllowedTiles))        //DONE: Убрать костыль TmpTile.NotSelectedFrame != 0, ввести тип Player для поиска правильной стороны
                         {
                             //TEST: Юниты
                             //TmpTile.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, AttScript, ScrForUnit, new Point(Tmp[0], Tmp[1]), new Animation(8, 17, false), 0.4f), MapZones.RIGHT, TiledMap.UI_VisibleState);
                             CommandParser.SendCommandToGameServer(new string[] { "SPAWN", _ChoosedCard.ToString(), Tmp[0].ToString(), Tmp[1].ToString() });
                             state.SetEnemyTurn();
                             Cards.RemoveAt(_ChoosedCard);
                         }
                         else
                         {
                             CalculateCardPosition(10, true);
                         }
                     }
                     else
                     {
                         Cards[_ChoosedCard].StopAnimation(true);
                         KilledNonTargetCards.Add(new Card(Cards[_ChoosedCard]));
                         KilledNonTargetCards.Last().Disappear();
                         Cards.RemoveAt(_ChoosedCard);
                     }
                     TiledMap.SetDefault();
                 }
                 else
                 {
                     CalculateCardPosition(10, true);
                 }
                 _ChoosedCard = -1;
             }
         }
         else
         {
             Cards[_ChoosedCard].Down();
             //Cards[_ChoosedCard].IterationReset();
             _ChoosedCard = -1;
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (Window.ClientBounds.Width != ScreenWidth || Window.ClientBounds.Height != ScreenHeight)
            {
                ScreenWidth  = Window.ClientBounds.Width; // TODO: ON RESIZE
                ScreenHeight = Window.ClientBounds.Height;
                if (gameState != null)
                {
                    gameState.Resize(ScreenWidth, ScreenHeight);
                }
            }

            MouseControl.Update();
            KeyBindings.Update();
            if (mainMenu != null && _GlobalState == GlobalGameState.MainMenu)
            {
                Menu.Update(null, null, mainMenu);
                mainMenu.Update(Menu);
            }
            if (gameState != null && _GlobalState == GlobalGameState.Game)
            {
                Menu.Update(gameState.UI, gameState, mainMenu);
                gameState.Update(Menu);
            }
            else
            {
                Menu.Update(null, gameState, mainMenu);
            }

            //Window.Title = gameState.watch.Elapsed.ToString() + "|--|" + Convert.ToString(Mouse.GetState().X) + "||" + Convert.ToString(Mouse.GetState().Y) + "|ZOOM|" + gameState.cam.Zoom.ToString() + "|POS|" + gameState.cam.Position.ToString();
            Window.Title = "|--|" + Convert.ToString(Mouse.GetState().X) + "||" + Convert.ToString(Mouse.GetState().Y);

            LoadingBr.UpdateAnims();
            if (IsLoadToGame)
            {
                LoadingIterations++;
                if (LoadingIterations == 60)
                {
                    _GlobalState = GlobalGameState.Game;
                    LoadingBr.ScreenBrUp();
                }
                if (LoadingIterations == 120)
                {
                    IsLoadToGame = false;
                }
            }
            if (IsLoadToMenu)
            {
                LoadingIterations++;
                if (LoadingIterations == 60)
                {
                    _GlobalState = GlobalGameState.MainMenu;
                    mainMenu.ReturnFromGame();
                    gameState = null;
                    LoadingBr.ScreenBrUp();
                }
                if (LoadingIterations == 120)
                {
                    IsLoadToMenu = false;
                }
            }
            base.Update(gameTime);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Обновление кнопки
 /// </summary>
 /// <param name="DontUpdBtnAnims"> True - Не обновлять анимации</param>
 /// <returns></returns>
 public virtual ButtonStates Update(bool DontUpdBtnAnims = false, Camera cam = null)
 {
     if (Visible)
     {
         if (!Enabled)
         {
             CurrentFrame = DisabledFrame;
             return(ButtonStates.NONE);
         }
         //Если отображение разрешено
         //Определить пересечение с курсором
         LastIntersectionCheckResult = IntersectionCheckResult;
         if (cam == null)
         {
             IntersectionCheckResult = Intersector.IntersectionCheck(new Vector2(MouseControl.X, MouseControl.Y));
         }
         else
         {
             IntersectionCheckResult = Intersector.IntersectionCheck(MouseControl.MouseToWorldCoords(cam));
         }
         if (IntersectionCheckResult)
         {
             if (MouseControl.LeftBtn == MouseButtonStates.PRESSED)
             {
                 if (!DontUpdBtnAnims)
                 {
                     StopAnimation(true, NotSelectedFrame);
                     CurrentFrame = ClickedFrame;
                 }
                 return(ButtonStates.PRESSED);
             }
             else
             if (MouseControl.LeftBtn == MouseButtonStates.RELEASED)
             {
                 return(ButtonStates.CLICKED);
             }
             else
             {
                 if (!DontUpdBtnAnims)
                 {
                     if (CurrAnim == null)
                     {
                         PlayAnimation("Selected");
                     }
                 }
                 return(ButtonStates.ENTERED);
             }
         }
         if (!DontUpdBtnAnims)
         {
             StopAnimation(true, NotSelectedFrame);
             CurrentFrame = NotSelectedFrame;
         }
         return(ButtonStates.NONE);
     }
     else
     {
         //Если отображение запрещено
         if (!DontUpdBtnAnims)
         {
             if (CurrAnim != null)
             {
                 StopAnimation(true, NotSelectedFrame);
             }
         }
         return(ButtonStates.NONE);
     }
 }