Exemplo n.º 1
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
            _spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend,
                               SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise);
            Simpsons.AlwaysDraw(_spriteBatch);
            switch (Simpsons.State)
            {
            case Simpsons.States.Loading:
                Simpsons.LoadingDraw(_spriteBatch);
                break;

            case Simpsons.States.Saves:
                Simpsons.DisplayGamesDraw(_spriteBatch, Window);
                break;

            case Simpsons.States.Run:
                Simpsons.RunDraw(_spriteBatch, gameTime);
                break;

            case Simpsons.States.Menu:
                Simpsons.MenuDraw(_spriteBatch, Window);
                break;

            case Simpsons.States.Store:
                Simpsons.StoreDraw(_spriteBatch);
                break;
            }
            _spriteBatch.DrawString(FontHandler.Fonts["Fonts/Reno14"], "Simpsons(v0.2.0)", new Vector2(0, 880), Color.White * 0.5f);
            _spriteBatch.End();
            base.Draw(gameTime);
        }
Exemplo n.º 2
0
 protected override void LoadContent()
 {
     _spriteBatch = new SpriteBatch(GraphicsDevice);
     Simpsons.LoadPreContent(Content, Window, GraphicsDevice);
     //Start up new thread to not block Draw thread
     ThreadPool.QueueUserWorkItem(state =>
     {
         Simpsons.LoadContent(Content, Window);
         isLoaded = true;
     });
 }
Exemplo n.º 3
0
        protected override void Update(GameTime gameTime)
        {
            Simpsons.AlwaysUpdate(Window, gameTime);
            switch (Simpsons.State)
            {
            case Simpsons.States.Loading:
                if (InputHandler.AnyPressed() && isLoaded)
                {
                    Simpsons.State = Simpsons.States.Menu;
                }
                else
                {
                    Simpsons.State = Simpsons.LoadingUpdate(gameTime, isLoaded);
                }
                break;

            case Simpsons.States.Run:
                Simpsons.State = Simpsons.RunUpdate(Window, gameTime);
                break;

            case Simpsons.States.GameStart:
                Simpsons.State = Simpsons.StartGame(null);
                break;

            case Simpsons.States.Saves:
                Simpsons.State = Simpsons.DisplayGamesUpdate(gameTime);
                break;

            case Simpsons.States.Quit:
                Simpsons.ExitGame();
                Exit();
                break;

            case Simpsons.States.Store:
                Simpsons.State = Simpsons.StoreUpdate(gameTime);
                break;

            case Simpsons.States.Menu:
                Simpsons.State = Simpsons.MenuUpdate(gameTime, Window);
                break;
            }
            // TODO: Add your update logic here

            base.Update(gameTime);
        }
Exemplo n.º 4
0
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            graphics.PreferredBackBufferHeight      = 900;
            graphics.PreferredBackBufferWidth       = 1600;
            graphics.SynchronizeWithVerticalRetrace = false;
            IsFixedTimeStep   = false;
            TargetElapsedTime = TimeSpan.FromMilliseconds(1000.0f / 144);
            //graphics.IsFullScreen = true;
            graphics.ApplyChanges();
            //Intialize
            ResolutionUtils.SetResolution(1600, 900);
            Simpsons.State = Simpsons.States.Loading;
            Simpsons.Initialize();


            base.Initialize();
        }
