public void Update(GameTime gameTime) { _animator.Position = ConvertUnits.ToDisplayUnits(_body.Position); _animator.Rotation = _body.Rotation; _animator.Update(gameTime.ElapsedGameTime.Milliseconds); }
public override void Update(GameTime gameTime) { base.Update(gameTime); if (_animator.CurrentAnimation.Name == "Expand") { if (_animator.Speed == 1) { if ((_animator.Progress * _animator.Length) > _randomAnimationTime) { _animator.Speed = 0; _expandTimer = TimeSpan.FromSeconds(_boss.Game.GameManager.Random.Next(1, 5)); } } else if (_animator.Speed == 0) { _expandTimer -= gameTime.ElapsedGameTime; if (_expandTimer.TotalSeconds < 0) { RevertExpand(); } } else if (_animator.Speed == -1) { if (_animator.Progress == 0) { Expand(); } } } _animator.Rotation += _angularSpeed * gameTime.GetElapsedSeconds(); _animator.Update(gameTime.ElapsedGameTime.Milliseconds); }
public void Update(GameTime gameTime) { _animator.Update(gameTime.ElapsedGameTime.Milliseconds); if (_laser != null) { _laser.SetStartPoint(Position()); _laser.SetEndPoint(Position() + Vector2.UnitY * GameConfig.VirtualResolution.Y); var scaleAmount = gameTime.GetElapsedSeconds() * 10f; if (_scaleDownLaser) { _laser.ScaleX(_laser.ScaleVector().X - scaleAmount); } else { _laser.ScaleX(_laser.ScaleVector().X + scaleAmount); } if (_scaleDownLaser && _laser.ScaleVector().X < 3f) { _scaleDownLaser = false; } else if (_laser.ScaleVector().X > 4f) { _scaleDownLaser = true; } _laser.Update(gameTime); } }
public void Update(GameTime gameTime) { //if (_verticalDirection == 1 && Position().Y >= GameConfig.VirtualResolution.Y) // _verticalDirection = -1; //else if (_verticalDirection == -1 && Position().Y <= 0) // _verticalDirection = 1; //Position(new Vector2(Position().X, Position().Y + (_speed * _verticalDirection * gameTime.GetElapsedSeconds()))); _animator.Update(gameTime.ElapsedGameTime.Milliseconds); }
public virtual void Update(GameTime gameTime) { UpdatePosition(gameTime); UpdateRotation(gameTime); UpdateBehaviour(gameTime); // Is outside of the screen? IsOutside = Game.GameManager.IsOutside(Position()); // New position timer if (StartNewPositionTimer && NewPositionTimerFinished != null) { if (NewPositionTimer.TotalMilliseconds > 0) { NewPositionTimer -= gameTime.ElapsedGameTime; } else { NewPositionTimer = TimeSpan.FromSeconds(NewPositionTimerTime); NewPositionTimerFinished.Invoke(this, NewPositionTimerTime); } } // Shoot timer if (StartShootTimer && ShootTimerFinished != null) { if (ShootTimer.TotalMilliseconds > 0) { ShootTimer -= gameTime.ElapsedGameTime; } else { ShootTimer = TimeSpan.FromSeconds(ShootTimerTime); ShootTimerFinished.Invoke(this, ShootTimerTime); } } if (_hitTimer.TotalMilliseconds > 0) { _hitTimer -= gameTime.ElapsedGameTime; } Tinted = _hitTimer.TotalMilliseconds > 0; var portion = (InitialLife / Behaviours.Count); var value = Life - (InitialLife - (CurrentBehaviourIndex + 1) * portion); _hpBar.Scale = new Vector2(value / portion, 1f); _hpBar.Color = Tinted ? Color.White : GameConfig.BossHPBarColors[CurrentBehaviourIndex]; _timer += gameTime.ElapsedGameTime; _timerLabel.Text = _timer.ToString("mm\\:ss"); CurrentAnimator.Update(gameTime.ElapsedGameTime.Milliseconds); }
public virtual void Update(GameTime gameTime) { if (_destroyed) { if (Game.GameManager.TransitioningToEndGame() && Game.SpriteBatchManager.Boss != null) { PlayExplosionAnimation(); Dispose(); } return; } if (_bossEntranceAnimation) { if (Position().EqualsWithTolerence(InitialPosition, 1E-02f)) { Position(InitialPosition); _ready = true; _bossEntranceAnimation = false; Invincible = false; } } if (!_destroyed && PhysicsEnabled) { PhysicsWorld.Step((float)gameTime.ElapsedGameTime.TotalSeconds); SynchronizeGraphicsWithPhysics(); } if (_randomPosition && !TargetingPosition) { var newPosition = Vector2.Zero; if (_randomPositionLongDistance) { var currentPosition = Position().ToPoint(); var minDistance = (RandomMovingArea.Width - RandomMovingArea.X) / 2; // Choose a random long distance new X position var leftSpace = currentPosition.X - RandomMovingArea.X; var rightSpace = RandomMovingArea.Width - currentPosition.X; if (leftSpace > minDistance) { if (rightSpace > minDistance) { if (Game.GameManager.Random.NextDouble() > 0.5) { newPosition.X = Game.GameManager.Random.Next(currentPosition.X + minDistance, RandomMovingArea.Width); } else { newPosition.X = Game.GameManager.Random.Next(RandomMovingArea.X, currentPosition.X - minDistance); } } else { newPosition.X = Game.GameManager.Random.Next(RandomMovingArea.X, currentPosition.X - minDistance); } } else { newPosition.X = Game.GameManager.Random.Next(currentPosition.X + minDistance, RandomMovingArea.Width); } // minDistance only depends on the random area X and width if (RandomMovingArea.Height - RandomMovingArea.Y > minDistance) { // Choose a random long distance new Y position var topSpace = currentPosition.Y - RandomMovingArea.Y; var bottomSpace = RandomMovingArea.Height - currentPosition.Y; if (topSpace > minDistance) { if (bottomSpace > minDistance) { if (Game.GameManager.Random.NextDouble() > 0.5) { newPosition.Y = Game.GameManager.Random.Next(currentPosition.Y + minDistance, RandomMovingArea.Height); } else { newPosition.Y = Game.GameManager.Random.Next(RandomMovingArea.Y, currentPosition.Y - minDistance); } } else { newPosition.Y = Game.GameManager.Random.Next(RandomMovingArea.Y, currentPosition.Y - minDistance); } } else { newPosition.Y = Game.GameManager.Random.Next(currentPosition.Y + minDistance, RandomMovingArea.Height); } } else { newPosition.Y = Game.GameManager.Random.Next(RandomMovingArea.Y, RandomMovingArea.Height); } } else { newPosition.X = Game.GameManager.Random.Next(RandomMovingArea.X, RandomMovingArea.Width); newPosition.Y = Game.GameManager.Random.Next(RandomMovingArea.Y, RandomMovingArea.Height); } MoveTo(newPosition, 1.5f); } UpdatePosition(gameTime); UpdateRotation(gameTime); UpdateBehaviour(gameTime); if (_destroyed) { return; } // Is outside of the screen? IsOutside = Game.GameManager.IsOutside(Position()); // New position timer if (StartNewPositionTimer && NewPositionTimerFinished != null) { if (NewPositionTimer.TotalMilliseconds > 0) { NewPositionTimer -= gameTime.ElapsedGameTime; } else { NewPositionTimer = TimeSpan.FromSeconds(NewPositionTimerTime); NewPositionTimerFinished.Invoke(this, NewPositionTimerTime); } } // Shoot timer if (StartShootTimer && ShootTimerFinished != null) { if (ShootTimer.TotalMilliseconds > 0) { ShootTimer -= gameTime.ElapsedGameTime; } else { ShootTimer = TimeSpan.FromSeconds(ShootTimerTime); ShootTimerFinished.Invoke(this, ShootTimerTime); } } if (_hitTimer.TotalMilliseconds > 0) { _hitTimer -= gameTime.ElapsedGameTime; } Tinted = _hitTimer.TotalMilliseconds > 0; CurrentAnimator.Update(gameTime.ElapsedGameTime.Milliseconds); }
public void Update(GameTime gameTime) { _animator.Update(gameTime.ElapsedGameTime.Milliseconds); }