Пример #1
0
    private void OnBatDestroyed(BatAI bat)
    {
        //If we miss this, it will stack up
        bat.DestroyedAction -= OnBatDestroyed;

        //Return the object to the pool
        componentPool.ReturnObject(bat);
    }
Пример #2
0
    protected override void Spawn()
    {
        BatAI batAI = componentPool.GetObject() as BatAI;

        //Get spawn location
        Transform spawnTransform = GetSpawnLocation();

        //Set spawn location to new bat
        batAI.transform.position = spawnTransform.position;

        batAI.Initialize(potatoPile);

        batAI.DestroyedAction += OnBatDestroyed;

        batAI.gameObject.SetActive(true);
    }
Пример #3
0
    private void EnableEnemy(GameObject enemy)
    {
        EnemyTrigger eT = enemy.GetComponentInChildren <EnemyTrigger>();

        eT.active = true;

        Collider2D[] enemyColliders = enemy.GetComponentsInChildren <Collider2D>();
        for (int i = 0; i < enemyColliders.Length; i++)
        {
            enemyColliders[i].enabled = true;
        }

        NeedleAI n = enemy.GetComponent <NeedleAI>();
        WaspAI   w = enemy.GetComponent <WaspAI>();
        BatAI    b = enemy.GetComponent <BatAI>();
        MoleAI   m = enemy.GetComponent <MoleAI>();
        SlugAI   s = enemy.GetComponent <SlugAI>();

        if (n != null)
        {
            n.enabled = true;
        }
        else if (w != null)
        {
            w.enabled = true;
        }
        else if (b != null)
        {
            b.enabled = true;
        }
        else if (m != null)
        {
            m.enabled = true;
        }
        else if (s != null)
        {
            s.enabled = true;
        }
        else
        {
            Debug.LogWarning(enemy + " is no enemy");
        }
    }