protected override void OnCollisionBegin(Collider_ other)
    {
        var c = 0;
        var k = other.GetInstanceID();

        if (m_cols.TryGetValue(k, out c))
        {
            m_cols[k] = c + 1;
        }
        else
        {
            m_cols.Add(k, 1);
        }

        #region Debug log
        #if (DEVELOPMENT_BUILD || UNITY_EDITOR) && DETAIL_BATTLE_LOG
        if (creature)
        {
            Logger.LogWarning("[{2}:{3}-{4}], Creature {0} attack box collision begin with [{1}]", creature.name, m_cols[k], Level.levelTime, creature.frameTime, creature.frameCount);
        }
        #endif

        #if AI_LOG
        Module_AI.LogBattleMsg(creature, "[attack box collision begin with {0}]", m_cols[k]);
        #endif
        #endregion
    }
Beispiel #2
0
    protected override void OnTransportTweenFinish()
    {
        base.OnTransportTweenFinish();

        m_allMemberTransportOver = false;
#if AI_LOG
        Module_AI.LogBattleMsg(player, "[finish to transport scene......]");
#endif
    }
Beispiel #3
0
    private void OnTransportSceneOver(FrameData d)
    {
        //组队的时候,一旦开始处理切换场景完毕,就统一开启逻辑帧
        OnLogicTransportFinish();
        m_allMemberTransportOver = true;
        moduleTeam.TransportOver();
#if AI_LOG
        Module_AI.LogBattleMsg(player, "[set m_allMemberTransportOver as true.....]");
#endif
    }
    private void _SetAttackBox(StateMachineInfo.AttackBox attackBox, StateMachineInfo.Effect hit, int snapShotIndex = -1)
    {
        m_attackBox = attackBox;
        m_hitEff    = hit;

        m_hitEff.markedHit = true;

        m_bulletAttackInfo = m_attackBox.bulletAttackInfo;
        m_attackInfo       = m_attackBox.attackInfo;

        gameObject.SetActive(!m_attackBox.isEmpty);

        if (m_attackBox.isEmpty)
        {
            return;
        }

        if (m_attackBox.type == StateMachineInfo.AttackBox.AttackBoxType.Box)
        {
            var off = m_attackBox.start + m_attackBox.size * 0.5;
            if (!m_forward)
            {
                off.x = -off.x;
            }

            offset  = off;
            boxSize = m_attackBox.size;
            radius  = 0;
        }
        else
        {
            var off = m_attackBox.start;
            if (!m_forward)
            {
                off.x = -off.x;
            }

            boxSize      = Vector2_.zero;
            sphereOffset = off;
            radius       = m_attackBox.size.x;
        }

        #region Debug log
        #if (DEVELOPMENT_BUILD || UNITY_EDITOR) && DETAIL_BATTLE_LOG
        if (creature)
        {
            Logger.LogWarning("[{4}:{5}-{6}], Creature {0} attack box set to [{1},{2},{3},{7}], snap [{8},{9}]", creature.name, m_attackBox.attackInfo, m_attackBox.type, m_forward, Level.levelTime, creature.frameTime, creature.frameCount, snapShotIndex, enableSnapshot, m_snapShotCount);
        }
        #endif

        #if AI_LOG
        Module_AI.LogBattleMsg(creature, "[attack box set to [{0},{1},{2},{3}], snap [{4},{5}]", m_attackBox.attackInfo, m_attackBox.type, m_forward, snapShotIndex, enableSnapshot, m_snapShotCount);
        #endif
        #endregion
    }
Beispiel #5
0
    protected override void OnDestroy()
    {
        base.OnDestroy();

#if AI_LOG
        Module_AI.LogBattleMsg(source, "flying effect destory [logId: {0}] with effect pos = {1}, collider pos = {2} ", logId, position_, m_collider == null ? "null" : m_collider.position.ToString());
#endif
        Object.Destroy(m_root.gameObject);
        m_collider.isActive = false;

        effectInfo = null;
    }
Beispiel #6
0
    protected override void OnDestroy()
    {
        base.OnDestroy();
        DispatchEvent(FOLLOW_EFFECT_DESTORY, Event_.Pop(conditionValue));

        FightRecordManager.RecordLog <LogEmpty>(log =>
        {
            log.tag = (byte)TagType.FollowEffectDestory;
        });

#if AI_LOG
        Module_AI.LogBattleMsg(source, "FollowTargetEffect[logId: {0}] destoryed with pos {0}", logId, position_);
#endif
    }
