Beispiel #1
0
 internal virtual void Update(GameTimeLight gameTime)
 {
     TimeElapsedSinceTick += (float) gameTime.ElapsedGameTime.TotalSeconds;
     if (TimeElapsedSinceTick > TickRate) {
         Tick();
         TimeElapsedSinceTick -= TickRate;
     }
 }
Beispiel #2
0
        internal override void Update(GameTimeLight gameTime)
        {
            base.Update(gameTime);
            if (Health <= 0) {
                FadingWorldsServer.Instance.RemoveEntity(this);
                return;
            }
            if (FadingWorldsServer.Instance.TheGrid.GetBlockAt(Position).Entities.GetById(Id) == null) {
                FadingWorldsServer.Instance.RemoveEntity(this);
                return;
            }

            TimeElapsed += (float) gameTime.ElapsedGameTime.TotalSeconds;
            TimeSinceRegen += (float) gameTime.ElapsedGameTime.TotalSeconds;

            if (RandomMovement) {
                if (TimeElapsed > TimeToUpdate) {
                    var v = RandomMove();
                    if (v == MoveResult.Moved || v == MoveResult.CannotMoveLivingEntityInTheWay) {
                        TimeElapsed -= TimeToUpdate;
                    }
                }
            }

            // Regen
            if (_regenSpeed > 0) {
                if (TimeSinceRegen > _regenSpeed) {
                    TimeSinceRegen -= _regenSpeed;

                    Heal(1);
                }
            }
            base.Update(gameTime);
        }