Exemplo n.º 5
0
        public int Update(GameTime gameTime)
        {
            float delta = (float)gameTime.ElapsedGameTime.TotalSeconds;

            /*frame++;
             * frame %= 30;*/
            frame += delta;
            frame %= 0.8f;
            if (frame <= 0.4)
            {
                selectedColor = new Color(159, 255, 111);
            }
            else
            {
                selectedColor = Color.Yellow;
            }
            Timer(gameTime);
            if (!IsChangingState)
            {
                allowKeyboard = MouseHandler.CheckIfSameSpot();
                if (Opacity + (0.05f * delta * 60) <= 1.0f)
                {
                    Opacity += (0.05f * delta * 60);
                }
                if (InputHandler.Press(Keys.Down) && allowKeyboard)
                {
                    if (selected < displayGamesItems.Count - 1)
                    {
                        selected++;
                    }
                }
                if (InputHandler.Press(Keys.Up) && allowKeyboard)
                {
                    if (selected > 0)
                    {
                        selected--;
                    }
                }
                if (InputHandler.Press(Keys.D) && allowKeyboard)
                {
                    if (displayGamesItems.Any())
                    {
                        GameHandler _gameHandler = displayGamesItems[selected].Game;
                        Simpsons.RemoveGameHandler(_gameHandler);
                        for (int i = selected; i < displayGamesItems.Count; i++)
                        {
                            var       tempRect = displayGamesItems[i].Rectangle;
                            Rectangle rect     = new Rectangle(tempRect.X, tempRect.Y - 35, tempRect.Width, tempRect.Height);
                            displayGamesItems[i].Rectangle = rect;
                        }



                        displayGamesItems.RemoveAt(selected);
                        _durationOpacity = 1f;
                        _deleteMessage   = $"Game {_gameHandler.GameID} deleted";

                        if (displayGamesItems.ElementAtOrDefault(selected) == null)
                        {
                            selected--;
                        }

                        if (displayGamesItems.Count == 0)
                        {
                            selected = 0;
                        }
                    }
                }
                //Checks if user presses enter
                //or if the user presses mouse1 and is hovering over the correct object
                if (displayGamesItems.Any())
                {
                    if (InputHandler.Press(Keys.Enter) || (MouseHandler.MouseState.LeftButton == ButtonState.Pressed &&
                                                           displayGamesItems[selected].Rectangle.Contains(MouseHandler.MouseState.X, MouseHandler.MouseState.Y)))
                    {
                        return((int)Simpsons.StartGame(displayGamesItems[selected].Game));
                    }
                }

                if (InputHandler.GoBackPressed())
                {
                    IsChangingState = true;
                }

                for (int i = 0; i < displayGamesItems.Count; i++)
                {
                    if (displayGamesItems[i].Rectangle.
                        Contains(MouseHandler.MouseState.X, MouseHandler.MouseState.Y) &&
                        !allowKeyboard)
                    {
                        selected = i;
                    }
                }
            }
            if (IsChangingState)
            {
                if (!IsOpacityDone)
                {
                    Opacity -= (0.1f * delta * 60);
                }
                if (Opacity <= 0 && !IsOpacityDone)
                {
                    IsOpacityDone = true;
                }
                if (IsOpacityDone)
                {
                    return(StartStateChange(15, 3, 0, 400, gameTime));
                }
            }
            return((int)Simpsons.States.Saves);
        }
