Пример #1
0
        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);
            }
        }
Пример #2
0
 protected override void Awake()
 {
     base.Awake();
     m_PartyView = this.GetComponent <PlayerEntityView>(true);
     enabled     = false;
 }
Пример #3
0
        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);
            }
        }