protected virtual void OnEntityCastSpell(Object p_sender, EventArgs p_args) { if (p_sender != MyController) { return; } SpellEventArgs args = (SpellEventArgs)p_args; MonsterSpell spell = (MonsterSpell)args.Spell; EventHandler eventHandler = delegate(Object sender, EventArgs e) { DelayedEventManager.InvokeEvent(EDelayType.ON_FX_HIT, EEventType.MONSTER_CAST_SPELL, p_sender, args); MyController.AttackingDone.Trigger(); if (spell.SpellType == EMonsterSpell.FLICKER) { m_MainView.SetEntityPosition(); } if (MyController is Monster) { ((Monster)MyController).BuffHandler.FlushActionLog(MonsterBuffHandler.ELogEntryPhase.ON_CAST_SPELL); ((Monster)MyController).BuffHandler.RemoveFlaggedBuffs(); } SpellEffectEntryEventArgs p_args9 = new SpellEffectEntryEventArgs(p_sender, args); LegacyLogic.Instance.ActionLog.PushEntry(p_args9); foreach (SpellTarget spellTarget2 in args.SpellTargets) { if (spellTarget2.Target is Character) { ((Character)spellTarget2.Target).ConditionHandler.FlushActionLog(); ((Character)spellTarget2.Target).ConditionHandler.FlushDelayedActionLog(); LegacyLogic.Instance.WorldManager.Party.Buffs.FlushActionLog(); } } if (MyController is Monster) { ((Monster)MyController).BuffHandler.FlushActionLog(MonsterBuffHandler.ELogEntryPhase.ON_END_TURN); } }; FXDescription fxdescription = Helper.ResourcesLoad <FXDescription>(spell.EffectKey, false); if (fxdescription == null) { Debug.LogError("FXDescription not found! at " + spell.EffectKey, this); eventHandler(this, EventArgs.Empty); return; } fxdescription = Helper.Instantiate <FXDescription>(fxdescription); fxdescription.Finished += eventHandler; Vector3 p_slotOriginPosition; Vector3 p_slotForward; Vector3 p_slotLeft; Vector3 p_slotTargetPosition; ViewManager.GetSlotDatas(MyController.Position, LegacyLogic.Instance.WorldManager.Party.Position, out p_slotOriginPosition, out p_slotForward, out p_slotLeft, out p_slotTargetPosition); Int32 animationID; if (Int32.TryParse(spell.EffectAnimationClip, out animationID)) { m_animatorControl.AttackMagic(animationID); } else { Debug.LogError("Error parse animation id for attack magic '" + spell.EffectAnimationClip + "'"); m_animatorControl.AttackMagic(); } GameObject gameObject = this.gameObject; ETargetType targetType = spell.TargetType; if (args.SpellTargets.Count == 0) { Debug.LogError("Error, missing targets for effects\n" + DebugUtil.DumpObjectText(spell)); FXArgs p_args2 = new FXArgs(gameObject, gameObject, gameObject, gameObject, p_slotOriginPosition, p_slotForward, p_slotLeft, p_slotTargetPosition, new List <GameObject> { gameObject }); fxdescription.Configurate(m_eventHandler, p_args2); return; } if ((targetType & ETargetType.MONSTER) == ETargetType.MONSTER) { PlayerEntityView playerEntityView = ViewManager.Instance.FindViewAndGetComponent <PlayerEntityView>(LegacyLogic.Instance.WorldManager.Party); MovingEntity movingEntity = null; List <GameObject> list = new List <GameObject>(); foreach (SpellTarget spellTarget in args.SpellTargets) { GameObject gameObject2 = null; if (spellTarget.Target is Character) { if (movingEntity == null) { movingEntity = LegacyLogic.Instance.WorldManager.Party; } gameObject2 = playerEntityView.GetMemberGameObject(((Character)spellTarget.Target).Index); } else if (spellTarget.Target is MovingEntity) { if (movingEntity == null) { movingEntity = (MovingEntity)spellTarget.Target; } gameObject2 = ViewManager.Instance.FindView((MovingEntity)spellTarget.Target); } if (gameObject2 != null) { list.Add(gameObject2); } } ViewManager.GetSlotDatas(MyController.Position, movingEntity.Position, out p_slotOriginPosition, out p_slotForward, out p_slotLeft, out p_slotTargetPosition); FXArgs p_args3 = new FXArgs(gameObject, playerEntityView.gameObject, gameObject, playerEntityView.gameObject, p_slotOriginPosition, p_slotForward, p_slotLeft, p_slotTargetPosition, list); fxdescription.Configurate(m_eventHandler, p_args3); } else if ((targetType & ETargetType.MULTY) == ETargetType.MULTY) { PlayerEntityView playerEntityView2 = ViewManager.Instance.FindViewAndGetComponent <PlayerEntityView>(LegacyLogic.Instance.WorldManager.Party); List <GameObject> list2 = new List <GameObject>(4); for (Int32 i = 0; i < 4; i++) { list2.Add(playerEntityView2.GetMemberGameObject(i)); } FXArgs p_args4 = new FXArgs(gameObject, playerEntityView2.gameObject, gameObject, playerEntityView2.gameObject, p_slotOriginPosition, p_slotForward, p_slotLeft, p_slotTargetPosition, list2); fxdescription.Configurate(m_eventHandler, p_args4); } else if ((targetType & ETargetType.SINGLE) == ETargetType.SINGLE) { Boolean flag = true; foreach (AttackedTarget attackedTarget in args.SpellTargetsOfType <AttackedTarget>()) { Character character = (Character)attackedTarget.Target; GameObject characterGO = FXHelper.GetCharacterGO(character.Index); if (!flag) { fxdescription = Helper.Instantiate <FXDescription>(fxdescription); } FXArgs p_args5 = new FXArgs(gameObject, characterGO, gameObject, characterGO, p_slotOriginPosition, p_slotForward, p_slotLeft, p_slotTargetPosition, new List <GameObject> { characterGO }); fxdescription.Configurate(m_eventHandler, p_args5); flag = false; } foreach (MonsterBuffTarget monsterBuffTarget in args.SpellTargetsOfType <MonsterBuffTarget>()) { Character character2 = (Character)monsterBuffTarget.Target; GameObject characterGO2 = FXHelper.GetCharacterGO(character2.Index); if (!flag) { fxdescription = Helper.Instantiate <FXDescription>(fxdescription); } FXArgs p_args6 = new FXArgs(gameObject, characterGO2, gameObject, characterGO2, p_slotOriginPosition, p_slotForward, p_slotLeft, p_slotTargetPosition, new List <GameObject> { characterGO2 }); fxdescription.Configurate(m_eventHandler, p_args6); flag = false; } } else if ((targetType & ETargetType.ADJACENT) == ETargetType.ADJACENT) { FXArgs p_args7 = new FXArgs(gameObject, gameObject, gameObject, gameObject, p_slotOriginPosition, p_slotForward, p_slotLeft, p_slotTargetPosition); fxdescription.Configurate(m_eventHandler, p_args7); } else { FXArgs p_args8 = new FXArgs(gameObject, gameObject, gameObject, gameObject, p_slotOriginPosition, p_slotForward, p_slotLeft, p_slotTargetPosition); fxdescription.Configurate(m_eventHandler, p_args8); } }
protected virtual void OnMonsterAttacksGeneric(Object p_sender, AttacksEventArgs p_args, Boolean p_isRanged) { PlayerEntityView playerEntity = FXHelper.GetPlayerEntity(); Vector3 p_slotOriginPosition; Vector3 p_slotForward; Vector3 p_slotLeft; Vector3 p_slotTargetPosition; ViewManager.GetSlotDatas(MyController.Position, LegacyLogic.Instance.WorldManager.Party.Position, out p_slotOriginPosition, out p_slotForward, out p_slotLeft, out p_slotTargetPosition); Boolean flag = false; GameObject gameObject = null; List <Action> callbacks = new List <Action>(p_args.Attacks.Count); EResultType eresultType = EResultType.HIT; Int32 num = 0; List <Character> targets = new List <Character>(); AttacksEventArgs.AttackedTarget attack; foreach (AttacksEventArgs.AttackedTarget attack2 in p_args.Attacks) { attack = attack2; num++; if (attack.AttackTarget is Character) { Character chara = (Character)attack.AttackTarget; AttackResult result = attack.AttackResult; targets.Add(chara); if (playerEntity != null) { gameObject = playerEntity.GetMemberGameObject(chara.Index); } if (gameObject == null) { Debug.LogError("Could not find target character! Char-Index: " + chara.Index); } else { flag |= attack.IsCriticalAttack; callbacks.Add(delegate { if (p_sender is Monster && ((Monster)p_sender).AbilityHandler.HasEntriesForPhase(EExecutionPhase.BEFORE_MONSTER_ATTACK)) { ((Monster)p_sender).AbilityHandler.FlushActionLog(EExecutionPhase.BEFORE_MONSTER_ATTACK); chara.ConditionHandler.FlushActionLog(); } if (((Monster)p_sender).AbilityHandler.HasEntriesForPhase(EExecutionPhase.AFTER_DAMAGE_CALCULATION)) { ((Monster)p_sender).AbilityHandler.FlushActionLog(EExecutionPhase.AFTER_DAMAGE_CALCULATION); } CombatEntryEventArgs p_args2 = new CombatEntryEventArgs(p_sender, chara, result, attack.BloodMagicEventArgs); LegacyLogic.Instance.ActionLog.PushEntry(p_args2); if (LegacyLogic.Instance.WorldManager.Party.Buffs.HasBuff(EPartyBuffs.SHADOW_CLOAK) && result.Result == EResultType.EVADE) { LegacyLogic.Instance.WorldManager.Party.Buffs.RemoveBuff(EPartyBuffs.SHADOW_CLOAK); } if (LegacyLogic.Instance.WorldManager.Party.Buffs.HasBuff(EPartyBuffs.CELESTIAL_ARMOR)) { if (LegacyLogic.Instance.WorldManager.Party.Buffs.GetBuff(EPartyBuffs.CELESTIAL_ARMOR).IsExpired()) { LegacyLogic.Instance.WorldManager.Party.Buffs.RemoveBuff(EPartyBuffs.CELESTIAL_ARMOR); } LegacyLogic.Instance.WorldManager.Party.Buffs.FlushActionLog(); } chara.FightHandler.FlushCounterAttackActionLog(); LegacyLogic.Instance.WorldManager.Party.Buffs.FlushActionLog(); if (p_sender is Monster && ((Monster)p_sender).AbilityHandler.HasEntriesForPhase(EExecutionPhase.AFTER_MONSTER_ATTACK)) { ((Monster)p_sender).AbilityHandler.FlushActionLog(EExecutionPhase.AFTER_MONSTER_ATTACK); chara.ConditionHandler.FlushActionLog(); } }); if (attack.AttackResult.Result == EResultType.BLOCK) { eresultType = EResultType.BLOCK; } else if (eresultType != EResultType.BLOCK && attack.AttackResult.Result == EResultType.EVADE) { eresultType = EResultType.EVADE; } } } } Action action = delegate { DelayedEventManager.InvokeEvent(EDelayType.ON_FX_HIT, (!p_isRanged) ? EEventType.MONSTER_ATTACKS : EEventType.MONSTER_ATTACKS_RANGED, p_sender, p_args); if (!p_isRanged) { foreach (AttacksEventArgs.AttackedTarget attackedTarget in p_args.Attacks) { ((Monster)MyController).CombatHandler.TriggerCounterAttacks(attackedTarget.AttackTarget, attackedTarget.AttackResult); } } foreach (Action action2 in callbacks) { action2(); } foreach (Character character in targets) { character.ConditionHandler.FlushDelayedActionLog(); } }; if (gameObject == null) { gameObject = playerEntity.GetMemberGameObject(UnityEngine.Random.Range(0, 4)); if (gameObject == null) { Debug.LogError("No target character could be found! Will skip whole FX! Num of Attacks = " + p_args.Attacks.Count); action(); return; } } FXArgs p_fxArgs = new FXArgs(this.gameObject, gameObject, this.gameObject, gameObject, p_slotOriginPosition, p_slotForward, p_slotLeft, p_slotTargetPosition); if (p_isRanged) { AttackRanged(p_fxArgs, action, (!flag) ? eresultType : EResultType.CRITICAL_HIT); } else if (flag) { AttackCritical(p_fxArgs, action); } else { Attack(p_fxArgs, action); } }
protected override void OnDestroy() { ViewManager.DestroyView(MyController); base.OnDestroy(); }
private void OnCharacterCastSpell(Object p_sender, EventArgs p_args) { Character character = (Character)p_sender; SpellEventArgs spellEventArgs = (SpellEventArgs)p_args; if (character != null) { SpellEffectEntryEventArgs p_args2 = new SpellEffectEntryEventArgs(p_sender, (SpellEventArgs)p_args); character.FightHandler.FeedDelayedActionLog(p_args2); } if (spellEventArgs.SpellTargets.Count == 0) { OnFXCancel(p_sender, p_args); return; } FXQueue fxqueue = Helper.ResourcesLoad <FXQueue>(spellEventArgs.Spell.EffectKey, false); if (fxqueue == null) { Debug.LogError(String.Concat(new Object[] { "PlayerSpellView: OnCharacterCastSpell: Character FXQueue not found! at '", spellEventArgs.Spell.EffectKey, "' ", spellEventArgs })); OnFXCancel(p_sender, p_args); return; } Party party = (Party)MyController; List <GameObject> list = new List <GameObject>(spellEventArgs.SpellTargets.Count); foreach (SpellTarget spellTarget in spellEventArgs.SpellTargets) { if (spellTarget.Target is Character) { Character character2 = (Character)spellTarget.Target; GameObject characterGO = FXHelper.GetCharacterGO(character2.Index); if (!list.Contains(characterGO)) { list.Add(characterGO); } } else { GameObject gameObject = ViewManager.Instance.FindView((BaseObject)spellTarget.Target); if (gameObject != null && !list.Contains(gameObject)) { list.Add(gameObject); } } if (spellTarget.Target is Party) { break; } } if (list.Count == 0) { Debug.LogError("PlayerSpellView: OnCharacterCastSpell: No views found! " + spellEventArgs); OnFXCancel(p_sender, p_args); return; } Vector3 p_slotOriginPosition; Vector3 p_slotForward; Vector3 p_slotLeft; Vector3 p_slotTargetPosition; if (spellEventArgs.SpellTargets[0].Target is Monster) { ViewManager.GetSlotDatas(party.Position, ((Monster)spellEventArgs.SpellTargets[0].Target).Position, out p_slotOriginPosition, out p_slotForward, out p_slotLeft, out p_slotTargetPosition); } else { Position position = party.Position + party.Direction; if (LegacyLogic.Instance.MapLoader.Grid.GetSlot(position) != null) { ViewManager.GetSlotDatas(party.Position, position, out p_slotOriginPosition, out p_slotForward, out p_slotLeft, out p_slotTargetPosition); } else { ViewManager.GetSlotDatas(party.Position, party.Position, out p_slotOriginPosition, out p_slotForward, out p_slotLeft, out p_slotTargetPosition); } } GameObject memberGameObject = m_PartyView.GetMemberGameObject(character.Index); ETargetType targetType = spellEventArgs.Spell.TargetType; if ((targetType & ETargetType.LINE_OF_SIGHT) == ETargetType.LINE_OF_SIGHT) { MovingEntity movingEntity = (MovingEntity)spellEventArgs.SpellTargets[0].Target; GameObject slotOrigin = ViewManager.Instance.GetSlotOrigin(movingEntity.Position); FXArgs args = new FXArgs(memberGameObject, slotOrigin, memberGameObject, slotOrigin, p_slotOriginPosition, p_slotForward, p_slotLeft, p_slotTargetPosition, list); FXQueue fxqueue2 = Helper.Instantiate <FXQueue>(fxqueue); fxqueue2.Finished += delegate(Object sender, EventArgs e) { OnFXQueueFinish(p_sender, p_args); }; fxqueue2.Execute(args); } else if ((targetType & ETargetType.MULTY) == ETargetType.MULTY) { GameObject slotOrigin2; if (spellEventArgs.SpellTargets[0].Target is MovingEntity) { MovingEntity movingEntity2 = (MovingEntity)spellEventArgs.SpellTargets[0].Target; slotOrigin2 = ViewManager.Instance.GetSlotOrigin(movingEntity2.Position); } else { slotOrigin2 = ViewManager.Instance.GetSlotOrigin(party.Position); } FXArgs args2 = new FXArgs(memberGameObject, slotOrigin2, memberGameObject, slotOrigin2, p_slotOriginPosition, p_slotForward, p_slotLeft, p_slotTargetPosition, list); FXQueue fxqueue3 = Helper.Instantiate <FXQueue>(fxqueue); fxqueue3.Finished += delegate(Object sender, EventArgs e) { OnFXQueueFinish(p_sender, p_args); }; fxqueue3.Execute(args2); } else if ((targetType & ETargetType.SINGLE) == ETargetType.SINGLE) { Boolean flag = true; foreach (GameObject gameObject2 in list) { GameObject p_endPoint = gameObject2; FXTags component = gameObject2.GetComponent <FXTags>(); if (component != null) { p_endPoint = component.FindOne("HitSpot"); } else { Debug.LogError("FXTags not found!!\nTarget=" + component, component); } FXArgs args3 = new FXArgs(memberGameObject, gameObject2, memberGameObject, p_endPoint, p_slotOriginPosition, p_slotForward, p_slotLeft, p_slotTargetPosition, list); FXQueue fxqueue4 = Helper.Instantiate <FXQueue>(fxqueue); if (flag) { flag = false; fxqueue4.Finished += delegate(Object sender, EventArgs e) { OnFXQueueFinish(p_sender, p_args); }; } fxqueue4.Execute(args3); } } else if ((targetType & ETargetType.ADJACENT) == ETargetType.ADJACENT) { GameObject slotOrigin3 = ViewManager.Instance.GetSlotOrigin(party.Position); FXArgs args4 = new FXArgs(memberGameObject, slotOrigin3, memberGameObject, slotOrigin3, p_slotOriginPosition, p_slotForward, p_slotLeft, p_slotTargetPosition, list); FXQueue fxqueue5 = Helper.Instantiate <FXQueue>(fxqueue); fxqueue5.Finished += delegate(Object sender, EventArgs e) { OnFXQueueFinish(p_sender, p_args); }; fxqueue5.Execute(args4); } else { Debug.Log("error !! spellType: " + targetType); FXArgs args5 = new FXArgs(memberGameObject, memberGameObject, memberGameObject, memberGameObject, p_slotOriginPosition, p_slotForward, p_slotLeft, p_slotTargetPosition, list); FXQueue fxqueue6 = Helper.Instantiate <FXQueue>(fxqueue); fxqueue6.Finished += delegate(Object sender, EventArgs e) { OnFXQueueFinish(p_sender, p_args); }; fxqueue6.Execute(args5); } }