Beispiel #7
0
    private void FrameUpdate(FrameData p)
    {
        FightRecordManager.FrameUpdate();
        m_inputStates = p.inputStates;
        if (p.action != FrameAction.None)
        {
            frameActionData = p;
        }

        ObjectManager.LogicUpdate(p.diff);

#if AI_LOG
        Module_AI.LogBattleMsg(null, "FrameUpdate   diff is {0},create resource is {1}", p.diff, p.createTip);
#endif
    }
Beispiel #8
0
    public void Clear()
    {
        m_attinfos.Clear();

        m_creature.DispatchEvent(CreatureEvents.HIT_INFO_CLEARED);

        #region Debug log
        #if (DEVELOPMENT_BUILD || UNITY_EDITOR) && DETAIL_BATTLE_LOG
        Logger.LogInfo("[{1}:{2}-{3}], [{0}] hit info cleared.", m_creature.name, Level.levelTime, creature.frameTime, creature.frameCount);
        #endif

        #if AI_LOG
        Module_AI.LogBattleMsg(m_creature, "[hit info cleared.]");
        #endif
        #endregion
    }
Beispiel #9
0
    protected override void OnTransportScene(STransportSceneBehaviour behaviour)
    {
        //单机直接跳转
        if (modulePVE.isStandalonePVE)
        {
            base.OnTransportScene(behaviour);
            return;
        }

        m_tempTransportSceneBehaviour = behaviour;
        moduleTeam.StartTransportScene();
        moduleBattle.parseInput = false;
        modulePVE.DispathTransportSceneToUI(true);
#if AI_LOG
        Module_AI.LogBattleMsg(player, "[begin to transport scene......behaviour is {0}]", behaviour.ToString());
#endif
    }
Beispiel #10
0
    protected void HandleRoleTurn()
    {
        if (storyItem.turnLockRoleId == 0)
        {
            return;
        }

        Creature tar = null;

        if (storyItem.turnLockRoleId < 0)
        {
            if (Level.current && Level.current is Level_PVE)
            {
                tar = (Level.current as Level_PVE).eventPlayer;
            }
            if (!tar)
            {
                tar = ObjectManager.FindObject <Creature>(o => o.isPlayer);
            }
        }
        else
        {
            tar = ObjectManager.FindObject <MonsterCreature>(o => o.monsterId == storyItem.turnLockRoleId && o.gameObject.activeSelf);
        }

        if (tar == null)
        {
            return;
        }

        foreach (var item in moduleStory.battleStoryDic)
        {
            //怪物在玩家右边并且怪物当前朝向朝前
            if ((Module_AI.GetDirection(item.Key, tar) > 0 && item.Key.direction == CreatureDirection.FORWARD) ||
                (Module_AI.GetDirection(item.Key, tar) < 0 && item.Key.direction == CreatureDirection.BACK))
            {
                item.Key.TurnBack();
            }
        }
    }
Beispiel #11
0
    public void OnHit(CreatureHitCollider hit)
    {
        FightRecordManager.RecordLog <LogEmpty>(log =>
        {
            log.tag = (byte)TagType.FlyEffectOnHit;
        });

        if (destroyed || !hit && m_groundHited)
        {
            return;
        }

        if (!hit)
        {
            m_groundHited = true;
        }

        if (!effectInfo.hitEffect.isEmpty)
        {
            Create(effectInfo.hitEffect, source, startForward ? 1 : -1, inverted, hitEffect, position_, eular_, m_root.eulerAngles);
        }

        if (effectInfo.removeOnHit == 1 || effectInfo.removeOnHit == 2 && !hit)
        {
            FightRecordManager.RecordLog <LogEffectDestoryOnHit>(l =>
            {
                l.tag         = (byte)TagType.FlyEffectOnHit;
                l.name        = name;
                l.removeOnHit = effectInfo.removeOnHit;
            });

            Destroy();
        }

#if AI_LOG
        Module_AI.LogBattleMsg(source, "flying effect[logId: {0}] OnHit,hit creature is {1} with effect pos = {2}, collider pos = {3} ", logId, hit == null ? "null" : hit.creature ? hit.creature.uiName : "null", position_, m_collider == null ? "null" : m_collider.position.ToString());
#endif
    }
