示例#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();
        }
    }