private void MoveLeft() { flip = true; move(roation.Left, Parameters.moveSpeed); foreach (var b in ActiveElements.GetActiveBlocks(position)) { if (Collide(b)) { move(roation.Right, Parameters.moveSpeed); OnWallHit?.Invoke(this, null); break; } } }
private void ApplyBlocksCollisions() { foreach (var b in ActiveElements.GetActiveBlocks(position)) { if (Collide(b as GenericSprite)) { if (speed > 0) { TicksElapsed = 0; speed = -speed; } } } if (TicksElapsed != Parameters.BlocksCollisionDelay) { TicksElapsed++; } }
public override void update() { if (Randomizer.Next(200) == 0 && Engine.entities.Count < 2) { var zombie = new Zombie(ActiveElements, Drawer, Sound, new Parameters(), Player); zombie.status.OnKill = () => Kill(zombie); zombie.position.x = Randomizer.Next(-110, 110); zombie.position.y = 70; if (!ActiveElements.GetActiveBlocks(zombie.position).Any(s => s.Collide(zombie))) { Engine.entities.Add(zombie); } } for (int i = 0; i < Engine.entities.Count(); i++) { var zombie = Engine.entities[i] as MovableObject; if (!zombie.IsInRange(150)) { Engine.entities.Remove(zombie); } } }