Esempio n. 1
0
        public void updateGame()
        {
            if (board.Lives < 0)
            {
                gamestate = 2;
            }

            Player.update();
            ball.update();

            if (grid.AllGone)
            {
                //TODO: find a way to count every level in levels, now max level is hardcoded
                if (grid.Level <= 7)
                {
                    grid.initNewLevel();
                }
                else
                {
                    Gamestate = 2;
                }
            }

            //Items hinzufuegen
            List <Item> toRemove = new List <Item>();

            foreach (Item i in itemList)
            {
                i.update();
                if (i.outOfRange())
                {
                    toRemove.Add(i);
                }
                if (ManagerCollision.Instance.collide(Player.PaddleShape, i.Rectangle))
                {
                    toRemove.Add(i);
                    Feature f           = i.Feature;
                    bool    sameFeature = false;
                    foreach (Feature has in featureList)
                    {
                        if (has.FeatureNumber == f.FeatureNumber)
                        {
                            sameFeature = true;
                        }
                    }
                    if (sameFeature)
                    {
                        f.resetClock();
                    }
                    else
                    {
                        featureList.Add(f);
                    }
                }
            }
            foreach (Item i in toRemove)
            {
                itemList.Remove(i);
            }
            List <Feature> toRemoveFeature = new List <Feature>();

            foreach (Feature f in featureList)
            {
                if (!f.timesUp())
                {
                    f.giveFeature();
                }
                else
                {
                    f.takeFeature();
                    if (f.Finished)
                    {
                        toRemoveFeature.Add(f);
                    }
                }
            }
            foreach (Feature f in toRemoveFeature)
            {
                featureList.Remove(f);
            }
        }