Update() public method

public Update ( ) : void
return void
Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var view = new View();

            try {
                if (args.Length >= 1)
                {
                    ShopLoader sl     = new ShopFileLoader();
                    var        player = new Player();
                    var        ui     = new UserInterface(view);

                    try {
                        Shop shop = sl.load(args[0]);

                        var gm = new GameEngine(player, shop);
                        // Default and first state
                        gm.Push(new MenuState(gm, ui, view));

                        while (gm.Running)
                        {
                            gm.Update();
                        }
                    } catch (ShopLoaderException e) {
                        view.DisplayError($"Error loading shop: {e.Message}");
                    }
                }
                else
                {
                    view.DisplayError("Must pass shop file as a command line argument");
                }
            } catch (Exception e) {
                view.DisplayError($"Unexpected Error: {e.Message}");
                // view.DisplayError(e.StackTrace);
            }
        }
Exemplo n.º 2
0
 protected override void Update(GameTime gameTime)
 {
     if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||
         Keyboard.GetState().IsKeyDown(Keys.Escape))
     {
         Exit();
     }
     _gameEngine.Update(gameTime);
     base.Update(gameTime);
 }
Exemplo 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)
        {
            // Allows the game to exit
            //if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            //    this.Exit();

            GE.Update(gameTime);

            base.Update(gameTime);
        }
Exemplo n.º 4
0
    protected virtual void Update()
    {
        TheGameEngine.Update();

        if (TheGameEngine.LevelComplete)
        {
            TheGameEngine.CleanupAssets();
            GlobalData.GetComponent <gameVariables>().GetSetLevelsCompleted += 1;
            GetLevel();
        }
    }
Exemplo n.º 5
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 (!_gameEngine.Update(gameTime))
            {
                this.Exit();
            }



            base.Update(gameTime);
        }
Exemplo n.º 6
0
        internal void HandleUpdate(GameTime gameTime)
        {
            GameEngine.gameTime = gameTime.TotalGameTime;
            Input.Update();
            _mouseState = Mouse.GetState();
            HandleGamePad();
            HandleKeyboard();
            HandleMouse();

            GameEngine.Update();
        }
Exemplo n.º 7
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)
        {
            //check for exit
            //if (GameEngine.Input.WasPressed(Keys.Escape))
            //{
            //    Exit();
            //}

            GameEngine.Update(gameTime);

            base.Update(gameTime);
        }
Exemplo n.º 8
0
        /// <summary>
        /// This is the main game loop handles keyboard input
        /// </summary>
        private static void GameLoop()
        {
            bool running = true;

            do
            {
                int retmsg = GameEngine.Update();
                switch (retmsg)
                {
                case -1:
                    running = false;
                    break;
                }
            } while (running);
        }
Exemplo n.º 9
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            if (IsQuitting)
            {
                Exit();
            }

            MainEngine.Update(gameTime, MainCharacter, Content);

            base.Update(gameTime);
        }
Exemplo n.º 10
0
        async Task MainAsync()
        {
            const int     SLEEP_TIME = 1000;
            DiscordClient discord    = new DiscordClient();
            ILogHelper    logger     = new DiscordLogHelper(discord);
            GameEngine    engine     = new GameEngine(logger);

            engine.Timer = new RealTimer();
            engine.LoadConfigFromFiles();
            engine.LoadPersistenceFiles();
            CommandManager.Instance.Engine = engine;
            discord.Engine = engine;
            discord.Init();
            while (true)
            {
                engine.Update();
                Thread.Sleep(SLEEP_TIME);
            }
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            var logger = LoggerFactory.GetLogger();

            logger.Information("===== Запуск =====");

            using (IGraphicsService graphicsService = new GraphicsService(logger))
            {
                if (graphicsService.TryInitialize())
                {
                    var blockMoveEngine = new GameEntityUpdateEngine();
                    var gameEngine      = new GameEngine(graphicsService, blockMoveEngine, logger);

                    gameEngine.CreateNew();

                    try
                    {
                        var quit = false;

                        while (!quit)
                        {
                            while (SDL2.SDL.SDL_PollEvent(out SDL2.SDL.SDL_Event sdlEvent) != 0)
                            {
                                if (sdlEvent.type == SDL2.SDL.SDL_EventType.SDL_QUIT)
                                {
                                    quit = true;
                                    break;
                                }
                            }

                            gameEngine.Update();
                        }
                    }
                    finally
                    {
                        blockMoveEngine = null;
                    }
                }
            }

            logger.Information("===== Останов =====");
        }
 private void timer1_Tick(object sender, EventArgs e)
 {
     lblRound.Text = "Round : " + engine.Round.ToString();
     engine.Update();
 }
