public virtual void Update(Player player) { ++timeInState; if (IsDying) { if (Y > level.Bounds.Bottom) { isDead = true; } } else { // see if the enemy got hit by a tomato //TODO // see if the player got hit by the enemy HitBox overlap = this.HitBox.CheckCollision(player.HitBox); if (overlap.IsNotNull()) { // the player dies player.KillSlowly(); } } }
public HitBox CheckCollisionSolid(HitBox hitbox) { HitBox overlap = new HitBox(); if (hitbox.Left < Bounds.Left) { overlap.Left = hitbox.Left - Bounds.Left; return(overlap); } /*/ TEMP: * if (hitbox.Top < Bounds.Top) * { * overlap.Top = hitbox.Top - Bounds.Top; * return overlap; * } * // :TEMP */ for (int i = 0; i < land.Length; ++i) { HitBox landHitBox = LandHitBox(i); overlap = hitbox.CheckCollision(landHitBox); if (overlap.IsNotNull()) { return(overlap); } } return(overlap); }
public void Update(Player player) { if (!collected) { // see if the player collected the item HitBox overlap = this.HitBox.CheckCollision(player.HitBox); if (overlap.IsNotNull()) { player.Collect(this); collected = true; } } }