Beispiel #1
0
    public void Die(BubbleDeathType deathType)
    {
        SetState(BubbleState.DYING);
        transform.DOKill();

        switch (deathType)
        {
        case BubbleDeathType.SILENT:
            Die();
            break;

        case BubbleDeathType.EXPLOSION:
            Root.Instance.AudioManager.Play(AudioManager.SFXType.BubbleExplode);
            ParticleEffectBase newParticles = ObjectPool.Spawn <ParticleEffectBase>(vfxExplosion, transform.position, Quaternion.identity);
            newParticles.Init(bubblesConfig.ExplosionColorForPower(Power));
            Die();
            break;

        case BubbleDeathType.DROP:
            rb.bodyType = RigidbodyType2D.Dynamic;
            //TODO: Move to config?
            Vector2 force = Vector2.up * 3 + Vector2.right * (UnityEngine.Random.value < .5f ? 1 : -1) * 3f;
            rb.AddForce(force, ForceMode2D.Impulse);

            //Wait until bubble falls under the screen
            Timers.Instance.WaitForTrue(() => { return(transform.position.y < -10f); })
            .Done(() => Die());
            break;

        default:
            Debug.LogError($"Unknown death type {deathType}");
            break;
        }
    }
Beispiel #2
0
    public void AddPowerUpEffect(GameObject parent, AnimationType type, BubbleDeathType deathType)
    {
        if (!(DeathSequence is PowerUpBubbleDeathSequence))
        {
            DeathSequence = new PowerUpBubbleDeathSequence(gameObject, DeathSequence.EffectDictionary);
        }

        AddBlockingEffect(parent, type, deathType);
    }
Beispiel #3
0
        virtual public void Play(BubbleDeathType type)
        {
            Play();

            var effects = EffectDictionary.ContainsKey(type) ? EffectDictionary[type] : GetDefaultEffects(type);

            foreach (var effect in effects)
            {
                effectController.AddEffect(effect);
            }
        }
Beispiel #4
0
        public void AddEffect(GameObject parent, AnimationType type, BubbleDeathType deathType, bool blocking)
        {
            if (!EffectDictionary.ContainsKey(deathType))
            {
                EffectDictionary.Add(deathType, new List <IEnumerator>());
            }

            var effect = blocking ? AnimationEffect.PlayAndRegister(parent, type, RegisterBlockers) :
                         AnimationEffect.Play(parent, type);

            EffectDictionary[deathType].Add(effect);
        }
Beispiel #5
0
    public void Die(BubbleDeathType type)
    {
        dying = true;

        GetComponent <Rigidbody2D>().isKinematic = true;
        Util.FrameUtil.AfterFrames(DEACTIVATION_DELAY, DeactivateObjects);

        var sounds = GetComponent <BubbleModelBehaviour>().Model.definition.Sounds;

        Sound.PlaySoundEvent.Dispatch((type == BubbleDeathType.Pop) ? sounds.match : sounds.cull);

        DeathSequence.Play(type);
    }
Beispiel #6
0
    public static void KillBubble(GameObject bubble, BubbleDeathType type)
    {
        var death = bubble.GetComponent <BubbleDeath>();

        if (death == null)
        {
            Destroy(bubble);
        }
        else if (!death.dying)
        {
            death.Die(type);
        }
    }
Beispiel #7
0
        private List <IEnumerator> GetDefaultEffects(BubbleDeathType type)
        {
            var effects = new List <IEnumerator>();
            var model   = gameObject.GetComponent <BubbleModelBehaviour>().Model;

            if (model.definition.AnimationMap.ContainsKey(type))
            {
                foreach (var animationType in model.definition.AnimationMap[type])
                {
                    effects.Add(AnimationEffect.PlayAndRegister(gameObject, animationType, RegisterBlockers));
                }
            }

            return(effects);
        }
Beispiel #8
0
 public void AddBlockingEffect(GameObject parent, AnimationType type, BubbleDeathType deathType)
 {
     DeathSequence.AddEffect(parent, type, deathType, true);
 }
Beispiel #9
0
 override public void Play(BubbleDeathType type)
 {
     timeToWait = GlobalState.Instance.Config.powerUp.popOrderDelay;
     base.Play(type);
 }