Exemple #1
0
 public void ResetCounter(SkillMeter counter)
 {
     for (int i = 0; i < counters.Length; i++)
     {
         if (counters[i] == counter)
         {
             counterValues[i] = 0;
         }
     }
 }
Exemple #2
0
    private IEnumerator SpawnEnemy(Vector2 tempPosition, float randomFloat, int i)
    {
        yield return(new WaitForSeconds(.5f));

        Debug.Log("Spawning a new Enemy");
        GameObject enemy;

        if (randomFloat < normalizedRarities[0])
        {
            enemy = Instantiate(enemies[0].enemyGameObject, tempPosition, Quaternion.identity);
        }
        else if (randomFloat >= normalizedRarities[0] && randomFloat < normalizedRarities[1])
        {
            enemy = Instantiate(enemies[1].enemyGameObject, tempPosition, Quaternion.identity);
        }
        else if (randomFloat >= normalizedRarities[1] && randomFloat < normalizedRarities[2])
        {
            enemy = Instantiate(enemies[2].enemyGameObject, tempPosition, Quaternion.identity);
        }
        else if (randomFloat >= normalizedRarities[2] && randomFloat < normalizedRarities[3])
        {
            enemy = Instantiate(enemies[3].enemyGameObject, tempPosition, Quaternion.identity);
        }
        else if (randomFloat >= normalizedRarities[3] && randomFloat < normalizedRarities[4])
        {
            enemy = Instantiate(enemies[4].enemyGameObject, tempPosition, Quaternion.identity);
        }
        else
        {
            enemy = Instantiate(enemies[5].enemyGameObject, tempPosition, Quaternion.identity);
        }
        enemy.transform.parent    = this.transform;
        enemy.transform.position += this.transform.position;
        Debug.Log(enemy.name);
        SpriteRenderer sprite             = enemy.GetComponent <SpriteRenderer>();
        Transform      healthBarTransform = enemy.transform.GetChild(0);
        Transform      indicatorTransform = enemy.transform.GetChild(1);
        SkillMeter     enemyHealthBar     = enemy.transform.GetChild(0).gameObject.GetComponent <SkillMeter>();

        healthBarTransform.position   = new Vector2(enemy.transform.position.x, enemy.transform.position.y - sprite.bounds.extents.y);
        healthBarTransform.localScale = new Vector3(0.005f, 0.002f, 0.005f);
        indicatorTransform.position   = new Vector2(enemy.transform.position.x, enemy.transform.position.y + sprite.bounds.extents.y + 0.2f);
        indicatorTransform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
        if (i == remainingMoves % width)
        {
            indicatorTransform.gameObject.GetComponent <SpriteRenderer>().enabled = true;
        }
        else
        {
            indicatorTransform.gameObject.GetComponent <SpriteRenderer>().enabled = false;
        }
        allEnemies[i]    = enemy;
        allIndicators[i] = indicatorTransform;
    }