示例#1
0
文件: World.cs 项目: hsuanhauliu/RuGo
    public void RespawnFiles()
    {
        int countOFchildern = mGadgetShelf.transform.childCount;

        for (int i = (int)GadgetInventory.NUM; i < countOFchildern; i++)
        {
            Transform placeHolder = mGadgetShelf.transform.GetChild(i);
            if (placeHolder.childCount < 2)
            {
                int      slot            = i - (int)GadgetInventory.NUM;
                string   gadgetName      = "LoadCube";
                LoadCube spawnedLoadCube = SpawnSingleGadget(gadgetName, placeHolder) as LoadCube;
                Renderer r = spawnedLoadCube.GetComponent <Renderer>();
                r.material.color     = RoomColors[slot];
                spawnedLoadCube.Slot = slot.ToString();
            }
        }
    }
示例#2
0
文件: World.cs 项目: hsuanhauliu/RuGo
    private void SpawnGadgetShelf()
    {
        float startDegree_xz = -60.0f;
        float gap            = 30f;
        int   counter        = 0;
        float y_pos          = 0.0f;

        shelfGadgetContainersPositions = new Vector3[(int)GadgetInventory.NUM];

        for (int i = 0; i < (int)GadgetInventory.NUM; i++)
        {
            // Create container and store their position
            GameObject container = new GameObject("Container " + i.ToString());
            container.transform.SetParent(mGadgetShelf.transform);

            float container_pos_x = shelfRadius * Mathf.Cos(startDegree_xz * (float)Math.PI / 180);
            float container_pos_z = shelfRadius * Mathf.Sin(startDegree_xz * (float)Math.PI / 180);

            Vector3 container_pos = new Vector3(container_pos_x, y_pos, container_pos_z);
            container.transform.localPosition = container_pos;
            shelfGadgetContainersPositions[i] = container_pos;

            // Create bubble
            GameObject bubbleObj = Instantiate(BubblePrefab, container.transform);

            // Create gadget
            string gadgetName = ((GadgetInventory)i).ToString();

            SpawnSingleGadget(gadgetName, container.transform);

            startDegree_xz += gap;
            counter        += 1;

            if (counter == 5)
            {
                counter        = 0;
                startDegree_xz = -60.0f;
                if (y_pos >= 0)
                {
                    y_pos += 0.3f;
                    y_pos  = -y_pos;
                }
                else
                {
                    y_pos = -y_pos;
                }
            }
        }

        // spawn small bubbles for saved files
        shelfFileContainersPositions = new Vector3[NUM_SAVE_SLOTS];

        startDegree_xz = 30.0f;
        if (y_pos >= 0)
        {
            y_pos += 0.3f;
            y_pos  = -y_pos;
        }
        else
        {
            y_pos = -y_pos;
        }

        for (int i = 0; i < NUM_SAVE_SLOTS; i++)
        {
            GameObject container = new GameObject("File Container " + i.ToString());
            container.transform.SetParent(mGadgetShelf.transform);

            float   container_pos_x = shelfRadius * Mathf.Cos(startDegree_xz * (float)Math.PI / 180);
            float   container_pos_z = Mathf.Sin(startDegree_xz * (float)Math.PI / 180);
            Vector3 container_pos   = new Vector3(container_pos_x, y_pos, container_pos_z);
            container.transform.localPosition = container_pos;
            shelfFileContainersPositions[i]   = container_pos;

            // load file bubble
            GameObject bubbleObj = Instantiate(BubblePrefab, container.transform);
            bubbleObj.transform.localScale *= 0.5f;

            // Create gadget
            string   gadgetName      = "LoadCube";
            LoadCube spawnedLoadCube = SpawnSingleGadget(gadgetName, container.transform) as LoadCube;
            Renderer r = spawnedLoadCube.GetComponent <Renderer>();
            r.material.color     = RoomColors[i];
            spawnedLoadCube.Slot = i.ToString();

            startDegree_xz -= 20.0f;
        }
    }