示例#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;
 }
示例#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);
                 }
             }
         }
     }
 }
示例#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;
             }
         }
     }
 }
示例#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];
     }
 }
示例#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];
     }
 }
示例#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();
                }

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