Beispiel #12
0
    public void OnHit(AttackCollider c, AttackInfo a, int t)
    {
        if (null == m_creature)
        {
            return;
        }
        var alive = !m_creature.isDead;

        var ts      = t == byte.MaxValue ? AttackInfo.hitProtectTrans : a.targetStates[t];
        var cc      = c.creature;
        var ss      = c.currentState;
        var passive = ss.info.ignoreTough || (!m_creature.tough || a.breakToughLevel > m_creature.toughLevel) || m_creature.weak && a.fromBullet;  // can we enter passive state ?
        var toState = -1;

        if (passive)
        {
            var pt         = 0L;
            var breakTough = m_creature.tough && (ss.info.ignoreTough || a.breakToughLevel > m_creature.toughLevel || cc.breakToughLevel > m_creature.toughLevel);
            var isCatch    = ss.info.catchState > 0;
            if (isCatch)
            {
                pt = pt.BitMask(StateMachine.PASSIVE_CATCH, true);
            }
            if (breakTough)
            {
                pt = pt.BitMask(StateMachine.PASSIVE_TOUGH, true);
            }
            if (a.fromBullet && (m_creature.weak || c.creature.HawkEye))
            {
                pt = pt.BitMask(StateMachine.PASSIVE_WEAK, true);
            }

            var opt = m_stateMachine.GetLong(StateMachineParam.forcePassive) >> 48 & 0xFFFF;
            if (opt == 0 || pt.BitMask(StateMachine.PASSIVE_CATCH) || !opt.BitMask(StateMachine.PASSIVE_CATCH) && pt.BitMask(StateMachine.PASSIVE_WEAK))
            {
                var tid = breakTough && m_creature.HasState(ts.toToughStateID) ? ts.toToughStateID : ts.toStateID;
                toState = tid;

                var p = pt << 48 | (long)cc.id << 32 | (uint)tid;
                m_stateMachine.SetParam(StateMachineParam.forcePassive, p);

                if (pt.BitMask(StateMachine.PASSIVE_CATCH))
                {
                    m_creature.RemoveBuff(BuffInfo.EffectTypes.Freez);
                }

                if (c.type == AttackColliderTypes.Attack)
                {
                    var mask = m_stateMachine.GetStateMask(toState);
                    cc.stateMachine.SetParam(StateMachineParam.targetGroupMask, mask);
                    cc.stateMachine.SetParam(StateMachineParam.targetHitGroupMask, m_stateMachine.GetLong(StateMachineParam.groupMask));
                    cc.stateMachine.SetParam(StateMachineParam.targetConfigID, m_creature.configID);
                    if (isCatch && !mask.BitMasks(ss.info.ignoreCatchPosGroups) && m_creature.HasState(toState))
                    {
                        if (ss.info.catchState == 1)
                        {
                            m_creature.position_ = cc.position_;
                        }
                        else
                        {
                            cc.position_ = m_creature.position_;
                        }
                    }
                }
            }
            else
            {
                passive = false;
            }
        }

        if (c.type == AttackColliderTypes.Attack)
        {
            cc.stateMachine.SetParam(StateMachineParam.hit, true);
        }

        m_stateMachine.SetParam(StateMachineParam.hited, cc.id);

        cc.DispatchAttackEvent(m_creature, a);
        if (!m_creature.isDead)
        {
            cc.rage += a.selfRageReward * (1 + cc.attackRageMul);                      // ignore rage reward if target is dead
        }
        m_creature.DispatchEvent(CreatureEvents.ATTACKED, Event_.Pop(cc, a));
        if (a.fromBullet)
        {
            m_creature.DispatchEvent(CreatureEvents.SHOOTED, Event_.Pop(m_creature, a));
        }
        if (!m_creature.isDead) // ignore rage reward if target is dead
        {
            m_creature.rage += a.targetRageReward * (1 + m_creature.attackedRageMul);
            m_creature.TakeDamage(cc, cc.CalculateDamage(a, m_creature, ss.damageMul));
        }
        else if (!alive)
        {
            UpdateDeadCombo();
        }

        if (a.freezTime > 0)
        {
            m_stateMachine.Pending(a.freezTime, passive, alive && m_creature.isDead);
            if (!a.fromEffect)
            {
                c.stateMachine.Pending(a.freezTime);
            }
        }

        if (passive)
        {
            if (a.preventTurn == 0)
            {
                if (a.fromBullet)
                {
                    m_creature.FaceTo(cc);
                }
                else
                {
                    var direction = CalculateHitDirection(c, a, m_creature.x);
                    if (direction != 0)
                    {
                        m_creature.direction = direction < 0 ? CreatureDirection.BACK : CreatureDirection.FORWARD;
                    }
                }
            }
            if (a.acttackSlide != 0)
            {
                m_creature.Knockback(m_creature.isForward ? -a.acttackSlide * 0.1 : a.acttackSlide * 0.1);
            }
        }

        var s = a.soundEffect.SelectSound(m_creature.roleProto, m_creature.gender);

        if (!s.isEmpty)
        {
            AudioManager.PlayAudio(s.sound, a.soundEffect.isVoice || s.isVoice ? AudioTypes.Voice : AudioTypes.Sound, false, a.soundEffect.overrideType);
        }

        if (c.type == AttackColliderTypes.Attack && !a.ignoreHitEffect)
        {
            behaviour.effects.PlayEffect(c.hitEff);
        }

        if (!m_creature.isDead)  // do not trigger buffs if target is dead
        {
            var level = 1;
            if (cc is PetCreature)
            {
                level = ((PetCreature)cc).petInfo.AdditiveLevel;
            }

            var b = a.selfBuff;
            if (b.intValue0 != 0 && (b.doubleValue0 == 0 || Module_Battle.Range() <= b.doubleValue0))
            {
                Buff.Create(b.intValue0, cc, null, b.intValue1, -1, level);
            }

            b = a.targetBuff;
            if (b.intValue0 != 0 && (b.doubleValue0 == 0 || Module_Battle.Range() <= b.doubleValue0))
            {
                Buff.Create(b.intValue0, m_creature, cc, b.intValue1, -1, level);
            }
        }

        #region Debug log
        #if DEVELOPMENT_BUILD || UNITY_EDITOR
        Logger.LogInfo("[{3}:{4}-{5}], [{0}] hited by attackInfo [{1}], translate to state [{2}]", m_creature.gameObject.name, a.ID, toState == ts.toStateID ? ts.toState : toState == ts.toToughStateID ? ts.toToughState : string.Empty, Level.levelTime, creature.frameTime, creature.frameCount);
        #endif

        #if AI_LOG
        Module_AI.LogBattleMsg(m_creature, "[m_creature.tough = {0},currentState is {1} ss.info.ignoreTough = {2} attackinfo.breaktoughLevel = {3} m_creature.toughLevel = {4} cc.breakToughLevel = {5}", m_creature.tough, m_creature.stateMachine.currentState.name, ss.info.ignoreTough, a.breakToughLevel, m_creature.toughLevel, cc.breakToughLevel);
        Module_AI.LogBattleMsg(m_creature, "[[{0}] hited by attackInfo [{1}], translate to state [{2}]", m_creature.gameObject.name, a.ID, toState == ts.toStateID ? ts.toState : toState == ts.toToughStateID ? ts.toToughState : string.Empty);
        #endif
        #endregion
    }
