public List <SceneAnimation> RemoveEffect(BattleEffect Effect, bool NaturalRemoval) { List <SceneAnimation> Animations = new List <SceneAnimation>(); AllEffects[Effect.CurrentPlacement].RemoveEffect(Effect); foreach (EffectScript Script in Effect.Scripts) { if (NaturalRemoval) { if (Script.Trigger == EffectTrigger.ON_EFFECT_TIMEOUT) { Animations.AddRange(InterpretEffect(Effect, Script, Effect.User, null, Effect.CurrentPlacement)); } if (Script.Trigger == EffectTrigger.ON_STAND_EXIT) { if (Effect.CurrentPlacement == Player1.Placement && !AllEffects[Player1.Placement].HasEffectGroup(Effect.GetEffectGroup())) { if (Effect.EffectAnimation != null) { Animations.Add(Effect.EffectAnimation); } Animations.AddRange(InterpretEffect(Effect, Script, Effect.User, Player1, Effect.CurrentPlacement)); } else if (Effect.CurrentPlacement == Player2.Placement && !AllEffects[Player2.Placement].HasEffectGroup(Effect.GetEffectGroup())) { if (Effect.EffectAnimation != null) { Animations.Add(Effect.EffectAnimation); } Animations.AddRange(InterpretEffect(Effect, Script, Effect.User, Player2, Effect.CurrentPlacement)); } } SortedEffects[Script.Trigger][Script.Speed].Remove(Effect); if (Effect.CurrentPlacement < 8) { Interpreter.SetPrevElement(Effect.Element); //TODO: HIGHLY LIKELY A BETTER WAY OF DOING ALL THIS Animations.AddRange(RunTriggerTypeEffect(EffectTrigger.ON_OTHER_EFFECT_TIMEOUT, Effect.User, true)); } } else { if (Script.Trigger == EffectTrigger.ON_EFFECT_EXIT) { Interpreter.SetPrevElement(Effect.Element); Animations.AddRange(InterpretEffect(Effect, Script, Effect.User, null, Effect.CurrentPlacement)); } if (Script.Trigger == EffectTrigger.ON_STAND_EXIT) { if (Effect.CurrentPlacement == Player1.Placement && !AllEffects[Player1.Placement].HasEffectGroup(Effect.GetEffectGroup())) { if (Effect.EffectAnimation != null) { Animations.Add(Effect.EffectAnimation); } Animations.AddRange(InterpretEffect(Effect, Script, Effect.User, Player1, Effect.CurrentPlacement)); } else if (Effect.CurrentPlacement == Player2.Placement && !AllEffects[Player2.Placement].HasEffectGroup(Effect.GetEffectGroup())) { if (Effect.EffectAnimation != null) { Animations.Add(Effect.EffectAnimation); } Animations.AddRange(InterpretEffect(Effect, Script, Effect.User, Player2, Effect.CurrentPlacement)); } } SortedEffects[Script.Trigger][Script.Speed].Remove(Effect); if (Effect.CurrentPlacement < 8) { Interpreter.SetPrevElement(Effect.Element); Animations.AddRange(RunTriggerTypeEffect(EffectTrigger.ON_OTHER_EFFECT_EXIT, Effect.User, true)); } } } if (Effect.CurrentPlacement < 8) { Animations.Add(new SceneAnimation(SceneAnimation.SceneAnimationType.REMOVE_EFFECT, new double[] { Effect.CurrentPlacement, Effect.GetEffectGroup() }, Effect.Name)); } return(Animations); }
public List <SceneAnimation> AddEffect(BattleEffect OriginalEffect, Player User) { List <SceneAnimation> Animations = new List <SceneAnimation>(); foreach (byte Placement in OriginalEffect.Placement) { BattleEffect Effect = new BattleEffect(OriginalEffect, User); if (Placement < 8) { if (Effect.User == Player1) { Effect.CurrentPlacement = (byte)((Placement + ArenaOrientation) % 8); } else { Effect.CurrentPlacement = (byte)((Placement + ArenaOrientation + 4) % 8); } } if (AllEffects[Effect.CurrentPlacement].CanAddEffect()) { Effect.SetEffectGroup(EffectGroups); foreach (EffectScript Script in Effect.Scripts) { if (Script.Trigger == EffectTrigger.ON_EFFECT_ENTER) { Animations.AddRange(InterpretEffect(Effect, Script, User, null, Effect.CurrentPlacement)); } } if (Placement < 8) { Animations.Add(new SceneAnimation(SceneAnimation.SceneAnimationType.ADD_EFFECT, new double[] { Effect.CurrentPlacement, Effect.GetEffectGroup() }, Effect.Name)); Animations.AddRange(RunTriggerTypeEffect(EffectTrigger.ON_NEW_TILE_PLACED, User, true)); foreach (EffectScript Script in Effect.Scripts) { if (Script.Trigger == EffectTrigger.ON_STAND_ENTER) { if (Effect.CurrentPlacement == Player1.Placement && !AllEffects[Player1.Placement].HasEffectGroup(Effect.GetEffectGroup())) { if (Effect.EffectAnimation != null) { Animations.Add(Effect.EffectAnimation); } Animations.AddRange(InterpretEffect(Effect, Script, Effect.User, Player1, Effect.CurrentPlacement)); } else if (Effect.CurrentPlacement == Player2.Placement && !AllEffects[Player2.Placement].HasEffectGroup(Effect.GetEffectGroup())) { if (Effect.EffectAnimation != null) { Animations.Add(Effect.EffectAnimation); } Animations.AddRange(InterpretEffect(Effect, Script, Effect.User, Player2, Effect.CurrentPlacement)); } } } if (Effect.User == Player1) { AllEffects[(Placement + ArenaOrientation) % 8].AddEffect(Effect); Animations.AddRange(RunTilePlacedOnTopEffect(Effect.CurrentPlacement, User)); } else { AllEffects[(Placement + ArenaOrientation + 4) % 8].AddEffect(Effect); Animations.AddRange(RunTilePlacedOnTopEffect(Effect.CurrentPlacement, User)); } } else if (Placement == 8) { //TODO: CENTRE EFFECTS } else if (Placement == 9) { if (Effect.User == Player1) { AllEffects[9].AddEffect(Effect); Effect.CurrentPlacement = 9; } else { AllEffects[10].AddEffect(Effect); Effect.CurrentPlacement = 10; } } else { if (Effect.User == Player1) { AllEffects[10].AddEffect(Effect); Effect.CurrentPlacement = 10; } else { AllEffects[9].AddEffect(Effect); Effect.CurrentPlacement = 9; } } Animations.AddRange(RunTriggerTypeEffect(EffectTrigger.ON_OTHER_EFFECT_ENTER, User, true)); foreach (EffectScript Script in Effect.Scripts) { List <BattleEffect> Effects; if (SortedEffects[Script.Trigger].ContainsKey(Script.Speed)) { Effects = SortedEffects[Script.Trigger][Script.Speed]; } else { Effects = new List <BattleEffect>(); SortedEffects[Script.Trigger].Add(Script.Speed, Effects); } Effects.Add(Effect); } } } EffectGroups++; return(Animations); }