Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
 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);
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
 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;
             }
         }
     }
 }
Ejemplo n.º 4
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];
     }
 }
Ejemplo n.º 5
0
 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];
     }
 }
Ejemplo n.º 6
0
        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();
                }

            }
        }
Ejemplo n.º 7
0
 public override void onCollHitting(Collideable c, float x, float y)
 {
     if (c is Player)
     {
     }
 }
Ejemplo n.º 8
0
 bool CheckWallOnly(Collideable w)
 {
     return (w is Wall && !(w is RockWall));
 }
Ejemplo n.º 9
0
 protected bool CheckColl(Collideable col)
 {
     return (rect.Intersects(col.rect));
 }
Ejemplo n.º 10
0
 public virtual void onCollHitting(Collideable c, float x, float y)
 {
 }
Ejemplo n.º 11
0
 public void Add(Collideable c, bool movers)
 {
     c.owner = this;
     if (movers)
     {
         toAddMovers.Add(c);
     }
     else
     {
         toAddNonMovers.Add(c);
     }
 }
Ejemplo n.º 12
0
 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;
         }
     }
 }