Exemplo n.º 1
0
        private void InitAssets()
        {
            #region Setup Variables
            startAmount = Constants.ShipAmount;
            Constants.playerSpritePath = String.Format("{0}{1}{2}", Constants.playerBasePath, Constants.SelectedShip, Constants.imageExtension);
            Constants.enemySpritePath = String.Format("{0}{1}{2}", Constants.enemyBasePath, Constants.SelectedEnemy, Constants.imageExtension);

            Constants.MenuBackgroundPath = String.Format("{0}{1}{2}", Constants.BackgroundBasePath, Constants.SelectedMenuBackground, Constants.imageExtension);
            Constants.GameBackgroundPath = String.Format("{0}{1}{2}", Constants.BackgroundBasePath, Constants.SelectedGameBackground, Constants.imageExtension);
            #endregion

            #region Setup Screen
            gameCanvas = new Canvas();
            gameCanvas.Height = Constants.ScreenHeight;
            gameCanvas.Width = Constants.ScreenWidth;
            gameCanvas.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            gameCanvas.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            this.Content = gameCanvas;
            #endregion

            #region Setup States
            Menu = new MenuState(this);
            Help = new HelpState(this);
            Story = new StoryState(this);
            ShipSelection = new ShipSelectionState(this);
            Play = new GameState(this, timeToPlay, Constants.ShipAmount);
            State.SetState(Menu);
            #endregion

            #region Setup Timers
            TimeTick = 1000 / Constants.fps;
            GameTick = new DispatcherTimer();
            GameTick.Interval = TimeSpan.FromMilliseconds(TimeTick);
            GameTick.Tick += GameLoop;

            PlayTime = new DispatcherTimer();
            PlayTime.Interval = TimeSpan.FromSeconds(1);
            PlayTime.Tick += PlayTime_Tick;

            #endregion
        }
 public static void SetState(State newState)
 {
     currentState = newState;
 }
Exemplo n.º 3
0
 public void GameReset()
 {
     gameCanvas.Children.Clear();
     //Gabrage collector will clean this.
     Play = null;
     Menu = null;
     Help = null;
 }