Пример #1
0
    //check which mod we are and spawn a random enemy in the list on a random line
    void SpawnNewEnemy()
    {
        //get a random enemy in the current game mod
        GameObject vNewEnemy = Instantiate(vCurGameType.vEnemyList[Random.Range(0, vCurGameType.vEnemyList.Count)]);

        //we randomize all the enemy for all mobs but SIMPLE
        vNewEnemy.GetComponent <cEnemy> ().Initialise(this);

        cSpawnList vRandomSpawn = vSpawnList [Random.Range(0, vSpawnList.Count)];

        //get a random spawn position now
        vNewEnemy.transform.position = vRandomSpawn.vSpawnObject.transform.position;

        //make this enemy a child of the current line to be able to delete it when game is finish
        vNewEnemy.transform.parent = vRandomSpawn.vSpawnObject.transform;
    }
Пример #2
0
    //check which mod we are and spawn a random enemy in the list on a random line
    cEnemy SpawnNewEnemy(int vIndex, cEnemy vTempEnemy = null)
    {
        //get a random enemy in the current game mod
        GameObject vNewEnemy = Instantiate(vEnemyPrefab);

        //modify the enemy (shape + color)
        cShape vNewShape = new cShape();

        vNewShape = GetRandomUsedShape(vTempEnemy);

        //get it's componnet
        cEnemy vEnemy = vNewEnemy.GetComponent <cEnemy> ();

        //send it's shape to the enemy to be used when we try to destroy it
        vEnemy.vShape = vNewShape;

        //create enemy border
        vEnemy.vBorder.sprite = Resources.Load <Sprite> ("Enemies/" + vNewShape.vForm + "/Border");

        //change the inside sprite on the button
        vEnemy.vInside.sprite = Resources.Load <Sprite> ("Enemies/" + vNewShape.vForm + "/Inside");
        vEnemy.vInside.color  = vNewShape.vColor;

        //we randomize all the enemy for all mobs but SIMPLE
        vEnemy.Initialise(this);

        //check if we spawn to a random spawn location
        if (vIndex == -1)
        {
            vIndex = Random.Range(0, vNbrSpawnLoc);
        }

        //spawn it on the correct location
        cSpawnList vRandomSpawn = vSpawnList [vIndex];

        //get a random spawn position now
        vNewEnemy.transform.position = vRandomSpawn.vSpawnObject.transform.position;

        //make this enemy a child of the current line to be able to delete it when game is finish
        vNewEnemy.transform.parent = vRandomSpawn.vSpawnObject.transform;
        vRandomSpawn.vSpawnList.Add(vNewEnemy);

        //increase counter
        vEnemyCount++;

        //mean we are about to change round
        //add some more enemy to fight between each chang of colors so the rounds are longer each time
        //cannot have more than 50 enemy to kills
        if (vEnemyCount >= GetMaxNbr())
        {
            vRound++;
            vRoundCounter++;

            //play alert sound!
            PlaySound(vChangingButtonSound, 1f);

            //show alert
            vAlertText.SetActive(true);

            //also check if we need to add new button. Cannot add more than 4x button
            if (vRound >= vRoundtimer && vNbrButton < 4)
            {
                vAction = "ChangeRound";
            }
            else
            {
                vAction = "JustShuffle";
            }

            //reset counter
            vEnemyCount = 0;
        }

        return(vEnemy);
    }