public FollowTargetEffect PlayEffect(StateMachineInfo.FollowTargetEffect effInfo, Buff sourceBuff, Creature target, Creature initNode) { // always ignore empty effect if (effInfo.isEmpty) { return(null); } var node = string.IsNullOrEmpty(effInfo.spawnAt) ? initNode.transform : Util.FindChild(initNode.activeRootNode, effInfo.spawnAt); if (!node) { Logger.LogWarning("CreatureEffects::PlayEffect: Could not play effect [{0}], could not find bind node [{1}]", effInfo.effect, effInfo.spawnAt); return(null); } return(FollowTargetEffect.Create(effInfo, node, target, initNode.position_, creature, sourceBuff)); }
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); }