Esempio n. 1
0
        public void Init()
        {
            IGameObject[]     objects = new IGameObject[31];
            SpriteComponent[] sprites = new SpriteComponent[31];
            m_CurrGraphicsSettings.Initialise(new Vector2(1314, 1018), false, true, true, new Vector3(0, 0, 0));

            m_GameCommand.SendData(Constant.enumMessage.LOAD_TEXTURES, new string[][] { m_spritePaths, m_texIDs });

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    objects[((i * 3) + j)] = new GameObject(m_TblObjTable[i, j], m_BoardGrid[i, j]);
                    sprites[((i * 3) + j)] = new SpriteComponent(m_texIDs[2]);
                    sprites[((i * 3) + j)].SwitchDrawState();
                    objects[((i * 3) + j) + 9]  = new GameObject(m_XObjTable[i, j], m_BoardGrid[i, j]);
                    sprites[((i * 3) + j) + 9]  = new SpriteComponent(m_texIDs[1]);
                    objects[((i * 3) + j) + 18] = new GameObject(m_OObjTable[i, j], m_BoardGrid[i, j]);
                    sprites[((i * 3) + j) + 18] = new SpriteComponent(m_texIDs[0]);
                }
            }
            Vector3 midScreen = new Vector3(m_CurrGraphicsSettings.m_ScreenSize.x / 2, m_CurrGraphicsSettings.m_ScreenSize.y / 2, 0.0f);

            objects[27] = new GameObject("StartScreen", midScreen);
            sprites[27] = new SpriteComponent(m_texIDs[3]);
            sprites[27].SwitchDrawState();
            objects[28] = new GameObject("WinScreen", midScreen);
            sprites[28] = new SpriteComponent(m_texIDs[4]);
            objects[29] = new GameObject("DrawScreen", midScreen);
            sprites[29] = new SpriteComponent(m_texIDs[5]);
            objects[30] = new GameObject("LoseScreen", midScreen);
            sprites[30] = new SpriteComponent(m_texIDs[6]);

            m_GameCommand.SendData(Constant.enumMessage.CREATE_OBJECTS, objects);

            for (int i = 0; i < sprites.Length; i++)
            {
                m_GameCommand.SendDataForObject <IComponent>(Constant.enumMessage.ADD_COMPONENTS_TO_OBJECT, objects[i].m_GameObjectKey, sprites[i]);
            }
            m_GameCommand.SendData(Constant.enumMessage.UPDATE_GRAPHICS_SETTINGS, new IGraphicsSettings[] { m_CurrGraphicsSettings });
        }
Esempio n. 2
0
        public void Init()
        {
            m_Random = new Random();
            string[] textures  = { "Resources/rocktex.jpg" };
            string[] spriteIDs = m_GameCommand.RequestData <string>(Constant.enumMessage.LOAD_TEXTURES, textures); //Load Textures and Get related IDS



            IGraphicsSettings graphicsSettings = new GraphicsSettings2D();

            graphicsSettings.Initialise(new Vector2(800, 600), false, true, true);
            m_GameCommand.SendData(Constant.enumMessage.UPDATE_GRAPHICS_SETTINGS, new IGraphicsSettings[] { graphicsSettings });
            m_ScreenHeight = graphicsSettings.m_ScreenSize.y;
            m_ScreenWidth  = graphicsSettings.m_ScreenSize.x;

            IGameObject[] rocks = new IGameObject[rockCount];
            for (int i = 0; i < rockCount; i++)
            {
                rockKeys[i] = "rock_" + i.ToString();
                rocks[i]    = new GameObject(rockKeys[i], -800, 0, 0);
            }

            m_GameCommand.SendData(Constant.enumMessage.CREATE_OBJECTS, rocks);

            for (int i = 0; i < rockCount; i++)
            {
                IComponent[] rockCompArray = { new RigidBody(5, 0, 0, false, true), new Collider(new Vector3(80, 80, 0)), new SpriteComponent(spriteIDs[0]) };
                rockKeys[i] = "rock_" + i.ToString();
                m_GameCommand.SendData(Constant.enumMessage.ADD_COMPONENTS_TO_OBJECT, new Object[] { rockKeys[i], rockCompArray });
            }

            IGameObject[] player = { new GameObject(playerKey, 0, 0, 0) };
            m_GameCommand.SendData(Constant.enumMessage.CREATE_OBJECTS, player);
            m_GameCommand.SendDataForObject <IScript>(Constant.enumMessage.ADD_SCRIPT_TO_OBJECT, playerKey, new TestScript());

            m_GameCommand.SendData(Constant.enumMessage.SWITCH_SPRITES_DRAW_STATUS, rockKeys);
        }