コード例 #1
0
        public void createInstances()
        {
            //Count up all of the objects
            foreach (int n in noOfObj)
            {
                total_obj += n;
            }
            int c = 0;

            block     = new Block[noOfObj[c++]];
            player    = new BasePlayer[noOfObj[c++]];
            marker    = new Marker[noOfObj[c++]];
            crawler   = new Crawler[noOfObj[c++]];
            flyenemy  = new FlyEnemy[noOfObj[c++]];
            toppler   = new Toppler[noOfObj[c++]];
            jelly     = new Jelly[noOfObj[c++]];
            nextlevel = new NextLevel[noOfObj[c++]];
            death     = new Death[noOfObj[c++]];

            cols = new Component[total_obj];
            cam  = new Camera();
            cam.init(640, 480);

            //Set ids
            int id_gen = 0;

            c = 0;
            for (int i = 0; i < noOfObj[c]; i++)
            {
                block[i] = new Block(id_gen++);
            }
            c++;
            for (int i = 0; i < noOfObj[c]; i++)
            {
                player[i] = new BasePlayer(id_gen++);
            }
            c++;
            for (int i = 0; i < noOfObj[c]; i++)
            {
                marker[i] = new Marker(id_gen++);
            }
            c++;
            for (int i = 0; i < noOfObj[c]; i++)
            {
                crawler[i] = new Crawler(id_gen++);
            }
            c++;
            for (int i = 0; i < noOfObj[c]; i++)
            {
                flyenemy[i] = new FlyEnemy(id_gen++);
            }
            c++;
            for (int i = 0; i < noOfObj[c]; i++)
            {
                toppler[i] = new Toppler(id_gen++);
            }
            c++;
            for (int i = 0; i < noOfObj[c]; i++)
            {
                jelly[i] = new Jelly(id_gen++);
            }
            c++;
            for (int i = 0; i < noOfObj[c]; i++)
            {
                nextlevel[i] = new NextLevel(id_gen++);
            }
            c++;
            for (int i = 0; i < noOfObj[c]; i++)
            {
                death[i] = new Death(id_gen++);
            }
            c++;
        }