Пример #1
0
    cShape GetRandomUsedShape(cEnemy vTempEnemy)
    {
        //intialise variable
        cShape vRandomShape = new cShape();

        List <cShape> vShapeList = new List <cShape> ();

        if (vTempEnemy != null)
        {
            //reconstruct the shape we can use
            foreach (cShape vCurShape in vUsedForms)
            {
                if (vTempEnemy.vShape.vColor != vCurShape.vColor || vTempEnemy.vShape.vForm != vCurShape.vForm)
                {
                    vShapeList.Add(vCurShape);
                }
            }
        }
        else
        {
            vShapeList = vUsedForms;
        }

        //get random shape in the list
        vRandomShape = vShapeList[Random.Range(0, vShapeList.Count)];

        //return value
        return(vRandomShape);
    }
Пример #2
0
    //get the new shape
    void ShuffleShapes()
    {
        //flush old variable
        vUsedForms = new List <cShape> ();

        for (int i = 0; i < vNbrButton; i++)
        {
            //create temporary shape
            cShape vNewShape = new cShape();
            vNewShape.vColor = GetRandomColor();            //get a random unique color. Canno have same colors
            vNewShape.vForm  = GetRandomForm();             //get a random form

            //add it to the list
            vUsedForms.Add(vNewShape);
        }

        //refresh button with new shape!
        RefreshButton();
    }
Пример #3
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);
    }