public override ISyncScenarioItem Apply(CastContext castContext, int abilityLevel) { var linesCollider = PrefabHelper.Intantiate(_linesColliderPrefab, Game.Instance.gameObject); linesCollider.transform.position = castContext.Caster.Position; linesCollider.transform.localScale = Vector3.one; linesCollider.OnTrigger += (unit) => { if (unit.PlayerId != castContext.Caster.PlayerId) { DamageSystem.ApplyDamage(castContext.Caster, _damage.GetValue(abilityLevel), unit); } }; var renderers = linesCollider.GetComponentsInChildren <Renderer>(); return(new SyncScenario( new List <ISyncScenarioItem> { new ActionScenarioItem(() => { FMODUnity.RuntimeManager.PlayOneShot("event:/Explosion"); }), new AlphaTween(renderers, 0), new AlphaTween(renderers, 1, 0.1f, EaseType.QuadIn), new AlphaTween(renderers, 0, 0.3f, EaseType.QuadOut) }, (s, interrupted) => Object.Destroy(linesCollider.gameObject) ).PlayRegisterAndReturnSelf()); }
public override ISyncScenarioItem Apply(CastContext castContext, int abilityLevel) { var effect = PrefabHelper.Intantiate(_explosionEffectPrefab, Game.Instance.gameObject); effect.transform.position = castContext.Caster.Position; effect.transform.localScale = Vector3.zero; var radius = _radius.GetValue(abilityLevel); var targets = MapController.Instance.GetEnemiesInArea(castContext.Caster.Position, radius, castContext.Caster.PlayerId); for (int i = 0; i < targets.Count; i++) { DamageSystem.ApplyDamage(castContext.Caster, _damage.GetValue(abilityLevel), targets[i]); } return(new SyncScenario( new List <ISyncScenarioItem> { new ActionScenarioItem(() => { FMODUnity.RuntimeManager.PlayOneShot("event:/Explosion"); }), new AlphaTween(effect, 1), new ScaleTween(effect, 10 * radius * Vector3.one, 0.5f, EaseType.QuadIn), new AlphaTween(effect, 0, 0.3f, EaseType.QuadOut) }, (s, interrupted) => Object.Destroy(effect.gameObject) ).PlayRegisterAndReturnSelf()); }
private void addInstances(int count) { for (int i = 0; i < count; i++) { T instance = PrefabHelper.Intantiate(prefab, Container); instance.gameObject.SetActive(false); instances.Push(instance); } }
public override ISyncScenarioItem Apply(CastContext castContext, int abilityLevel) { var directions = _directions[_index].GetDirections(); _index = _index + 1 >= _directions.Length ? 0 : _index + 1; var items = new List <ISyncScenarioItem>(); foreach (var direction in directions) { var effect = PrefabHelper.Intantiate(_explosionEffectPrefab, Game.Instance.gameObject); effect.transform.position = castContext.Caster.Position + direction * _distance; effect.transform.localScale = Vector3.zero; var radius = _radius.GetValue(abilityLevel); items.Add(new SyncScenario( new List <ISyncScenarioItem> { new AlphaTween(effect, 1), new ScaleTween(effect, 10 * radius * Vector3.one, 0.5f, EaseType.QuadIn), new ActionScenarioItem(() => { FMODUnity.RuntimeManager.PlayOneShot("event:/Gas"); }), new ActionScenarioItem(() => { var targets = MapController.Instance.GetEnemiesInArea(effect.transform.position, radius, castContext.Caster.PlayerId); for (int i = 0; i < targets.Count; i++) { if (!DamageSystem.ApplyDamage(castContext.Caster, _damage.GetValue(abilityLevel), targets[i])) { targets[i].AddEffect(new CharacterEffect(EffectOnTouch, abilityLevel)); } } }), new AlphaTween(effect, 0, 0.3f, EaseType.QuadOut) }, (s, interrupted) => Object.Destroy(effect.gameObject) )); } return(new CompositeItem(items).PlayRegisterAndReturnSelf()); }