Exemplo n.º 1
0
    public void addConstructPlace(Vector3 pos, int type)
    {
        GameObject[]     neuGO = new GameObject[constructPlacesGO.Length + 1];
        ConstructPlace[] neu   = new ConstructPlace[constructPlaces.Length + 1];
        for (int i = 0; i < constructPlaces.Length; i++)
        {
            neuGO[i] = constructPlacesGO[i];
            neu[i]   = constructPlaces[i];
        }
        switch (type)
        {
        case 0:
            pos = new Vector3(pos.x, pos.y, pos.z);
            neuGO[constructPlacesGO.Length] = Instantiate(constructSmall, pos, new Quaternion());
            neu[constructPlaces.Length]     = new ConstructPlace(pos, type);
            break;

        case 1:
            pos = new Vector3(pos.x, pos.y + 0.5f, pos.z);
            neuGO[constructPlacesGO.Length] = Instantiate(constructLarge, pos, new Quaternion());
            neu[constructPlaces.Length]     = new ConstructPlace(pos, type);
            break;
        }
        constructPlacesGO = neuGO;
        constructPlaces   = neu;
        save(GetComponent <World>().LevelName);
    }
Exemplo n.º 2
0
    public void deleteObject(GameObject obj)
    {
        for (int i = 0; i < constructPlacesGO.Length; i++)
        {
            if (obj.Equals(constructPlacesGO[i]))
            {
                GameObject[]     neuGO = new GameObject[constructPlacesGO.Length - 1];
                ConstructPlace[] neu   = new ConstructPlace[constructPlaces.Length - 1];

                for (int a = 0; a < i; a++)
                {
                    neuGO[a] = constructPlacesGO[a];
                    neu[a]   = constructPlaces[a];
                }
                for (int b = i; b < neuGO.Length; b++)
                {
                    neuGO[b] = constructPlacesGO[b + 1];
                    neu[b]   = constructPlaces[b + 1];
                }
                constructPlacesGO = neuGO;
                constructPlaces   = neu;
                Destroy(obj);
                save(GetComponent <World>().LevelName);
                return;
            }
        }
        for (int i = 0; i < containerGO.Length; i++)
        {
            if (obj.Equals(containerGO[i]))
            {
                GameObject[] neuGO = new GameObject[containerGO.Length - 1];
                Container[]  neu   = new Container[container.Length - 1];

                for (int a = 0; a < i; a++)
                {
                    neuGO[a] = containerGO[a];
                    neu[a]   = container[a];
                }
                for (int b = i; b < neuGO.Length; b++)
                {
                    neuGO[b] = containerGO[b + 1];
                    neu[b]   = container[b + 1];
                }
                containerGO = neuGO;
                container   = neu;
                Destroy(obj);
                save(GetComponent <World>().LevelName);
                return;
            }
        }
        for (int i = 0; i < lightGO.Length; i++)
        {
            if (obj.Equals(lightGO[i]))
            {
                GameObject[]  neuGO = new GameObject[lightGO.Length - 1];
                LightSource[] neu   = new LightSource[light.Length - 1];

                for (int a = 0; a < i; a++)
                {
                    neuGO[a] = lightGO[a];
                    neu[a]   = light[a];
                }
                for (int b = i; b < neuGO.Length; b++)
                {
                    neuGO[b] = lightGO[b + 1];
                    neu[b]   = light[b + 1];
                }
                lightGO = neuGO;
                light   = neu;
                Destroy(obj);
                save(GetComponent <World>().LevelName);
                return;
            }
        }
        for (int i = 0; i < spawnGO.Length; i++)
        {
            if (obj.Equals(spawnGO[i]))
            {
                GameObject[] neuGO = new GameObject[spawnGO.Length - 1];
                SpawnPoint[] neu   = new SpawnPoint[spawn.Length - 1];

                for (int a = 0; a < i; a++)
                {
                    neuGO[a] = spawnGO[a];
                    neu[a]   = spawn[a];
                }
                for (int b = i; b < neuGO.Length; b++)
                {
                    neuGO[b] = spawnGO[b + 1];
                    neu[b]   = spawn[b + 1];
                }
                spawnGO = neuGO;
                spawn   = neu;
                Destroy(obj);
                save(GetComponent <World>().LevelName);
                return;
            }
        }
    }