コード例 #1
0
 void OnTriggerExit2D(Collider2D coll)
 {
     if (coll.tag == "Enemy")
     {
         BoomEnemy enemy = coll.GetComponent <BoomEnemy>();
         enemiesInRange.Remove(enemy);
     }
 }
コード例 #2
0
ファイル: BoomEnemyManager.cs プロジェクト: Xelareip/Osmos
    public void Spawn()
    {
        GameObject newEnemy = Instantiate(enemyModel,
                                          Quaternion.AngleAxis(Random.Range(0.0f, 360.0f), Vector3.forward) * new Vector3(1.0f, 1.0f, 0.0f) * spawnDist * Random.Range(1.0f - spawnDistanceVariation, 1.0f + spawnDistanceVariation) * BoomPlayer.Instance.transform.localScale.x,
                                          Quaternion.identity);
        BoomEnemy enemy = newEnemy.GetComponent <BoomEnemy>();

        enemy.strength = BoomPlayer.Instance.strength * scales[Random.Range(0, scales.Count)];
        newEnemy.transform.localScale = Vector3.one * (BoomPlayer.Instance.transform.localScale.x * enemy.strength / BoomPlayer.Instance.strength);
    }
コード例 #3
0
ファイル: BoomPlayer.cs プロジェクト: Xelareip/Osmos
    private IEnumerator AbsorbEnemies(List <BoomEnemy> enemiesAbsorbed)
    {
        BoomEnemyManager.Instance.pause = true;
        while (enemiesAbsorbed.Count > 0)
        {
            BoomEnemy enemy = enemiesAbsorbed[enemiesAbsorbed.Count - 1];

            float strengthIncrease = 1.0f + (enemy.strength / strength);
            enemiesAbsorbed.Remove(enemy);
            DestroyImmediate(enemy.rig);
            DestroyImmediate(enemy.GetComponent <Collider2D>());
            enemy.enabled = false;
            Vector3 toGo       = transform.position - enemy.transform.position;
            float   enemySpeed = toGo.magnitude * Parameters.Instance.absorbSpeed;
            while (toGo != Vector3.zero && toGo.magnitude > (transform.localScale.x - enemy.transform.localScale.x) / 2.0f)
            {
                yield return(new WaitForEndOfFrame());

                enemy.transform.position += toGo.normalized * Mathf.Min(toGo.magnitude, enemySpeed * Time.deltaTime);
                toGo = transform.position - enemy.transform.position;
            }

            if (enemy.strength <= strength)
            {
                yield return(new WaitForSeconds(0.1f));

                score += (strengthIncrease - 1.0f) * 10.0f;
                transform.localScale *= strengthIncrease;
                strength             *= strengthIncrease;
                Destroy(enemy.gameObject);
            }
            else
            {
                EndGame();
                enemiesAbsorbed.Remove(enemy);
                enemy.gameObject.transform.localScale      *= strengthIncrease;
                GetComponentInChildren <Renderer>().enabled = false;
                break;
            }
        }
        power = 0.0f;
        BoomEnemyManager.Instance.pause = false;
        yield return(null);
    }
コード例 #4
0
ファイル: BoomPlayer.cs プロジェクト: Xelareip/Osmos
    private bool ZoomOut()
    {
        if (transform.localScale.x <= 1.0f)
        {
            return(false);
        }

        float reduceVal             = Mathf.Min(Mathf.Max(transform.localScale.x - 1.0f, 1.0f) * Time.deltaTime * zoomOutSpeed, transform.localScale.x - 1.0f);
        float proportionalReduction = reduceVal / transform.localScale.x;

        transform.localScale      = (transform.localScale.x - reduceVal) * Vector3.one;
        wave.transform.localScale = (wave.transform.localScale.x - reduceVal) * Vector3.one;
        background.zoom          *= 1.0f + proportionalReduction;

        for (int enemyIdx = 0; enemyIdx < BoomEnemyManager.Instance.enemies.Count; ++enemyIdx)
        {
            BoomEnemy currentEnemy = BoomEnemyManager.Instance.enemies[enemyIdx];

            if (currentEnemy == null)
            {
                continue;
            }

            if (currentEnemy.transform.localScale.x - reduceVal < 0.05f)
            {
                Destroy(currentEnemy.gameObject);
            }
            else
            {
                currentEnemy.transform.localScale -= currentEnemy.transform.localScale * proportionalReduction;

                currentEnemy.transform.position -= currentEnemy.transform.position * proportionalReduction;
                if (currentEnemy.rig != null)
                {
                    currentEnemy.rig.velocity -= currentEnemy.rig.velocity * proportionalReduction;
                }
            }
        }
        return(true);
    }
コード例 #5
0
ファイル: BoomEnemyManager.cs プロジェクト: Xelareip/Osmos
 public void UnregisterEnemy(BoomEnemy enemy)
 {
     enemies.Remove(enemy);
 }
コード例 #6
0
ファイル: BoomEnemyManager.cs プロジェクト: Xelareip/Osmos
 public void RegisterEnemy(BoomEnemy enemy)
 {
     enemies.Add(enemy);
 }