Exemplo n.º 6
0
        public int Update(GameTime gameTime)
        {
            float delta = (float)gameTime.ElapsedGameTime.TotalSeconds;

            UpdatePriceColor();
            switch (stateTracker)
            {
            case StateTracker.Left:
                foreach (StoreItem item in MainStore[selectedy])
                {
                    item.X += 5 * delta * 60;
                }
                if (MainStore[selectedy][selected[selectedy]].X >= TargetX)
                {
                    stateTracker = StateTracker.None;
                    MainStore[selectedy][selected[selectedy]].X = TargetX;
                }
                break;

            case StateTracker.Right:
                foreach (StoreItem item in MainStore[selectedy])
                {
                    item.X -= 5 * delta * 60;
                }
                if (MainStore[selectedy][selected[selectedy]].X <= TargetX)
                {
                    stateTracker = StateTracker.None;
                    MainStore[selectedy][selected[selectedy]].X = TargetX;
                }
                break;

            default:
                break;
            }

            StoreItem selectedItem = MainStore[selectedy][selected[selectedy]];

            if (!selectedItem.Unlocked && _playerInformationHandler.Cash < selectedItem.Cost)
            {
                _color = Color.Red;
            }
            else if (_playerInformationHandler.SelectedPlayer == selectedItem.Name)
            {
                _color = Color.Green;
            }
            else
            {
                _color = Color.Yellow;
            }

            if (!IsChangingState)
            {
                frame += delta;
                frame %= 0.8f;
                if (frame <= 0.4)
                {
                    _colorArrows = _colorGreen;
                }
                else
                {
                    _colorArrows = _colorYellow;
                }

                if (Opacity + (0.05f * 60 * delta) <= 1f)
                {
                    Opacity += (0.05f * 60 * delta);
                }
                if (Opacity >= 1f)
                {
                    Opacity = 1f;
                }

                if (InputHandler.Press(Keys.Right))
                {
                    if (MainStore[selectedy].Count - 1 > selected[selectedy] && stateTracker == StateTracker.None)
                    {
                        selected[selectedy]++;
                        stateTracker = StateTracker.Right;
                    }
                }
                if (InputHandler.Press(Keys.Left))
                {
                    if (selected[selectedy] > 0 && stateTracker == StateTracker.None)
                    {
                        stateTracker = StateTracker.Left;
                        selected[selectedy]--;
                    }
                }

                if (InputHandler.Press(Keys.Enter))
                {
                    var item = MainStore[selectedy][selected[selectedy]];
                    if (!item.Unlocked)
                    {
                        if (_playerInformationHandler.Cash >= item.Cost)
                        {
                            _playerInformationHandler.UnlockedPlayers.Add(item.Name);
                            _playerInformationHandler.Cash          -= item.Cost;
                            _playerInformationHandler.SelectedPlayer = item.Name;
                            item.Unlocked = true;
                            Simpsons.Reload();
                        }
                    }
                    else
                    {
                        _playerInformationHandler.SelectedPlayer = item.Name;
                        Simpsons.Reload();
                        IsChangingState = true;
                    }
                }

                if (InputHandler.GoBackPressed() && stateTracker == StateTracker.None)
                {
                    IsChangingState = true;
                }
            }
            else
            {
                Opacity -= (0.05f * 60 * delta);

                if (Opacity <= 0 && !IsOpacityDone)
                {
                    IsOpacityDone = true;
                }

                if (IsOpacityDone)
                {
                    return(StartStateChange(15, 3, 0, 400, gameTime));
                }
            }



            return(defaultState);
        }
Exemplo n.º 7
0
        public async Task Run(ILoggerFactory loggerFactory)
        {
            _logger = loggerFactory.CreateLogger <GreenlightOMatic>();
            var shows = new ShowOptions[]
            {
                ShowOptions.Simpsons,
                ShowOptions.Firefly,
                ShowOptions.Dollhouse,
                ShowOptions.KVille,
                ShowOptions.Quit
            };

            Console.CancelKeyPress += (sender, eventArgs) =>
            {
                _logger.LogCritical($"Awaiting cancelled show {_choice.ToString()} to cancel.");
                eventArgs.Cancel = true;
                _tokenSource.Cancel();
            };

            while (true)
            {
                DisplayMenu(shows);
                _choice = GetSelection(shows);
                Console.WriteLine($"You have selected {_choice.ToString()}");

                if (_choice != ShowOptions.Quit)
                {
                    _logger.LogInformation($"Beginning pre-production of {_choice.ToString()}");
                }

                _tokenSource = new CancellationTokenSource();
                var token = _tokenSource.Token;

                IShow show = null;

                switch (_choice)
                {
                case ShowOptions.Simpsons:
                    show = new Simpsons(loggerFactory);
                    break;

                case ShowOptions.Firefly:
                    show = new Firefly(loggerFactory);
                    break;

                case ShowOptions.Dollhouse:
                    show = new Dollhouse(loggerFactory);
                    break;

                case ShowOptions.KVille:
                    show = new KVille(loggerFactory);
                    break;

                case ShowOptions.Quit:
                    return;
                }

                _logger.LogInformation("Pre-production complete.  Let's make some television, people!");

                PromptCancel();

                if (null != show)
                {
                    await show.MakeShow(token).ContinueWith((t) =>
                    {
                        _logger.LogCritical($"Show {_choice.ToString()} has been cancelled.");
                    });
                }

                await Task.Delay(1000); // Delay for a second to let the loggers finish up
            }
        }