public Effect PlayEffect(StateMachineInfo.Effect effInfo, Buff sourceBuff = null) { // always ignore empty effect if (effInfo.isEmpty) { return(null); } var node = string.IsNullOrEmpty(effInfo.spawnAt) ? transform : Util.FindChild(creature.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); } for (var i = node.childCount - 1; i >= 0; i--) { var c = node.GetChild(i); if (c.gameObject.activeSelf && c.name.Equals(effInfo.effect)) { c.SafeSetActive(false); } } return(Effect.Create(effInfo, node, creature, sourceBuff)); }
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 }
public FlyingEffect PlayEffect(StateMachineInfo.FlyingEffect effInfo, StateMachineInfo.Effect hitEffect) { var node = string.IsNullOrEmpty(effInfo.spawnAt) ? transform : Util.FindChild(creature.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(FlyingEffect.Create(effInfo, creature, 0, !creature.isForward, hitEffect, creature.position_, Vector3_.zero, creature.eulerAngles)); }
public void SetAttackBox(StateMachineInfo.AttackBox attackBox, StateMachineInfo.Effect hit, bool forward) { Clear(); m_forward = forward; attackBox.start *= 0.1; attackBox.size *= 0.1; _SetAttackBox(attackBox, hit); CreateSnapShot(); }
private void _Clear() { m_targetCount = 0; m_attackBox = StateMachineInfo.AttackBox.empty; m_hitEff = StateMachineInfo.Effect.empty; m_bulletAttackInfo = 0; m_attackInfo = 0; m_forward = true; gameObject.SetActive(false); m_cols?.Clear(); }
private void RefreshAllBuff() { short[] props = moduleLabyrinth.sneakPlayerDetail.propIds; if (props == null || props.Length == 0) { return; } for (int i = 0; i < props.Length; i++) { PropToBuffInfo info = propToBuffDic.Get(props[i]); if (!info) { continue; } if (info.buffId > 0) { BuffInfo buff = ConfigManager.Get <BuffInfo>(info.buffId); if (buff) { Buff.Create(buff, player); } } if (!string.IsNullOrEmpty(info.effect)) { StateMachineInfo.Effect e = new StateMachineInfo.Effect(); e.effect = info.effect; e.follow = true; if (player && player.behaviour) { player.behaviour.effects.PlayEffect(e); } } } }
public void Set(StateMachineInfo.AttackBox _attackBox, StateMachineInfo.Effect _hit, bool _isForward) { attackBox = _attackBox; hit = _hit; isForward = _isForward; }
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); }
public static Effect Create(StateMachineInfo.Effect effInfo, Transform node, Creature source = null, Buff sourceBuff = null) { var pos = effInfo.offset * 0.1f; var rotation = effInfo.rotation; if (node) { pos = node.TransformPoint(pos); rotation = (node.rotation * Quaternion.Euler(rotation)).eulerAngles; } if (effInfo.lockY != 0) { pos.y = effInfo.lockY < 0 ? 0 : effInfo.lockY; } var eff = Create <Effect>(effInfo.effect, effInfo.effect, pos, rotation); eff.source = source; eff.follow = effInfo.follow; eff.sourceBuff = sourceBuff; eff.m_inherit = effInfo.inherit; eff.m_freez = !effInfo.markedHit && source && !source.stateMachine.playable; if (effInfo.follow) #if UNITY_EDITOR { eff.transform.SetParent(node, true); if (source && source.lockLayer) { Util.SetLayer(eff.gameObject, source.lockedLayer); } } #else { eff.transform.SetParent(node, true); } #endif eff.m_originEular = eff.localEulerAngles; eff.lockForward = effInfo.syncRotation ? Vector3.zero : eff.transform.forward; eff.startForward = !source || source.isForward; if (sourceBuff != null) { eff.m_buffCheck = sourceBuff.version; eff.lifeTime = -1; } else { eff.m_buffCheck = 0; } if (source) { if (effInfo.interrupt) { source.AddEventListener(CreatureEvents.QUIT_STATE, eff.OnCreatureQuitState); } if (effInfo.follow) { source.AddEventListener(CreatureEvents.DIRECTION_CHANGED, eff.OnCreatureDirectionChanged); source.AddEventListener(CreatureEvents.MORPH_MODEL_CHANGED, eff.OnCreatureMorphModelChanged); if (node != source.behaviour.effects.transform) { source.AddEventListener(CreatureEvents.RESET_LAYERS, eff.OnCreatureResetLayers); } } source.AddEventListener(CreatureEvents.STATE_PLAYABLE, eff.OnCreatureStatePlayable); } eff.m_inverted = source && !source.isForward; eff.UpdateInvert(); return(eff); }