Example #1
0
        public void update(Controller cont)
        {
            //Get all of the components
            int c = 0;

            foreach (Block b in block)
            {
                cols[c++] = b.Comp;
            }
            foreach (BasePlayer p in player)
            {
                cols[c++] = p.Comp;
            }
            foreach (Marker m in marker)
            {
                cols[c++] = m.Comp;
            }
            foreach (Crawler cr in crawler)
            {
                cols[c++] = cr.Comp;
            }
            foreach (FlyEnemy fe in flyenemy)
            {
                cols[c++] = fe.Comp;
            }
            foreach (Toppler t in toppler)
            {
                cols[c++] = t.Comp;
            }
            foreach (Jelly j in jelly)
            {
                cols[c++] = j.Comp;
            }
            foreach (NextLevel nl in nextlevel)
            {
                cols[c++] = nl.Comp;
            }
            foreach (Death d in death)
            {
                cols[c++] = d.Comp;
            }

            //Initialise all of the worlds.
            foreach (BasePlayer p in player)
            {
                p.initWorld(cols);
            }
            foreach (Crawler cr in crawler)
            {
                cr.initWorld(cols);
            }
            foreach (FlyEnemy fe in flyenemy)
            {
                fe.initWorld(cols);
            }
            foreach (Toppler t in toppler)
            {
                t.initWorld(cols);
            }
            foreach (Jelly j in jelly)
            {
                j.initWorld(cols);
            }
            //Camera
            foreach (Block b in block)
            {
                b.Cam = cam;
            }
            foreach (BasePlayer p in player)
            {
                p.Cam = cam;
            }
            foreach (Marker m in marker)
            {
                m.Cam = cam;
            }
            foreach (Crawler cr in crawler)
            {
                cr.Cam = cam;
            }
            foreach (FlyEnemy fe in flyenemy)
            {
                fe.Cam = cam;
            }
            foreach (Toppler t in toppler)
            {
                t.Cam = cam;
            }
            foreach (Jelly j in jelly)
            {
                j.Cam = cam;
            }
            foreach (NextLevel nl in nextlevel)
            {
                nl.Cam = cam;
            }
            foreach (Death d in death)
            {
                d.Cam = cam;
            }
            foreach (Terrain t in terrain)
            {
                t.Cam = cam;
            }
            foreach (Foreground fg in foreground)
            {
                fg.Cam = cam;
            }
            //Make camera follow player
            Component toFollow = null;

            foreach (BasePlayer p in player)
            {
                if (p.Level == level)
                {
                    toFollow = p.Comp; break;
                }
            }
            cam.centreAround(toFollow, 3);
            //Update each object
            foreach (BasePlayer p in player)
            {
                p.update();
                p.updateWorld(cols);
            }
            foreach (Crawler cr in crawler)
            {
                cr.update();
                cr.updateWorld(cols);
            }
            foreach (FlyEnemy fe in flyenemy)
            {
                fe.update();
                fe.updateWorld(cols);
            }
            foreach (Toppler t in toppler)
            {
                t.update();
                t.updateWorld(cols);
            }
            foreach (Jelly j in jelly)
            {
                j.update();
                j.updateWorld(cols);
            }
            //Next level
            if (level != toFollow.Level)
            {
                try
                {
                    level = toFollow.Level;
                    init();
                }
                catch (FileNotFoundException)
                {
                    level = 0;
                    init();
                }
            }
        }