Exemplo n.º 13
0
        static void Main(string[] args)
        {
            const int  SLEEP_TIME = 1000;
            GameEngine engine     = new GameEngine(new DiscordLogHelper(new ConsoleLogger()));

            engine.LoadConfigFromFiles();
            MockTimer timer = (MockTimer)engine.GetTimer();

            CommandManager.Instance.Engine = engine;
            Command cmd = new Command()
            {
                UserId = 1, Name = "create", Args = new string[] { "John", "edge" }
            };
            Command cmd2 = new Command()
            {
                UserId = 2, Name = "create", Args = new string[] { "Putza", "shonen" }
            };
            Command cmd3 = new Command()
            {
                UserId = 1, Name = "duel", Args = new string[] { "challenge", "Putza" }
            };
            Command cmd4 = new Command()
            {
                UserId = 2, Name = "duel", Args = new string[] { "accept" }
            };
            Command cmd5 = new Command()
            {
                UserId = 2, Name = "autoattack", Args = new string[] {}
            };
            Command cmd6 = new Command()
            {
                UserId = 1, Name = "cast", Args = new string[] { "strike" }
            };
            Command meCmd = new Command()
            {
                UserId = 2, Name = "me", Args = new string[] {}
            };
            Command meSkills = new Command()
            {
                UserId = 2, Name = "me", Args = new string[] { "skills" }
            };

            engine.EnqueueCommand(cmd);
            engine.EnqueueCommand(cmd2);

            engine.Update();
            timer.ForceTick();
            engine.GetPlayerManager().FindPlayerById(1).Entity.AddToResource("RP", 100);

            engine.EnqueueCommand(cmd3);
            engine.EnqueueCommand(cmd4);
            engine.EnqueueCommand(cmd5);
            engine.EnqueueCommand(meCmd);
            engine.EnqueueCommand(cmd6);
            engine.EnqueueCommand(meSkills);



            while (true)
            {
                engine.Update();
                timer.ForceTick();

                Thread.Sleep(SLEEP_TIME);
            }
        }
Exemplo n.º 14
0
        public void TestUpdateRoundNumber(GameState game, Shape player1Shape, Shape player2Shape, int expected)
        {
            var newGame = _engine.Update(game, player1Shape, player2Shape);

            Assert.AreEqual(expected, newGame.RoundNumber);
        }
Exemplo n.º 15
0
 protected override void Update()
 {
     CameraControler.Update();
     GameEngine.Update();
     base.Update();
 }
Exemplo n.º 16
0
 static void MainForm_FrameTick(object sender, EventArgs e)
 {
     GameEngine.Update();
 }
Exemplo n.º 17
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                System.Console.WriteLine("Invalid number of arguments.  Use /? for help.");

                return;
            }

            if (args[0] == "/?")
            {
                System.Console.WriteLine("This program needs to be run with 4 parameters");
                System.Console.WriteLine("First: the maximum number of rounds");
                System.Console.WriteLine("Second: player 1 type.  Valid values are 'H' (Human), 'R' (Computer - Random), or 'T' (Computer - Tactical)");
                System.Console.WriteLine("Third: player 2 type.  Valid values are 'H' (Human), 'R' (Computer - Random), or 'T' (Computer - Tactical)");
                System.Console.WriteLine("Fourth: rules type.  Valid values are 'D' (Default) or 'E' (Extended)");

                return;
            }

            if (args.Length < 4)
            {
                System.Console.WriteLine("Invalid number of arguments");

                return;
            }

            if (!int.TryParse(args[0], out var rounds))
            {
                System.Console.WriteLine("Please specify number of rounds");

                return;
            }

            if (!TryCreatePlayer(args[1], 1, out var player1))
            {
                System.Console.WriteLine("Invalid type for player 1.  Should be 'H', 'R', or 'T'.");

                return;
            }

            if (!TryCreatePlayer(args[2], 2, out var player2))
            {
                System.Console.WriteLine("Invalid type for player 1.  Should be 'H', 'R', or 'T'.");

                return;
            }

            if (!TryCreateGameRules(args[3], out var rules))
            {
                System.Console.WriteLine("Invalid type for game rules.  Should be 'D' (Default), or 'E' (Extended).");

                return;
            }

            var game   = GameState.NewGame(rules, player1, player2, rounds);
            var engine = new GameEngine();

            while (game.IsInProgress)
            {
                var player1Shape = GetInputForPlayer(game, player1);

                System.Console.WriteLine($"Player 1 selected {player1Shape}");

                var player2Shape = GetInputForPlayer(game, player2);

                System.Console.WriteLine($"Player 2 selected {player2Shape}");

                game = engine.Update(game, player1Shape, player2Shape);

                var roundsRemaining = game.IsInProgress ? (game.MaxRounds - game.RoundNumber + 1) : 0;

                System.Console.WriteLine(game.History.Last().Description);
                System.Console.WriteLine($"Player 1 score: {game.Player1Score} Player 2 score: {game.Player2Score} Rounds remaining: {roundsRemaining}");
            }

            if (game.Winner != null)
            {
                System.Console.WriteLine($"Game over.  Player {game.Winner.Number} was the winner.");
            }
            else
            {
                System.Console.WriteLine("Game over.  Draw.");
            }
        }