//Start animation that replace the current menu with the next. private void ToNextMenu(GameMenu nextGameMenu) { GameMenu oldGameMenu = _menuesStack.Peek(); ReplaceMenus animate = new ReplaceMenus(oldGameMenu, nextGameMenu) { TimeToReach = PANEL_TIME_TO_LEAVE, WindowSize = SizeVector, AnimateDirection = Direction.Up }; animate.ActionInEnd += () => { _menuesStack.Push(nextGameMenu); Animations.Remove(animate); }; Animations.Add(animate); animate.StartAnimate(); }
//Start animation that replace the current menu with the old one. private void ToOldMenu(Action doInEnd = null) { GameMenu currentGameMenu = _menuesStack.Pop(); GameMenu oldGameMenu = _menuesStack.Peek(); ReplaceMenus animate = new ReplaceMenus(currentGameMenu, oldGameMenu) { TimeToReach = PANEL_TIME_TO_LEAVE, WindowSize = SizeVector, AnimateDirection = Direction.Down }; animate.ActionInEnd += () => { Animations.Remove(animate); doInEnd?.Invoke(); }; Animations.Add(animate); animate.StartAnimate(); }