public void PlayVfx(VfxList inLabel, Vector2 inPosition) { var map = GetVfxMap(inLabel); if (map == null) { throw new Exception($"Vfx {inLabel} not found!"); } IVfx gameVfx = null; switch (map.type) { case VfxType.Animation: gameVfx = GetAnimationVfx(map); break; case VfxType.ParticleSystem: gameVfx = GetParticleVfx(map); break; } if (gameVfx == null) { throw new Exception($"Vfx Is null !"); } VfxList.Add(gameVfx); //- add vfx to level view SystemFacade.Level.Level.AddVfx(gameVfx, new Vector2(inPosition.x, inPosition.y)); //- play sound effect if (map.sfx != SoundList.None) { SystemFacade.Sounds.PlaySfx(map.sfx); } gameVfx?.Play(); }
private VfxMap GetVfxMap(VfxList inLabel) => _config.vfxMap.FirstOrDefault(v => v.label == inLabel);