Пример #1
0
    protected virtual void Spawn(int num)
    {
        Vector3 pos = Vector3.zero;

        while (num > 0)
        {
            //spawn an object
            do
            {
                if (quadrant == 0)
                {
                    pos = new Vector3(Random.Range(min, max) * grid, 0, Random.Range(min, max) * grid);
                }
                else if (quadrant == 1)
                {
                    pos = new Vector3(-Random.Range(min, max) * grid, 0, Random.Range(min, max) * grid);
                }
                else if (quadrant == 2)
                {
                    pos = new Vector3(Random.Range(min, max) * grid, 0, -Random.Range(min, max) * grid);
                }
                else if (quadrant == 3)
                {
                    pos = new Vector3(-Random.Range(min, max) * grid, 0, -Random.Range(min, max) * grid);
                }
            } while (!voidControl.IsPositionUnique(pos));

            voidControl.usedPositions.Add(pos);
            GameObject clone = (GameObject)Instantiate(objectToClone, pos, Quaternion.identity);
            num--;
            quadrant = (quadrant + 1) % 4;
        }
    }
Пример #2
0
    protected void Spawn(int num)
    {
        pitch = 1f;
        Vector3 pos = Vector3.zero;

        while (num > 0)
        {
            //spawn a key
            do
            {
                if (quadrant == 0)
                {
                    pos = new Vector3(Random.Range((int)min, (int)max) * grid, 0, Random.Range((int)min, (int)max) * grid);
                }
                else if (quadrant == 1)
                {
                    pos = new Vector3(-Random.Range((int)min, (int)max) * grid, 0, Random.Range((int)min, (int)max) * grid);
                }
                else if (quadrant == 2)
                {
                    pos = new Vector3(Random.Range((int)min, (int)max) * grid, 0, -Random.Range((int)min, (int)max) * grid);
                }
                else if (quadrant == 3)
                {
                    pos = new Vector3(-Random.Range((int)min, (int)max) * grid, 0, -Random.Range((int)min, (int)max) * grid);
                }
            } while (!voidControl.IsPositionUnique(pos));

            voidControl.usedPositions.Add(pos);
            GameObject clone = (GameObject)Instantiate(keyObj, pos, Quaternion.identity);
            levelManager.keys.Add(clone);
            clone.GetComponent <AudioSource>().pitch = pitch;

            num--;
            quadrant = (quadrant + 1) % 4;
            pitch   += 0.5f;
        }
    }
Пример #3
0
    protected void Spawn(int num)
    {
        Vector3 pos = Vector3.zero;

        while (num > 0)
        {
            //spawn an enemy
            do
            {
                if (quadrant == 0)
                {
                    pos = new Vector3(Random.Range((int)min, (int)max) * grid, 0, Random.Range((int)min, (int)max) * grid);
                }
                else if (quadrant == 1)
                {
                    pos = new Vector3(-Random.Range((int)min, (int)max) * grid, 0, Random.Range((int)min, (int)max) * grid);
                }
                else if (quadrant == 2)
                {
                    pos = new Vector3(Random.Range((int)min, (int)max) * grid, 0, -Random.Range((int)min, (int)max) * grid);
                }
                else if (quadrant == 3)
                {
                    pos = new Vector3(-Random.Range((int)min, (int)max) * grid, 0, -Random.Range((int)min, (int)max) * grid);
                }
            } while (!voidControl.IsPositionUnique(pos));

            voidControl.usedPositions.Add(pos);
            GameObject clone = (GameObject)Instantiate(enemyObj, pos, Quaternion.identity);
            levelManager.enemies.Add(clone);
            num--;
            quadrant = (quadrant + 1) % 4;
        }

        EventManager.TriggerEvent(messages.readyToSpawnKeys);
    }