Ejemplo n.º 1
0
 protected virtual void OnVfxPrefabSpawn(SpawnPrefab logic)
 {
 }
Ejemplo n.º 2
0
        private void ProcessVfx(float dt)
        {
            for (int i = pendingVfxs.Count - 1; i >= 0; i--)
            {
                try {
                    VfxConfig vc = pendingVfxs[i];
                    if (elapsed >= FrameAndSecondsConverter._30Fps.FramesToSeconds(vc.frame))
                    {
                        pendingVfxs.RemoveAt(i);
                        VfxLogic          logic   = null;
                        VfxAction.VfxType vfxType = vc.vfx.ShowVfxType();
                        switch (vfxType)
                        {
                        case VfxAction.VfxType.SpawnPrefab:
                            SpawnPrefabVfx spv    = (SpawnPrefabVfx)vc.vfx;
                            VfxTag         vfxTag = spv.ShowVfxPrefab().GetComponent <VfxTag>();
                            if (vfxTag)
                            {
                                if (vfxTag.tag == VfxTag.Tag.Startup)
                                {
                                    if (isOverrideMode && isOverridingModifierOfSameType)
                                    {
                                        //DLog.Log("Skip spawn startup vfx");
                                        continue;
                                    }

                                    if (!isStartupVfxPlayed)
                                    {
                                        startupVfxCoroutine = Timing.RunCoroutine(LoopStartupVfx_());
                                    }
                                    isStartupVfxPlayed = true;
                                    //DLog.Log("Spawn startup vfx");
                                    startupVfxLogics.Add(new SpawnPrefab(
                                                             vc.ttl, (SpawnPrefabVfx)vc.vfx,
                                                             new Vfx.DefaultVfxGameObjectFactory(environment), target,
                                                             SkillCastingSource.FromUserInput(), environment.GetCamera(),
                                                             environment, null
                                                             ));
                                    continue;
                                }
                            }
                            logic = new SpawnPrefab(
                                vc.ttl, (SpawnPrefabVfx)vc.vfx,
                                new Vfx.DefaultVfxGameObjectFactory(environment), target,
                                SkillCastingSource.FromUserInput(), environment.GetCamera(),
                                environment, null
                                );
                            OnVfxPrefabSpawn((SpawnPrefab)logic);
                            break;

                        case VfxAction.VfxType.ChangeMaterial:
                            logic = new ChangeMaterial(
                                (VfxAction.ChangeMaterialVfx)vc.vfx, vc.ttl, environment, target
                                );
                            break;

                        case VfxAction.VfxType.ChangeMaterialColor:
                            logic = new ChangeMaterialColor(
                                (VfxAction.ChangeMaterialColorVfx)vc.vfx, vc.ttl, environment, target
                                );
                            break;

                        case VfxAction.VfxType.AddMaterial:
                            logic = new AddMaterialLogic(
                                (VfxAction.AddMaterialVfx)vc.vfx, vc.ttl, target
                                );
                            break;

                        default:
                            throw new Exception("Missing logic to create vfx logic of type " + vfxType);
                        }
                        vfxLogics.Add(logic);
                    }
                }
                catch (Exception e) {
                    DLog.LogException(e);
                }
            }

            for (int i = vfxLogics.Count - 1; i >= 0; i--)
            {
                vfxLogics[i].Update(dt);
                if (vfxLogics[i].IsFinish())
                {
                    vfxLogics.RemoveAt(i);
                }
            }
        }