Beispiel #13
0
    private bool TranslateTo(StateMachineState state, int type = 0, bool checkCooldown = false, float blendTime = -1)
    {
        if (checkCooldown && state.coolingDown)
        {
            return(false);
        }

        #region Debug log

        #if (DEVELOPMENT_BUILD || UNITY_EDITOR) && DETAIL_BATTLE_LOG
        if (type != 0 && creature.isCombat)
        {
            var msg = Util.Format("[{2}:{3}-{4}], [{5}:{6}] Enter state {0} from {1}, type:{7}", state.name, currentState.name, Level.levelTime, creature.frameTime, creature.frameCount, creature.id, creature.name, type);
            if (type > 0)
            {
                Logger.LogChat(msg);
            }
            else
            {
                Logger.LogWarning(msg);
            }
        }
        #endif

        #if AI_LOG
        if (type != 0 && creature.isCombat)
        {
            Module_AI.LogBattleMsg(creature, true, "[Enter state {0} from {1}, type:{2}", state.name, currentState.name, type);
        }
        #endif
        #endregion

        FightRecordManager.RecordLog <LogStateTranslate>(l =>
        {
            l.tag          = (byte)TagType.StateTranslate;
            l.form         = currentState.name;
            l.roleId       = creature.Identify;
            l.to           = state.name;
            l.currentFrame = (ushort)currentState.currentFrame;
            l.frameCount   = (ushort)currentState.frameCount;
        }, true);

        var old = currentState;
        old.Quit();

        onQuitState?.Invoke(old, state, blendTime);

        currentState = state;
        currentState.Enter();

        onEnterState?.Invoke(old, currentState, blendTime);

        if (m_nextPendingTime > 0)
        {
            Pending(m_nextPendingTime, false, m_preventShake);
            m_nextPendingTime = 0;
        }
        else
        {
            pending = false;
        }

        return(true);
    }
