예제 #1
0
    void SpawnMissile()
    {
        RecycleObject missile = missileFactory.Get();

        missile.Activate(GetMissileSpawnPosition(), buildingManager.GetRandomBuildingPosition());
        missile.Destroyed   += OnMissileDestroyed;
        missile.OutOfScreen += OnMissileOutOfScreen;
        missiles.Add(missile);
        currentMissileCount++;
    }
예제 #2
0
    void OnBulletDestroyed(RecycleObject usedBullet)
    {
        Vector3 lastBulletPosition = usedBullet.transform.position;

        usedBullet.Destroyed -= OnBulletDestroyed;
        bulletFactory.Restore(usedBullet);

        RecycleObject explosion = explosionFactory.Get();

        explosion.Activate(lastBulletPosition);
        explosion.Destroyed += OnExplosionDestroyed;

        AudioManager.instance.PlaySound(SoundID.BulletExplosion);
    }
예제 #3
0
    public void OnFireButtonPressed(Vector3 position)
    {
        if (!canShoot)
        {
            return;
        }

        RecycleObject bullet = bulletFactory.Get();

        bullet.Activate(firePosition.position, position);
        bullet.Destroyed += OnBulletDestroyed;

        AudioManager.instance.PlaySound(SoundID.Shoot);

        canShoot = false;
    }
예제 #4
0
    void OnBuildingDestryed(Building building)
    {
        AudioManager.instance.PlaySound(SoundID.BuildingExplosion);

        RecycleObject effect = effectFactory.Get();

        effect.Activate(building.transform.position);
        effect.Destroyed += OnEffectDestroyed;

        building.Destroyed -= OnBuildingDestryed;
        int index = buildings.IndexOf(building);

        buildings.RemoveAt(index);
        GameObject.Destroy(building.gameObject);

        if (buildings.Count == 0)
        {
            AllBuildingsDestroyed?.Invoke();
        }
    }