public override void Update(UpdateArgs args)
        {
            if (Updated)
                return;

            UpdateModificators();

            #region Handling keys

            if (Game.HandlingKeysInGame)
            {
                if (IsPlayer)
                {

                    if (args.Key == ConsoleKey.LeftArrow)
                        Move(Direction.Left);

                    if (args.Key == ConsoleKey.RightArrow)
                        Move(Direction.Right);

                    if (args.Key == ConsoleKey.UpArrow)
                        Move(Direction.Up);

                    if (args.Key == ConsoleKey.DownArrow)
                        Move(Direction.Down);
                }
            }

            #endregion

            base.Update(args);
        }
Exemple #2
0
        private void StartUpdate()
        {
            HandlingKeysInGame = true;
            _updateLastTime = DateTime.Now;
            double keyCooler = 0.0;
            while (!_exit)
            {
                _updateElapsedTime = (DateTime.Now - _updateLastTime).TotalMilliseconds;
                _updateLastTime = DateTime.Now;
                _updateTime += _updateElapsedTime;

                if (!_isGamePaused)
                {
                    _updateGameTime += _gameTurnTime;
                    keyCooler += _updateElapsedTime;
                }

                var key = ConsoleKey.NoName;
                if(HandlingKeysInGame)
                    key = Console.ReadKey(true).Key;

                var args = new UpdateArgs
                {
                    GlobalTime = _updateTime,
                    GameTime = _updateGameTime,
                    ElapsedGlobalTime = _updateElapsedTime,
                    ElapsedGameTime = _gameTurnTime,
                    IsGamePaused = _isGamePaused
                };

                if (keyCooler >= _updateRate)
                {
                    keyCooler = 0;
                    args.Key = key;
                }
                Update(args);

                UpdateHandlingKeys();
            }
        }
Exemple #3
0
        private void Update(UpdateArgs args)
        {
            //todo ui update

            if (args.Key == ConsoleKey.Escape)
                _exit = true;

            _currentMap.Update(args);
        }
Exemple #4
0
        public override void Update(UpdateArgs args)
        {
            base.Update(args);

            //var xLength = _map.GetLength(0);
            //var yLength = _map.GetLength(1);

            //for(int x = 0; x < xLength; x++)
            //    for (int y = 0; y < yLength; y++)
            //    {
            //        this[x, y].ToList().ForEach(obj => obj.Update(args));
            //    }
            DoForAll(obj => obj.Update(args));
            DoForAll(ResetUpdate);
        }