public void Recoil(Vector2 far_location, AdventureObject recoiler) { int del_x = (int)(location.X - far_location.X); int del_y = (int)(location.Y - far_location.Y); if (Math.Abs(del_x) > Math.Abs(del_y)) { if (del_x > 0) faceDir = Master.Directions.Right; else faceDir = Master.Directions.Left; } else { if (del_y > 0) faceDir = Master.Directions.Down; else faceDir = Master.Directions.Up; } Vector2 move_dist = new Vector2(0, 0); switch (faceDir) { case Master.Directions.Down: move_dist = new Vector2(0, 4); break; case Master.Directions.Up: move_dist = new Vector2(0, -4); break; case Master.Directions.Left: move_dist = new Vector2(-4, 0); break; case Master.Directions.Right: move_dist = new Vector2(4, 0); break; default: break; // Something has gone wrong } Vector2 test = location + move_dist; if (!parent.hblock && !parent.hloop && ((test.X - width) <= 0)) parent.enterNewRoom(-1, 0); else if (!parent.vblock && !parent.vloop && ((test.Y - height) <= 0)) parent.enterNewRoom(0, -1); else if (!parent.hblock && !parent.hloop && ((test.X + width) >= (25 * 32))) parent.enterNewRoom(1, 0); else if (!parent.hblock && !parent.vloop && ((test.Y + height) >= (13 * 32))) parent.enterNewRoom(0, 1); else if (parent.hloop && test.X - width < 0) location.X = 25 * 32 - width - 2; else if (parent.hloop && test.X + width >= (25 * 32)) location.X = width + 2; else if (parent.vloop && test.Y - height < 0) location.Y = 13 * 32 - height - 2; else if (parent.vloop && test.Y + height >= (13 * 32)) location.Y = height + 2; else if (!parent.isSolid(test, 1, width, height, faceDir)) location = test; else if (flickerCount <= 0 && !(recoiler is AdventureEntity)) recoiler.Move(-move_dist); }
protected bool doesOverlap(AdventureObject obj) { return Math.Abs(location.X - obj.location.X) < (width + obj.width) && Math.Abs(location.Y - obj.location.Y) < (height + obj.height); }
public bool interenemyCollide(Vector2 location, int radius, AdventureObject self) { if (self is AdventureEnemy && ((AdventureEnemy)self).ghost) return false; foreach (AdventureObject obj in objects) { if (obj is AdventureEnemy && obj != self && !((AdventureEnemy)obj).ghost) { if (Vector2.Distance(obj.location, location) < radius) return true; } } return false; }
public void addObject(AdventureObject obj) { obj.Initialize(this, game); newobjects.Add(obj); }
public static bool isProjectile(AdventureObject proj) { if (proj is AdventureProjectile) return true; else return false; }
// Predicates public static bool isInactive(AdventureObject obj) { return !(obj.active); }