public void Update(float dt) { if (Hit) { hitTimer.Update(dt); if (hitTimer.IsTimeUp()) { recovering(); } } if (Recovering) { recoveryTimer.Update(dt); if (recoveryTimer.IsTimeUp()) { recoveredFromHit(); } } if (Dead) { this.RespawnTimer.Update(dt); } }
public override void Update(float dt) { if (!this.Fallen) { if (!fallTimer.IsReset()) { fallTimer.Update(dt); if (fallTimer.IsTimeUp()) { fallAway(); } } } else { if (!resetTimer.IsReset()) { resetTimer.Update(dt); if (resetTimer.IsTimeUp()) { Reset(); } } } }
protected void doBlink(float dt) { blinkTimer.Update(dt); if (blinkTimer.IsTimeUp()) { blinkTimer.SetDelay(blinkDelay); toggleBlink(); } }
/* * public override void Respawn() * { * base.Respawn(); * SetUpEnemy(this.SpawnPosition, EnemyFactory.BatWidth, EnemyFactory.BatHeight, EnemyFactory.BatHealth, EnemyFactory.BatHitDelay, EnemyFactory.BatRecoveryDelay); * } */ // Activities: private bool checkFlap() { if (this.Position.Y >= ConvertUnits.ToSimUnits(this.SpawnPosition.Y) || this.PhysicsContainer.Object.OnGround) { if (flapTimer.IsTimeUp()) { flapTimer.SetDelay(flapTimerDelay); enemyEvent.flap = true; return(true); } } return(false); }
public bool CheckStopDiving() { if (this.PhysicsContainer.Object.OnGround) { return(true); } if (diveTimer.IsTimeUp()) { return(true); } return(false); }
public bool CheckForPlayer(bool playerInSight) { if (playerInSight) { if (!EnemySeesPlayer) { EnemySeesPlayer = true; enemySawPlayerTimer.SetDelay(enemySightDelay); } if (enemySawPlayerTimer.IsTimeUp()) { return(true); } else { return(false); } } else { if (EnemySeesPlayer) { EnemySeesPlayer = false; enemySawPlayerTimer.SetDelay(enemySightDelay); } if (enemySawPlayerTimer.IsTimeUp()) { return(false); } else { return(true); } } }
protected void checkShake(float dt) { if (livingEntity.Health.Hit) { shakeTimer.Update(dt); if (shakeTimer.IsTimeUp()) { shakeTimer.SetAccumulatedDelay(shakeDelay); doShake(); } } else { shakePositionOffset = Vector2.Zero; } }
public void Update(float dt) { lifeTimer.Update(dt); if (fadeAway) { Opacity = lifeTimer.PercentFromTimeUp() * initialOpacity; } if (alphaAway) { Alpha = lifeTimer.PercentFromTimeUp() * initialAlpha; } if (lifeTimer.IsTimeUp()) { this.Active = false; } }
public void Update(float dt) { if (Running) { emissionTimer.Update(dt); if (emissionTimer.IsTimeUp()) { emissionTimer.SetAccumulatedDelay(emissionDelay); EmitParticleWithDisplayEntity(this.DisplayEntity); } } foreach (Particle particle in particles) { if (particle.Active) { particle.Update(dt); } } }
public override void Draw(GameTime gameTime) { ++frameCounter; string fps = string.Format("fps: {0}", frameRate); if (debugText) { GraphicsDevice.Viewport = game.defaultViewport; spriteBatch.Begin(); spriteBatch.DrawString(spriteFont, fps, new Vector2(5, 5), Color.White); if (!debugTextTimer.IsTimeUp()) { spriteBatch.DrawString(spriteFont, debugString, new Vector2(5, 37), Color.White); } spriteBatch.End(); } }
public override void Update(float dt) { // horizontally if (Math.Abs(Position.X - ConvertUnits.ToSimUnits(initialPosition.X)) > ConvertUnits.ToSimUnits(distance)) { MarkDone(); } // vertically else if (Math.Abs(Position.Y - ConvertUnits.ToSimUnits(initialPosition.Y)) > ConvertUnits.ToSimUnits(distance)) { MarkDone(); } if (!doneTimer.IsReset()) { doneTimer.Update(dt); if (doneTimer.IsTimeUp()) { MarkDone(); doneTimer.Reset(); } } }
public void TurnAround(Enemy enemy) { Stop(); if (!turnAround) { turnAround = true; turnAroundTimer.SetDelay(turnAroundTimerDelay); } if (turnAroundTimer.IsTimeUp()) { turnAround = false; if (enemy.FacingRight) { enemy.FacingRight = false; } else { enemy.FacingRight = true; } } }
protected override void performChecks() { // we don't care about the ceiling checkForGround(); checkForWall(false, false); checkForCharOnHead(true, false); // record the previous values to the next values prevOnGround = nextOnGround; prevOnLeftWall = nextOnLeftWall; prevOnRightWall = nextOnRightWall; // record the next values nextOnGround = onGroundPhysics; nextOnLeftWall = OnLeftWall; nextOnRightWall = OnRightWall; if (onGroundPhysics) { enableOnGroundDelay = true; } if (OnLeftWall) { enableOnLeftWallDelay = true; } if (OnRightWall) { enableOnRightWallDelay = true; } onGroundDelay = false; if (enableOnGroundDelay && !onGroundPhysics) { if (prevOnGround && !nextOnGround) { if (body.LinearVelocity.Y >= 0) // so that it doesn't happen when shooting upwards off a platform { onGroundTimer.SetDelay(onGroundOrWallDelay); } } if (!onGroundPhysics && !onGroundTimer.IsTimeUp()) { onGroundDelay = true; } } if (enableOnLeftWallDelay && !OnLeftWall) { if (prevOnLeftWall && !nextOnLeftWall) { onLeftWallTimer.SetDelay(onGroundOrWallDelay); } if (!OnLeftWall && !onLeftWallTimer.IsTimeUp()) { OnLeftWall = true; } } if (enableOnRightWallDelay && !OnRightWall) { if (prevOnRightWall && !nextOnRightWall) { onRightWallTimer.SetDelay(onGroundOrWallDelay); } if (!OnRightWall && !onRightWallTimer.IsTimeUp()) { OnRightWall = true; } } }