Beispiel #14
0
    public virtual void Enter()
    {
        #region Debug log
        #if (DEVELOPMENT_BUILD || UNITY_EDITOR) && DETAIL_BATTLE_LOG
        if (!m_waitToLoop)
        {
            Logger.LogDetail("[{2}:{3}-{4}], Creature {0} enter state [{1}]", stateMachine.creature.name, name, Level.levelTime, stateMachine.creature.frameTime, stateMachine.creature.frameCount);
        }
        #endif

        #if AI_LOG
        if (!m_waitToLoop)
        {
            Module_AI.LogBattleMsg(stateMachine.creature, true, "[enter state [{0}]", name);
        }
        #endif
        #endregion

        var c = stateMachine.creature;

        m_speed          = isRun ? c.speedRun : !passive && !info.ignoreAttackSpeed && !isIdle && !isDie ? c.speedAttack : 1.0;
        m_animationSpeed = (float)(stateMachine.speed * m_speed);

        var overflow = 0;

        if (!m_waitToLoop)
        {
            m_loopCount  = 0;
            m_totalFrame = 0;
        }
        else
        {
            overflow = m_time % m_length;
            ++m_loopCount;
        }

        m_time               = 0;
        m_normalizedTime     = 0;
        m_currentFrame       = 0;
        m_curSectionIdx      = 0;
        m_curInvisibleIndex  = 0;
        m_curDarkIndex       = 0;
        m_curRimIndex        = 0;
        m_curWeakIndex       = 0;
        m_curToughIdx        = 0;
        m_curBuffIndex       = 0;
        m_curEffectIdx       = 0;
        m_curFlyingEffectIdx = 0;
        m_curSoundEffectIdx  = 0;
        m_curShakeIdx        = 0;
        m_curHideIdx         = 0;
        m_curHideOffIdx      = 0;
        m_curHidePetIdx      = 0;
        m_curActorIdx        = 0;

        if (stateMachine.GetInt(StateMachineParam.state) != m_ID)
        {
            m_inheritEffectsFrame.Clear();
            foreach (var effect in m_inheritEffects)
            {
                effect.Destroy();
            }
            m_inheritEffects.Clear();
        }

        if (isLaydown)
        {
            m_length = stateMachine.GetInt(StateMachineParam.nextLayDownTime);
            if (m_length < 1)
            {
                m_length = 33;
            }
            frameCount    = m_length / 33;
            m_floatLength = m_length * 0.001f;

            etherealCount    = stateMachine.GetInt(StateMachineParam.prevEthreal);
            c.etherealCount += etherealCount;

            passiveEtherealCount    = stateMachine.GetInt(StateMachineParam.prevPassiveEthreal);
            c.passiveEtherealCount += passiveEtherealCount;
        }
        else if (!m_waitToLoop)
        {
            etherealCount        = 0;
            passiveEtherealCount = 0;
        }

        stateMachine.SetParam(StateMachineParam.totalFrame, m_totalFrame);
        stateMachine.SetParam(StateMachineParam.loopCount, m_loopCount);
        stateMachine.SetParam(StateMachineParam.stateType, off ? 1 : passive ? 2 : 0);
        stateMachine.SetParam(StateMachineParam.prevGroupMask, stateMachine.GetLong(StateMachineParam.groupMask));
        stateMachine.SetParam(StateMachineParam.groupMask, info.groupMask);
        stateMachine.SetParam(StateMachineParam.targetGroupMask, 0);
        stateMachine.SetParam(StateMachineParam.targetHitGroupMask, 0);
        stateMachine.SetParam(StateMachineParam.targetConfigID, 0);
        stateMachine.SetParam(StateMachineParam.forcePassive, 0);
        stateMachine.SetParam(StateMachineParam.frame, 0);
        stateMachine.SetParam(StateMachineParam.section, 0);
        stateMachine.SetParam(StateMachineParam.process, 0);
        stateMachine.SetParam(StateMachineParam.key, 0);
        stateMachine.SetParam(StateMachineParam.state, m_ID);
        stateMachine.SetParam(StateMachineParam.exit, info.processes.y < 1);
        stateMachine.SetParam(StateMachineParam.moveBreak, false);
        stateMachine.SetParam(StateMachineParam.hit, false);
        stateMachine.SetParam(StateMachineParam.hited, 0);
        stateMachine.SetParam(StateMachineParam.immuneDeath, false);
        stateMachine.SetParam(StateMachineParam.nextLayDownTime, 0);
        stateMachine.SetParam(StateMachineParam.prevEthreal, 0);
        stateMachine.SetParam(StateMachineParam.prevPassiveEthreal, 0);
        stateMachine.SetParam(StateMachineParam.hasLaydownTime, info.layDownTime > 0);
        stateMachine.SetParam(StateMachineParam.catchState, info.catchState);

        m_toughs.Clear();

        invincibleCount = 0;
        weakCount       = 0;
        rimCount        = 0;
        darkCount       = 0;
        fatal           = false;

        m_rimLight     = true;
        m_holdRimCount = 0;

        m_acceptInput = true;

        fallSpeed  = defaultFallSpeed;
        m_falling  = false;
        m_fallTime = 0;
        m_inMotion = m_motion;

        currentMotionPos = m_waitToLoop ? Vector3_.zero : motionOffset;
        if (!stateMachine.creature.isForward)
        {
            currentMotionPos.x = -currentMotionPos.x;
        }

        currentMotionPos += stateMachine.creature.position_;

        m_motionIndex = m_motionFrame.y < 1 ? 0 : (int)m_motionFrame.x;

        m_waitToResetKey = false;
        m_waitToDefault  = false;
        m_waitToLayDown  = false;
        m_waitToLoop     = false;
        m_ended          = false;

        var cc = c.behaviour;

        cc.attackCollider.SetAttackBox(StateMachineInfo.AttackBox.empty, StateMachineInfo.Effect.empty, c.isForward);

        cc.SetWeaponVisibility(-1, m_showOffWeapon, true);
        cc.SetWeaponVisibility(-1, true, false);

        if (c.pet)
        {
            c.pet.enabledAndVisible = c.visible;
        }

        cc.SetWeaponBind(m_bindInfo);

        if (off)
        {
            cc.SetWeaponBind(parent.defaultWeaponBinds, true);
        }

        c.SetLayer(-1);

        if (c.shadow)
        {
            c.shadow.gameObject.SetActive(!info.hideShadow);
        }

        if (c.springManager)
        {
            c.springManager.SetState(c.useSpringBone && !info.disableSpringManager);
            c.springManager.SetExtendColliderState(isVictory);
        }

        HandleFrameEvent(); // Initialize 0 frame actions

        if (overflow > 0)
        {
            _Update(overflow);
        }

        if (isLaydown)
        {
            stateMachine.creature.UpdateAnimatorForce();
        }
    }
