예제 #1
0
    private void GenerateNewObstacleGroup() {
        if (HelperFunctions.ChanceChecker(spawnChance)) {

            GameObject newObs = GetGameObjectFromPool(prefab, pool);
            ObstacleGroup newObsGroup = newObs.GetComponent<ObstacleGroup>();
            newObs.transform.position = startingPosition;
            newObsGroup.Init(RandomObs(), speed);
        }
        Invoke("GenerateNewObstacleGroup", intervalTime);
    }
예제 #2
0
    public void SpawnGroup()
    {
        Vector3 config = configs [Random.Range(0, configs.Length - 1)];

        while (config [(int)ObstacleSpawner.lastEntry.y] == ObstacleSpawner.lastEntry.x)
        {
            config = configs [Random.Range(0, configs.Length - 1)];
        }
        //Debug.Log (config);

        Vector3 groupSpawnPos = new Vector3(0, 0, transform.position.z - spawnRange);

        GameObject groupObject = new GameObject();

        groupObject.transform.position = groupSpawnPos;
        groupObject.tag  = "Obstacle";
        groupObject.name = "Wave" + wave.ToString();

        BoxCollider bc = groupObject.AddComponent <BoxCollider> ();

        bc.isTrigger = true;
        bc.size      = new Vector3(10, 10, 10);



        ObstacleGroup groupScript = groupObject.AddComponent <ObstacleGroup> ();

        groupScript.Initialize(config, groupRotateSpeed, wave);
        wave++;

        //spawn indicator
        Vector3    indicatorSpawnPos = new Vector3(0, -0.5f, transform.position.z - spawnRange);
        Object     indicatorPrefab   = Resources.Load("Prefabs/IndicatorSet");
        GameObject indicator         = (GameObject)GameObject.Instantiate(indicatorPrefab, indicatorSpawnPos, Quaternion.identity);

        groupScript.indicator = indicator;

        GameEngine.rocketMan.PushAssessDifficulty();
    }
예제 #3
0
    public int AssessDifficulty()
    {
        int axis      = currentAxis + 1;
        int direction = currentDirection;

        GameObject groupObject = GameObject.Find("Wave" + (GameEngine.currentWave + 1).ToString());

        if (groupObject == null)
        {
            return(-1);
        }

        ObstacleGroup obstacleGroupScript = groupObject.GetComponent <ObstacleGroup> ();

        if (obstacleGroupScript == null)
        {
            return(-1);
        }
        Vector3 currentConfig = obstacleGroupScript.config;
        int     rotations     = obstacleGroupScript.rotations;

        rotations = rotations - (int)Mathf.Floor(rotations / 3) * 3;

        switch (rotations)
        {
        case 0:
        {
            break;
        }

        case 1:
        {
            currentConfig = new Vector3(currentConfig.y, currentConfig.z, currentConfig.x);
            break;
        }

        case 2:
        {
            currentConfig = new Vector3(currentConfig.z, currentConfig.x, currentConfig.y);
            break;
        }

        default:
        {
            break;
        }
        }

        int numberOfSteps = 0;

        while (currentConfig.y != axis)
        {
            if (axis == 2)
            {
                direction = -1;
            }
            if (axis == 0)
            {
                direction = 1;
            }

            axis += direction;

            numberOfSteps++;
            currentConfig = new Vector3(currentConfig.y, currentConfig.z, currentConfig.x);
        }


        return(numberOfSteps);
    }