private void PlayComponentsDestroyEffect()
        {
            AbstractComponentEffect effect = AbstractComponentEffect.LoadRandomEffect();

            effect.transform.position = GetMountPointAtRandom(Space.World);
            effect.Initaizlie();

            LayerManager.GetInstance().AddObject(effect.transform);
        }
Beispiel #2
0
        private IEnumerator ExplosionProcessor()
        {
            bool isCompleted = false;

            GetContext().Play(AnimationDefs.Explosion.ToString().ToLower());

            MonsterData        monster           = GetContext().data as MonsterData;
            tk2dSpriteAnimator explosionAnimator = ResourceUtils.GetComponent <tk2dSpriteAnimator>(GlobalDefinitions.RESOURCE_PATH_EFFECT_EXPLOSION + monster.explosionID);

            explosionAnimator.transform.SetParent(GetContext().transform);
            explosionAnimator.transform.position = GetContext().GetMountPoint(ComponentDefs.Body).position;

            explosionAnimator.AnimationCompleted = (tk2dSpriteAnimator animator, tk2dSpriteAnimationClip clip) =>
            {
                animator.AnimationCompleted = null;
                GameObject.Destroy(animator.gameObject);

                DeadProcessor();

                isCompleted = true;
            };

            float time = default(float);

            while (!isCompleted)
            {
                if (time > 0.5)
                {
                    AbstractComponentEffect effect = AbstractComponentEffect.LoadRandomEffect();
                    effect.transform.position = GetContext().GetMountPointAtRandom(Space.World);
                    effect.Initaizlie();

                    LayerManager.GetInstance().AddObject(effect.transform);

                    time = default(float);
                }

                time += Time.deltaTime;

                yield return(null);
            }

            for (int index = 0, amount = Random.Range(3, 5); index < amount; index++)
            {
                AbstractComponentEffect effect = AbstractComponentEffect.LoadRandomEffect();
                effect.transform.position = GetContext().GetMountPointAtRandom(Space.World);
                effect.Initaizlie();

                LayerManager.GetInstance().AddObject(effect.transform);
            }
        }