Beispiel #15
0
    public static FollowTargetEffect Create(StateMachineInfo.FollowTargetEffect effInfo, Transform node, Creature target, Vector3_ position,
                                            Creature source = null, Buff sourceBuff = null)
    {
        var eff = Create <FollowTargetEffect>(effInfo.effect, effInfo.effect, position + effInfo.motionData.offset,
                                              (node.rotation * Quaternion.Euler(effInfo.rotation)).eulerAngles);

        eff.enableUpdate   = true;
        eff.source         = source;
        eff.follow         = false;
        eff.m_time         = 0;
        eff.offset         = effInfo.motionData.offset;
        eff.target         = target;
        eff.sourceBuff     = sourceBuff;
        eff.triggerType    = effInfo.triggerType;
        eff.m_originEular  = eff.localEulerAngles;
        eff.localScale     = effInfo.scale;
        eff.velocity       = effInfo.motionData.velocity;
        eff.acceleration   = effInfo.motionData.acceleration;
        eff.randomPosition = eff.position_ = position + effInfo.motionData.offset;
        eff.motion         = new Motion_SlantingThrow(eff, target, effInfo.motionData);
        eff.lifeTime       = -1;
        //粒子系统要更改粒子节点才能改其缩放。搞不懂为什么
        var particles = eff.transform.GetComponentsInChildren <ParticleSystem>();

        if (particles != null && particles.Length > 0)
        {
            for (var i = 0; i < particles.Length; i++)
            {
                particles[i].transform.localScale = effInfo.scale;
            }
        }

        eff.transform.SetParent(null);

        if (effInfo.randomPosition)
        {
            var p = eff.position_;
            eff.randomPosition = new Vector3_(p.x + 1.5 * moduleBattle._Range(-1.0, 1.0), p.y + 1.5 * moduleBattle._Range(0, 1.0));
            eff.startPos       = eff.randomPosition;
        }
        else
        {
            eff.startPos = eff.position_;
        }


        if (sourceBuff != null)
        {
            eff.m_buffCheck = sourceBuff.version;
            eff.lifeTime    = -1;
        }
        else
        {
            eff.m_buffCheck = 0;
        }

        eff.m_inverted = source && !source.isForward;
        eff.UpdateInvert();

        eff.InitTrigger();

#if AI_LOG
        eff.logId = MonsterCreature.GetMonsterRoomIndex();
        Module_AI.LogBattleMsg(source, "create a FollowTargetEffect[logId: {0}] with target {0} startPos {1}, lifeTime = {1}  startForward is {2}", eff.logId, eff.position_, eff.lifeTime, eff.startForward);
#endif

        return(eff);
    }
