Пример #1
0
        public virtual void Update(Player player)
        {
            ++timeInState;

            if (IsDying)
            {
                if (Y > level.Bounds.Bottom)
                {
                    isDead = true;
                }
            }
            else
            {
                // see if the enemy got hit by a tomato
                //TODO

                // see if the player got hit by the enemy
                HitBox overlap = this.HitBox.CheckCollision(player.HitBox);
                if (overlap.IsNotNull())
                {
                    // the player dies
                    player.KillSlowly();
                }
            }
        }
Пример #2
0
        public HitBox CheckCollisionSolid(HitBox hitbox)
        {
            HitBox overlap = new HitBox();

            if (hitbox.Left < Bounds.Left)
            {
                overlap.Left = hitbox.Left - Bounds.Left;
                return(overlap);
            }

            /*/ TEMP:
             * if (hitbox.Top < Bounds.Top)
             * {
             *      overlap.Top = hitbox.Top - Bounds.Top;
             *      return overlap;
             * }
             * // :TEMP */
            for (int i = 0; i < land.Length; ++i)
            {
                HitBox landHitBox = LandHitBox(i);
                overlap = hitbox.CheckCollision(landHitBox);
                if (overlap.IsNotNull())
                {
                    return(overlap);
                }
            }
            return(overlap);
        }
Пример #3
0
 public void Update(Player player)
 {
     if (!collected)
     {
         // see if the player collected the item
         HitBox overlap = this.HitBox.CheckCollision(player.HitBox);
         if (overlap.IsNotNull())
         {
             player.Collect(this);
             collected = true;
         }
     }
 }