public void Consume() { ClockFactory.StartTimer(timer); //character.StateManager.IsInvincible = true; //character.StateManager.IsImmuneToDehydration = true; HasBeenConsumed = true; }
public void DehydrateCharacter() { if (ClockFactory.IsTimerFinished(timer) && isDehydrationEnabled) { if (!StateManager.IsImmuneToDehydration) { SoundFactory.PlayCharacterHurtSound(); HealthLevel -= dehydrationDamage; if (HealthLevel <= 0) { StateManager.IsDead = true; StateManager.HandleDeath(); } else { characterDrawingManager.SetCharacterBlinking(true); } } ClockFactory.ResetTimer(timer); ClockFactory.StartTimer(timer); } }
public override void Update() { if (ClockFactory.IsTimerFinished(timeIds[2])) { this.level.IsCompleted = true; this.IsFinished = true; } else if (ClockFactory.IsTimerFinished(timeIds[1])) { float x = camera.Transform.M11 + camera.View.Width / 2f - scoreFont.SpriteFont.MeasureString(scoreMessage).X / 2f; float y = (camera.Transform.M22 + camera.View.Height) * 2f / 3f; this.scoreMessagePosition = new Vector2(x, y); ClockFactory.StartTimer(timeIds[2]); } else if (ClockFactory.IsTimerFinished(timeIds[0])) { float x = camera.Transform.M11 + camera.View.Width / 2f - completeFont.SpriteFont.MeasureString(completeMessage).X / 2f; float y = camera.Transform.M22 + camera.View.Height / 3f; this.completeMessagePosition = new Vector2(x, y); ClockFactory.StartTimer(timeIds[1]); } foreach (AbstractTerrain terrain in terrainList) { terrain.Update(); } }
public DefaultSubLevelTransitionEvent(TimeSpan timeToTextOverlay, TimeSpan timeToLevelChange, String transitionMessage, SpriteFontContainer transitionFont) { this.timeIds = new int[2]; this.timeIds[0] = ClockFactory.RegisterTimer(timeToTextOverlay); this.timeIds[1] = ClockFactory.RegisterTimer(timeToLevelChange); this.transitionMessage = transitionMessage; this.transitionFont = transitionFont; this.transitionMessagePosition = new Vector2(); ClockFactory.StartTimer(timeIds[0]); }
public DefaultDeathEvent(TimeSpan timeToTextOverlay, TimeSpan timeToLevelReset, String deathMessage, SpriteFontContainer deathFont) { this.timeIds = new int[2]; this.timeIds[0] = ClockFactory.RegisterTimer(timeToTextOverlay); this.timeIds[1] = ClockFactory.RegisterTimer(timeToLevelReset); this.deathMessage = deathMessage; this.deathFont = deathFont; this.deathMessagePosition = new Vector2(); ClockFactory.StartTimer(timeIds[0]); }
public DefaultLevelCompleteEvent(TimeSpan timeToTextOverlay, TimeSpan timeToScoreOverlay, TimeSpan timeToLevelChange, String completeMessage, String scoreMessage, SpriteFontContainer completeFont, SpriteFontContainer scoreFont) { this.timeIds = new int[3]; this.timeIds[0] = ClockFactory.RegisterTimer(timeToTextOverlay); this.timeIds[1] = ClockFactory.RegisterTimer(timeToScoreOverlay); this.timeIds[2] = ClockFactory.RegisterTimer(timeToLevelChange); this.completeMessage = completeMessage; this.scoreMessage = scoreMessage; this.completeFont = completeFont; this.scoreFont = scoreFont; this.completeMessagePosition = new Vector2(); ClockFactory.StartTimer(timeIds[0]); }
public override void Update() { if (ClockFactory.IsTimerFinished(timeIds[1])) { this.level.IsFailed = true; this.IsFinished = true; } else if (ClockFactory.IsTimerFinished(timeIds[0])) { float x = camera.Transform.M11 + camera.View.Width / 2f - deathFont.SpriteFont.MeasureString(deathMessage).X / 2f; float y = camera.Transform.M22 + camera.View.Height / 2f; this.deathMessagePosition = new Vector2(x, y); ClockFactory.StartTimer(timeIds[1]); } foreach (AbstractCharacter character in characterList) { character.Update(); } foreach (IEnemy enemy in enemyList) { enemy.Update(); } foreach (AbstractTerrain terrain in terrainList) { terrain.Update(); } foreach (ItemSet itemSet in itemSetList) { itemSet.Update(); } foreach (ICollectable collectable in collectableList) { collectable.Update(); } foreach (IItem item in itemList) { item.Update(); } camera.Update(); }
public CharacterImpl(int health, int fishbowlWaterLevel, Rectangle position, List <IController> controllersList, bool isDehydrationEnabled, int dehydrationDamage, int dehydrationTime, CollisionType collisionType, string message) { this.Position = new Vector2(position.X, position.Y); this.Size = new Vector2(position.Width, position.Height); this.Velocity = new Vector2(); this.originalHitbox = position; this.HealthLevel = health; this.maxHealthLevel = health; this.MeterLevel = fishbowlWaterLevel; this.controllers = controllersList == null ? new List <IController>() : controllersList; this.StateManager = new CharacterStateManagerImpl(this); this.CurrentItem = null; this.ShouldNotifyReceivers = false; this.CollisionType = collisionType; this.isDehydrationEnabled = isDehydrationEnabled; this.keyPickupHeld = false; this.dehydrationDamage = dehydrationDamage; this.CurrentPowerup = null; this.timer = ClockFactory.RegisterTimer(new TimeSpan(0, 0, dehydrationTime)); this.MessageToReceivers = message; ClockFactory.StartTimer(timer); }