예제 #1
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);
            }
        }
예제 #2
0
        protected virtual void OnEntityAbilityAdded(Object p_sender, EventArgs p_args)
        {
            AbilityEventArgs abilityEventArgs = (AbilityEventArgs)p_args;

            if (abilityEventArgs.Monster == MyController)
            {
                String gfx       = abilityEventArgs.Ability.StaticData.Gfx;
                String animation = abilityEventArgs.Ability.StaticData.Animation;
                if (!String.IsNullOrEmpty(animation))
                {
                    Int32 animationID = Int32.Parse(animation);
                    if (m_old)
                    {
                        m_Animation.Play(animation, -1f, 1f);
                    }
                    else if (m_animatorControl.DieState == 0)
                    {
                        m_animatorControl.AttackMagic(animationID);
                    }
                }
                if (!String.IsNullOrEmpty(gfx))
                {
                    if (gfx == "SKIP_FX")
                    {
                        return;
                    }
                    BuffFX buffFX = Helper.ResourcesLoad <BuffFX>(gfx, false);
                    if (buffFX != null)
                    {
                        buffFX = Helper.Instantiate <BuffFX>(buffFX);
                        FXQueue fxqueue = new GameObject(name + " " + buffFX.name + " FXQueue").AddComponent <FXQueue>();
                        fxqueue.SetData(new FXQueue.Entry[]
                        {
                            new FXQueue.Entry(buffFX, 0f, 0f)
                        }, 0);
                        if (abilityEventArgs.Ability.StaticData.TargetType == ETargetType.PARTY)
                        {
                            FXArgs args = new FXArgs(gameObject, FXHelper.GetPlayerEntity().gameObject, gameObject, FXHelper.GetPlayerEntity().gameObject, transform.position, transform.forward, -transform.right, FXHelper.GetPlayerEntity().transform.position, new List <GameObject>
                            {
                                FXHelper.GetPlayerEntity().gameObject
                            });
                            fxqueue.Execute(args);
                        }
                        else
                        {
                            FXArgs args2 = new FXArgs(gameObject, gameObject, gameObject, gameObject, transform.position, transform.forward, -transform.right, transform.position, new List <GameObject>
                            {
                                gameObject
                            });
                            fxqueue.Execute(args2);
                        }
                        m_Queues.Add(fxqueue);
                    }
                    else
                    {
                        Debug.LogError("OnAbilityEvent: Ability's  given GFX does not exist! " + gfx);
                    }
                }
                else
                {
                    Debug.LogWarning("OnAbilityEvent: Ability GFX is missing!");
                }
                if (abilityEventArgs.Ability.StaticData.NameKey == "MONSTER_ABILITY_EXPLOSIVE")
                {
                    DelayedEventManagerWorker delayedEventManagerWorker = new GameObject("ExplosiveHelper").AddComponent <DelayedEventManagerWorker>();
                    DontDestroyOnLoad(delayedEventManagerWorker);
                    delayedEventManagerWorker.StartCoroutine(PlayLateShakeFX(delayedEventManagerWorker.gameObject));
                    Destroy(gameObject, m_explosiveAbilityDelay);
                }
            }
        }