public override void onCollHit(Collideable c, float x, float y) { if (y != 0) { if (y > 0) //DOWN { c.rect.Y = rect.Y - c.rect.Height; } else //UP { c.rect.Y = rect.Y + rect.Height; } } if (x != 0) { if (x > 0) //RIGHT { c.rect.X = rect.X - c.rect.Width; } else //LEFT { c.rect.X = rect.X + rect.Width; } } c.pos.X = c.rect.X; c.pos.Y = c.rect.Y; }
public override void onCollHit(Collideable c, float x, float y) { base.onCollHit(c, x, y); if (c is Player) { Player p = (Player)c; if (x != 0) { if (p.Eating) { if (!eating.Contains(p)) { eating.Add(p); p.realEating = true; eatingPos.Add(p, p.rect.Location); } } else { if (eating.Contains(p)) { eating.Remove(p); p.realEating = false; eatingPos.Remove(p); } } } } }
public override void onCollHitting(Collideable c, float x, float y) { if (c is Wall) { if (x != 0) { velocity.X *= -1; if (velocity.X > 0) { velocity.X /= 2; } else { velocity.X /= 2; } } if (y != 0) { velocity.Y = 0; if (velocity.X > friction) { velocity.X -= friction; } else if (velocity.X < -friction) { velocity.X += friction; } else { velocity.X = 0; } } } }
public Map(int xOff, int yOff) { this.xOff = xOff; this.yOff = yOff; grid = new Collideable[HEIGHT][]; for (int i = 0; i < grid.Length; i++) { grid[i] = new Collideable[WIDTH]; } }
public Map(int xOff, int yOff, int width, int height) { this.xOff = xOff; this.yOff = yOff; this.HEIGHT = height; this.WIDTH = width; grid = new Collideable[HEIGHT][]; for (int i = 0; i < grid.Length; i++) { grid[i] = new Collideable[WIDTH]; } }
public override void onCollHit(Collideable c, float x, float y) { if (c is Player) { Player p = (Player)c; if (edible) { if (p.Eating && alive) { p.points += points; alive = false; } } else if (p != attackOwner && !p.isHit) { p.Hit(); } } }
public override void onCollHitting(Collideable c, float x, float y) { if (c is Player) { } }
bool CheckWallOnly(Collideable w) { return (w is Wall && !(w is RockWall)); }
protected bool CheckColl(Collideable col) { return (rect.Intersects(col.rect)); }
public virtual void onCollHitting(Collideable c, float x, float y) { }
public void Add(Collideable c, bool movers) { c.owner = this; if (movers) { toAddMovers.Add(c); } else { toAddNonMovers.Add(c); } }
public override void onCollHitting(Collideable c, float x, float y) { if (c is Wall) { if (y != 0) { velocity.Y = 0; if (y > 0) { jumpPossible = true; } } if (x != 0) { velocity.X = 0; } } }