private void MoveIfNeeded(GameObject gameObject) { switch (gameObject.Type) { case GameObjectType.Obstacle: case GameObjectType.Collectable: case GameObjectType.Civilian: gameObject.Location.Y += distance - oldDistance; break; } }
private void CheckCollisionWithPlayer(GameObject gameObject) { if (gameObject == player) return; switch (gameObject.Type) { case GameObjectType.Collectable: if (gameObject.DoesCollideWith(player)) { gameObject.OnCollect(player); if (gameObject is Life) sound.Play(Sounds.LifePickup); else sound.Play(Sounds.Pickup); } break; case GameObjectType.Civilian: case GameObjectType.Obstacle: if (gameObject.DoesCollideWith(player) && !blinking) { sound.Play(Sounds.Hit); actionManager .AddToQueue( () => { blinking = true; blinkingTimer = 0; livesCount -= 1; if (livesCount < 0) isGameOver = true; }) .AddToQueue( (dt) => { blinkingTimer += dt; if (blinkingTimer > 0.1) { blinkingTimer = 0; player.Visible = !player.Visible; } }, 2.0d) .AddToQueue( () => { player.Visible = true; blinking = false; blinkingTimer = -1; }); } break; } }
public override void OnCollect(GameObject gameObject) { base.OnCollect(gameObject); (gameObject as Player).FuelLevel += Utility.FUEL_ADD; }
public override void OnCollect(GameObject gameObject) { (gameObject as Player).OnLifeCollect(); base.OnCollect(gameObject); }
public virtual void OnCollect(GameObject gameObject) { Active = false; }
public bool DoesCollideWith(GameObject gameObject) { return GetAbsoluteCollisonRect().IntersectsWith(gameObject.GetAbsoluteCollisonRect()); }