Esempio n. 1
0
    /// <summary>
    /// This fucntion is used to spawn a number of monsters.
    /// </summary>
    IEnumerator SpawnEnemies(int num)
    {
        while (_monsters.Count < num)
        {
            GameObject monster = Instantiate(_monsterPrefabs[Random.Range(0, _monsterPrefabs.Count)], transform.position, Quaternion.identity);
            Vector3    vel     = Random.onUnitSphere * Random.Range(2, 5);
            monster.GetComponent <Rigidbody>().velocity = vel;
            PlayerInfoScript player = PlayerInfoScript.instance;
            //If the PlayerInfoScript exists (started game from menu)
            if (player)
            {
                //Each level is offset but 10 levels to make it more challenging in other groups
                int level = player.GetCurrentGroup() * 25 + player.GetLevelInSugarGroup(player.GetCurrentGroup());
                monster.GetComponent <MonsterScript>().InitMonster(_cameraTransform.position, _radius, _canvas, level);
            }
            else //For testing purposes
            {
                monster.GetComponent <MonsterScript>().InitMonster(_cameraTransform.position, _radius, _canvas, 0);
            }

            monster.transform.LookAt(_cameraTransform.position);
            _monsters.Add(monster);
            yield return(null);
        }
    }
Esempio n. 2
0
    /// <summary>
    /// This fucntion is used to spawn a number of monsters.
    /// </summary>
    IEnumerator SpawnEnemies(int num)
    {
        PlayerInfoScript player = PlayerInfoScript.instance;
        int index;

        if (player)
        {
            index = player.GetCurrentGroup();
        }
        else
        {
            index = 0;
        }

        // set monsters depending on the current chosen sugar type
        switch (index)
        {
        // cane
        case 0:
            _chosenMonster = _caneMonster;
            break;

        // concentrate
        case 1:
            _chosenMonster = _concentrateMonster;
            break;

        // dextrin
        case 2:
            _chosenMonster = _dextrinMonster;
            break;

        // Obvios
        case 3:
            _chosenMonster = _obviosMonster;
            break;

        // ose
        case 4:
            _chosenMonster = _OSEMonster;
            break;

        // strange
        case 5:
            _chosenMonster = _strangeMonster;
            break;

        // syrup
        case 6:
            _chosenMonster = _syrupMonster;
            break;

        default:
            _chosenMonster = _caneMonster;
            break;
        }

        while (_monsters.Count < num)
        {
            player = PlayerInfoScript.instance;
            GameObject monster = Instantiate(_chosenMonster, transform.position, Quaternion.identity);
            // generate random velocity random
            Vector3 vel = Random.onUnitSphere * Random.Range(2, 5);
            // setting the velocity
            monster.GetComponent <Rigidbody>().velocity = vel;

            //If the PlayerInfoScript exists (started game from menu)
            if (player)
            {
                //Each level is offset but 10 levels to make it more challenging in other groups
                int level = player.GetLevelInSugarGroup(player.GetCurrentGroup());
                print("level: " + level);
                monster.GetComponent <MonsterScript>().InitMonster(_cameraTransform.position, _radius, _canvas, level);//leveling setting here ##############
            }
            else //For testing purposes
            {
                monster.GetComponent <MonsterScript>().InitMonster(_cameraTransform.position, _radius, _canvas, 0);
            }

            monster.transform.LookAt(_cameraTransform.position);
            _monsters.Add(monster);
            yield return(null);
        }
    }