Beispiel #16
0
    public static FlyingEffect Create(StateMachineInfo.FlyingEffect effInfo, Creature source, int overrideForward, bool invert, StateMachineInfo.Effect hitEffect, Vector3_ root, Vector3_ rootEular, Vector3 rootRot)
    {
        var fe = ConfigManager.Get <FlyingEffectInfo>(effInfo.effect);

        if (!fe)
        {
            Logger.LogWarning("FlyingEffect::Create: Could not create flying effect [{0}], could not find effect config from config_flyingEffectInfos", effInfo.effect);
            return(null);
        }

        FightRecordManager.RecordLog <LogString>(log =>
        {
            log.tag   = (byte)TagType.CreateFlyEffect;
            log.value = fe.effect;
        });

        var off = effInfo.offset * 0.1;

        if (invert)
        {
            off.x = -off.x;
            off.z = -off.z;
        }

        var direction = effInfo.direction;
        var rotation  = effInfo.rotation;

        direction.Set(direction.z, direction.y, -direction.x);
        rotation.Set(-rotation.x, rotation.y, rotation.z);

        var eular = rootEular + direction;

        eular.z = Mathd.ClampAngle(eular.z);

        var z   = Mathd.AngToRad(eular.z);
        var dir = new Vector3_(Mathd.Cos(z), -Mathd.Sin(z));
        var pos = root + off;
        var eff = Create <FlyingEffect>(fe.effect, fe.effect, pos, rotation);

        eff.enableUpdate = true;

        if (invert)
        {
            dir.x = -dir.x;
        }

        eff.sourceBuff = null;
        eff.follow     = false;
        eff.m_inherit  = false;
        eff.m_time     = 0;

        eff.m_originEular = eff.localEulerAngles;
        eff.lockForward   = Vector3.zero;
        eff.startForward  = overrideForward == 0 ? !source || source.isForward : overrideForward > 0;

        eff.m_curSectionIdx     = 0;
        eff.m_curActivedSection = -1;
        eff.m_curSubEffectIdx   = 0;
        eff.m_curSoundEffectIdx = 0;
        eff.m_curShakeIdx       = 0;
        eff.m_groundHited       = false;
        eff.m_renderTime        = 0;

        eff.effectInfo   = fe;
        eff.source       = source;
        eff.position_    = pos;
        eff.velocity     = effInfo.velocity * 0.0001;
        eff.acceleration = effInfo.acceleration * 0.0001;
        eff.lifeTime     = fe.lifeTime;
        eff.hitEffect    = hitEffect;

        eff.CreateCollider(rootRot, dir, eular);

        eff.m_inverted = invert;
        eff.UpdateInvert();

#if AI_LOG
        eff.logId = MonsterCreature.GetMonsterRoomIndex();
        Module_AI.LogBattleMsg(source, "create a flying effect[logId:{0}] with pos {1}, lifeTime = {2}  startForward is {3}", eff.logId, eff.position_, eff.lifeTime, eff.startForward);
#endif
        return(eff);
    }