Example #1
0
        public void update(GameTime time)
        {
            for (int i = 0; i < objects.Count; i++)
            {
                Rock       rock          = objects[i];
                BaseScreen currentScreen = Game1.getInstance().getScreenManager().getCurrentScreen();

                if (rock.collisionRect.Intersects(((GamePlayScreen)currentScreen).getPlayer().getCollisionRect()))
                {
                    if (rock.item == Rock.ITEM.NONE)
                    {
                        ((GamePlayScreen)currentScreen).damage();
                    }
                    else
                    {
                        ((GamePlayScreen)currentScreen).heal();
                    }
                    rock.notifyCollision();
                }

                Cursor cursor = ((GamePlayScreen)currentScreen).getCursor();
                if (!cursor.isInnofensive() && rock.item == Rock.ITEM.NONE && rock.type == cursor.getColor() && rock.collisionRect.Intersects(cursor.getCollisionRect()))
                {
                    em.getNextOfColor(rock.type).explode(rock.pos);
                    removeObject(rock);
                    continue;
                }

                if (!rock.update(time))
                {
                    removeObject(rock);
                }
            }
        }