public override void Handle(Monster a, Monster b, CollisionDirections directions) { a.Direction = a.Direction.Opposite(); if (a.Position.X < b.Position.X) { a.Position -= new Vector2(0.02f, 0); } if (a.Position.X >= b.Position.X) { a.Position += new Vector2(0.02f, 0); } }
private List <Coin> handled = new List <Coin>(); // This isn't going to work forever, but it will work for now. public override void Handle(Coin a, BlockBump b, CollisionDirections directions) { if (handled.Contains(a)) { return; } handled.Add(a); a.Collect(); a.Velocity = new Vector2(0, 24); a.Position += new Vector2(0, 0.1f); }
private List <Monster> handled = new List <Monster>(); // This isn't going to work forever, but it will work for now. public override void Handle(Monster a, BlockBump b, CollisionDirections directions) { if (handled.Contains(a)) { return; } handled.Add(a); a.Hit(); a.Velocity = new Vector2(0, 24); a.Position += new Vector2(0, 0.1f); a.Direction = a.Direction.Opposite(); }
//private List<Monster> handled = new List<Monster>(); //public override void Handle(PlayerCharacter a, POWBlock b, CollisionDirections directions) //{ // if (handled.Contains(a)) return; // handled.Add(a); // a.Hit(); // a.Velocity = new Vector2(0, 24); // a.Direction = a.Direction.Opposite(); //} public override void Handle(SimpleObject p, POWBlock b, CollisionDirections directions) { if (directions.Top) { p.Position = new Vector2(p.Position.X, b.PhysicsBox.Top + 0.001f); p.Velocity = new Vector2(p.Velocity.X, 0); } if (directions.Bottom) { p.Position = new Vector2(p.Position.X, b.PhysicsBox.Bottom - p.PhysicsDimensions.Height - 0.02f); p.Velocity = new Vector2(p.Velocity.X, 0); if (p is PlayerCharacter) { b.TimesHit++; if (b.TimesHit > 3) { return; } foreach (Monster monster in monstersToHit) { if (!monster.IsStunned) { monster.Hit(); } } } } if (directions.Left) { p.Position = new Vector2(b.PhysicsBox.Right + p.PhysicsDimensions.Left + 0.02f, p.Position.Y); p.Velocity = new Vector2(0, p.Velocity.Y); } if (directions.Right) { p.Position = new Vector2(b.PhysicsBox.Left - p.PhysicsDimensions.Right - 0.02f, p.Position.Y); p.Velocity = new Vector2(0, p.Velocity.Y); } }
public override void Handle(SimpleObject p, Block b, CollisionDirections directions) { if (directions.Top) { p.Position = new Vector2(p.Position.X, b.PhysicsBox.Top + 0.02f); p.Velocity = new Vector2(p.Velocity.X, 0); } if (directions.Bottom) { p.Position = new Vector2(p.Position.X, b.PhysicsBox.Bottom - p.PhysicsDimensions.Height - 0.02f); p.Velocity = new Vector2(p.Velocity.X, 0); } if (directions.Left) { p.Position = new Vector2(b.PhysicsBox.Right + p.PhysicsDimensions.Left + 0.02f, p.Position.Y); p.Velocity = new Vector2(0, p.Velocity.Y); } if (directions.Right) { p.Position = new Vector2(b.PhysicsBox.Left - p.PhysicsDimensions.Right - 0.02f, p.Position.Y); p.Velocity = new Vector2(0, p.Velocity.Y); } }
public override void Handle(Coin a, ExitPipe b, CollisionDirections directions) { a.Position = new Vector2(1f, 23.5f); a.Direction = a.Direction.Opposite(); }