public void SendConcurrentMessage(string msgId, params object[] args) { MessageInfo msgInfo = new MessageInfo(); msgInfo.m_MsgId = msgId; msgInfo.m_Args = args; Queue <MessageInfo> queue; if (m_ConcurrentMessageQueues.TryGetValue(msgId, out queue)) { if (msgId != "start" && msgId != "PlayerStart" && !msgId.StartsWith("common_")) { LogSystem.Warn("StoryInstance queue concurrent message {0}", msgId); } queue.Enqueue(msgInfo); ++m_ConcurrentMessageCount; } else { //忽略没有处理的消息 //LogSystem.Info("StoryInstance ignore concurrent message {0}", msgId); } }
public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime) { GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo; if (null == senderObj) return false; GameObject obj = senderObj.GfxObj; if (null == obj) return false; if (curSectionTime < StartTime) { return true; } if (0 == m_Type.CompareTo("anim")) { Animator animator = obj.GetComponentInChildren<Animator>(); if (null != animator) { float length = 0; int layerCount = animator.layerCount; for (int i = 0; i < layerCount; ++i) { AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo(i); //LogSystem.Info("adjustsectionduration anim, skill id:{0} dsl skill id:{1}, length:{2} normalized time:{3} loop:{4} layer:{5} layer count:{6}", senderObj.SkillId, instance.DslSkillId, stateInfo.length, stateInfo.normalizedTime, stateInfo.loop, i, layerCount); if (length < stateInfo.length && !float.IsInfinity(stateInfo.length)) length = stateInfo.length; } if (length > Geometry.c_FloatPrecision) { long newDuration = (long)(length * 1000) + m_DeltaTime; if (instance.CurSectionDuration < newDuration) instance.SetCurSectionDuration(newDuration); } else { //LogSystem.Warn("adjustsectionduration anim length is 0, skill id:{0} dsl skill id:{1}", senderObj.SkillId, instance.DslSkillId); return true; } } } else if (0 == m_Type.CompareTo("impact")) { int time = EntityController.Instance.GetImpactDuration(senderObj.ObjId, senderObj.SkillId, senderObj.Seq); if (time > 0) { long newDuration = (long)time + m_DeltaTime; if (instance.CurSectionDuration < newDuration) instance.SetCurSectionDuration(newDuration); } else { LogSystem.Warn("adjustsectionduration impact duration is 0, skill id:{0} dsl skill id:{1}", senderObj.SkillId, instance.DslSkillId); } } else { bool handled = false; Animator animator = obj.GetComponentInChildren<Animator>(); if (null != animator && null != animator.runtimeAnimatorController) { float length = 0; var clips = animator.runtimeAnimatorController.animationClips; for (int i = 0; i < clips.Length; ++i) { if (clips[i].name == m_Type) { length = clips[i].length; handled = true; break; } } if (length > Geometry.c_FloatPrecision) { long newDuration = (long)(length * 1000) + m_DeltaTime; if (instance.CurSectionDuration < newDuration) instance.SetCurSectionDuration(newDuration); } else { LogSystem.Warn("adjustsectionduration variable time is 0, skill id:{0} dsl skill id:{1} type:{2}", senderObj.SkillId, instance.DslSkillId, m_Type); } } if (!handled) { int time = TryGetTimeFromConfig(instance); if (time > 0) { long newDuration = (long)time + m_DeltaTime; if (instance.CurSectionDuration < newDuration) instance.SetCurSectionDuration(newDuration); } else { LogSystem.Warn("adjustsectionduration variable time is 0, skill id:{0} dsl skill id:{1} type:{2}", senderObj.SkillId, instance.DslSkillId, m_Type); } } } return false; }
private bool Prepare(GfxSkillSenderInfo senderObj, SkillInstance instance, GameObject obj, GameObject targetObj) { if (!m_TargetChecked) { m_TargetChecked = true; m_RealDuration = m_Duration; m_RealVelocity = m_Velocity; if (m_RealDuration <= 0) { m_RealDuration += instance.CurSectionDuration; } if (m_RealDuration <= 0) { LogSystem.Warn("charge duration is 0, skill id:{0} dsl skill id:{1}", senderObj.SkillId, instance.DslSkillId); return(false); } m_StartPos = obj.transform.position; Vector3 targetPos = Vector3.zero; if (null != targetObj) { targetPos = targetObj.transform.position; } if (!m_IsFreeMove && targetPos.sqrMagnitude > Geometry.c_FloatPrecision) { float degree = Geometry.GetYRadian(new ScriptRuntime.Vector2(m_StartPos.x, m_StartPos.z), new ScriptRuntime.Vector2(targetPos.x, targetPos.z)); ScriptRuntime.Vector2 newPos; if (m_RandRelativeToSelf) { int v = Helper.Random.Next(); if (v < 50) { newPos = new ScriptRuntime.Vector2(m_StartPos.x, m_StartPos.z) + Geometry.GetRotate(new ScriptRuntime.Vector2(m_Offset.x, m_Offset.z), degree); targetPos = new Vector3(newPos.X, m_StartPos.y + m_Offset.y, newPos.Y); } else { newPos = new ScriptRuntime.Vector2(m_StartPos.x, m_StartPos.z) + Geometry.GetRotate(new ScriptRuntime.Vector2(-m_Offset.x, m_Offset.z), degree); targetPos = new Vector3(newPos.X, m_StartPos.y + m_Offset.y, newPos.Y); } } else if (m_RelativeToSelf) { newPos = new ScriptRuntime.Vector2(m_StartPos.x, m_StartPos.z) + Geometry.GetRotate(new ScriptRuntime.Vector2(m_Offset.x, m_Offset.z), degree); targetPos = new Vector3(newPos.X, m_StartPos.y + m_Offset.y, newPos.Y); } else if (m_RandRelativeToTarget) { int v = Helper.Random.Next(); if (v < 50) { newPos = new ScriptRuntime.Vector2(targetPos.x, targetPos.z) + Geometry.GetRotate(new ScriptRuntime.Vector2(m_Offset.x, m_Offset.z), degree); targetPos = new Vector3(newPos.X, targetPos.y + m_Offset.y, newPos.Y); } else { newPos = new ScriptRuntime.Vector2(targetPos.x, targetPos.z) + Geometry.GetRotate(new ScriptRuntime.Vector2(-m_Offset.x, m_Offset.z), degree); targetPos = new Vector3(newPos.X, targetPos.y + m_Offset.y, newPos.Y); } } else { newPos = new ScriptRuntime.Vector2(targetPos.x, targetPos.z) + Geometry.GetRotate(new ScriptRuntime.Vector2(m_Offset.x, m_Offset.z), degree); targetPos = new Vector3(newPos.X, targetPos.y + m_Offset.y, newPos.Y); } m_Forward = targetPos - m_StartPos; m_Forward.y = 0; m_Forward.Normalize(); if (m_StopAtTarget == (int)StopAtTargetType.AdjustVelocity) { m_RealVelocity = (long)(1000.0f * (targetPos - m_StartPos).magnitude / m_RealDuration); m_TargetPos = targetPos; } else if (m_StopAtTarget == (int)StopAtTargetType.AdjustTime) { m_RealDuration = (long)(1000.0f * (targetPos - m_StartPos).magnitude / m_RealVelocity); m_TargetPos = targetPos; } else { m_TargetPos = m_StartPos + m_Forward * m_RealVelocity * m_RealDuration / 1000.0f; } } else { if (m_RandRelativeToSelf) { int v = Helper.Random.Next(); if (v < 50) { m_TargetPos = obj.transform.TransformPoint(m_Offset.x, 0, m_Offset.z); } else { m_TargetPos = obj.transform.TransformPoint(-m_Offset.x, 0, m_Offset.z); } } else if (m_RelativeToSelf) { m_TargetPos = obj.transform.TransformPoint(m_Offset.x, 0, m_Offset.z); } else { m_TargetPos = obj.transform.TransformPoint(0, 0, m_RealVelocity * m_RealDuration / 1000.0f); } m_Forward = obj.transform.forward; } } return(true); }
public bool StartSkill(int actorId, TableConfig.Skill configData, int seq, params Dictionary <string, object>[] locals) { bool ret = false; if (null == configData) { LogSystem.Error("{0} can't cast skill, config is null !", actorId, seq); Helper.LogCallStack(); return(false); } if (!EntityController.Instance.CanCastSkill(actorId, configData, seq)) { EntityController.Instance.CancelCastSkill(actorId); LogSystem.Warn("{0} can't cast skill {1} {2}, cancel.", actorId, configData.id, seq); EntityController.Instance.CancelIfImpact(actorId, configData, seq); return(false); } GfxSkillSenderInfo senderInfo = EntityController.Instance.BuildSkillInfo(actorId, configData, seq); if (null != senderInfo && null != senderInfo.GfxObj) { int skillId = senderInfo.SkillId; GameObject obj = senderInfo.GfxObj; SkillLogicInfo logicInfo = m_SkillLogicInfos.Find(info => info.GfxObj == obj && info.SkillId == skillId && info.Seq == seq); if (logicInfo != null) { LogSystem.Warn("{0} is casting skill {1} {2}, cancel.", actorId, skillId, seq); EntityController.Instance.CancelIfImpact(actorId, configData, seq); return(false); } SkillInstanceInfo inst = null; SkillInstance innerInstance = null; if (skillId == PredefinedSkill.c_EmitSkillId) { for (int i = 0; i < locals.Length; ++i) { object instObj; if (locals[i].TryGetValue("emitskill", out instObj)) { innerInstance = instObj as SkillInstance; } } if (null == innerInstance) { LogSystem.Warn("{0} use predefined skill {1} {2} but not found emitskill, cancel.", actorId, skillId, seq); //EntityController.Instance.CancelIfImpact(actorId, configData, seq); //return false; } } else if (skillId == PredefinedSkill.c_HitSkillId) { for (int i = 0; i < locals.Length; ++i) { object instObj; if (locals[i].TryGetValue("hitskill", out instObj)) { innerInstance = instObj as SkillInstance; } } if (null == innerInstance) { LogSystem.Warn("{0} use predefined skill {1} {2} but not found hitskill, cancel.", actorId, skillId, seq); //EntityController.Instance.CancelIfImpact(actorId, configData, seq); //return false; } } if (null == innerInstance) { inst = NewSkillInstance(skillId, senderInfo.ConfigData); } else { inst = NewInnerSkillInstance(skillId, innerInstance); } if (null != inst) { m_SkillLogicInfos.Add(new SkillLogicInfo(senderInfo, inst)); } else { LogSystem.Warn("{0} cast skill {1} {2}, alloc failed.", actorId, skillId, seq); EntityController.Instance.CancelIfImpact(actorId, configData, seq); return(false); } logicInfo = m_SkillLogicInfos.Find(info => info.GfxObj == obj && info.SkillId == skillId && info.Seq == seq); if (null != logicInfo) { if (null != locals) { int localCount = locals.Length; for (int i = 0; i < localCount; ++i) { foreach (KeyValuePair <string, object> pair in locals[i]) { logicInfo.SkillInst.SetVariable(pair.Key, pair.Value); } } } GameObject target = senderInfo.TargetGfxObj; if (null != target && target != obj && configData.type == (int)SkillOrImpactType.Skill) { Trigers.TriggerUtil.Lookat(obj, target.transform.position); } EntityController.Instance.ActivateSkill(actorId, skillId, seq); logicInfo.SkillInst.Start(logicInfo.Sender); ret = true; } } return(ret); }
public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime) { GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo; if (null == senderObj) { return(false); } Scene scene = senderObj.Scene; EntityInfo obj = senderObj.GfxObj; if (null == obj) { return(false); } bool isTower = scene.EntityController.GetEntityType(senderObj.GfxObj) == (int)EntityTypeEnum.Tower; if (isTower) { return(false); } if (!m_TargetChecked) { m_TargetChecked = true; m_RealDuration = m_Duration; m_RealVelocity = m_Velocity; if (m_RealDuration <= 0) { m_RealDuration += instance.CurSectionDuration; } if (m_RealDuration <= 0) { LogSystem.Warn("jump duration is 0, skill id:{0} dsl skill id:{1}", senderObj.SkillId, instance.DslSkillId); return(false); } EntityInfo targetObj = senderObj.TargetGfxObj; if (null != targetObj) { Vector3 srcPos = obj.GetMovementStateInfo().GetPosition3D(); Vector3 targetPos = targetObj.GetMovementStateInfo().GetPosition3D(); float degree = Geometry.GetYRadian(new ScriptRuntime.Vector2(srcPos.X, srcPos.Z), new ScriptRuntime.Vector2(targetPos.X, targetPos.Z)); ScriptRuntime.Vector2 newPos = new ScriptRuntime.Vector2(targetPos.X, targetPos.Z) + Geometry.GetRotate(new ScriptRuntime.Vector2(m_Offset.X, m_Offset.Z), degree); targetPos = new Vector3(newPos.X, targetPos.Y + m_Offset.Y, newPos.Y); if (m_StopAtTarget == (int)StopAtTargetType.AdjustVelocity) { m_RealVelocity = (long)(1000.0f * (targetPos - srcPos).Length() / m_RealDuration); } else if (m_StopAtTarget == (int)StopAtTargetType.AdjustTime) { m_RealDuration = (long)(1000.0f * (targetPos - targetPos).Length() / m_RealVelocity); CalcYVelocityAndG(); } m_Forward = targetPos - srcPos; m_Forward.Normalize(); } else { m_Forward = Geometry.GetRotate(new Vector3(0, 0, 1), obj.GetMovementStateInfo().GetFaceDir()); } m_InitY = obj.GetMovementStateInfo().PositionY; } if (curSectionTime < StartTime) { return(true); } else if (curSectionTime <= m_RealDuration) { float t = (float)(int)(curSectionTime - StartTime) / 1000.0f; float disty = m_YVelocity * t - m_G * t * t / 2; float dist = TriggerUtil.ConvertToSecond(delta) * m_RealVelocity; Vector3 targetPos = obj.GetMovementStateInfo().GetPosition3D() + m_Forward * dist; targetPos.Y = m_InitY + disty; TriggerUtil.MoveObjTo(obj, targetPos); return(true); } else { return(false); } }
public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime) { GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo; if (null == senderObj) { return(false); } if (senderObj.ConfigData.type == (int)SkillOrImpactType.Skill) { return(false);//track只能在impact或buff里使用 } GameObject obj = senderObj.GfxObj; if (null != obj) { if (curSectionTime >= StartTime) { if (!m_IsStarted) { m_IsStarted = true; Vector3 dest; string trackBone = m_TrackBone.Get(instance); m_BoneTransform = Utility.FindChildRecursive(obj.transform, trackBone); if (null != m_BoneTransform) { dest = m_BoneTransform.position; } else { dest = obj.transform.position; dest.y += 1.5f; LogSystem.Warn("[skill:{0} dsl skill id:{1}] track bone {2} can't find.", senderObj.SkillId, instance.DslSkillId, trackBone); } m_StartPos = EntityController.Instance.GetImpactSenderPosition(senderObj.ObjId, senderObj.SkillId, senderObj.Seq); dest = Utility.FrontOfTarget(m_StartPos, dest, 0.1f); object speedObj; if (instance.Variables.TryGetValue("emitSpeed", out speedObj)) { m_Speed = (float)speedObj; } else { return(false); } float duration = m_Duration.Get(instance); if (duration > Geometry.c_FloatPrecision) { float d = duration / 1000.0f; m_Lifetime = d; m_Speed = (dest - m_StartPos).magnitude / m_Lifetime; } else { m_Lifetime = 1.0f; if (m_Speed > Geometry.c_FloatPrecision) { m_Lifetime = (dest - m_StartPos).magnitude / m_Speed; } } long newSectionDuration = StartTime + (long)(m_Lifetime * 1000); if (instance.CurSectionDuration < newSectionDuration) { instance.SetCurSectionDuration(newSectionDuration); } Quaternion dir; object dirObj; if (instance.Variables.TryGetValue("emitDir", out dirObj)) { dir = (Quaternion)dirObj; } else { dir = Quaternion.identity; } Vector3 scale; object scaleObj; if (instance.Variables.TryGetValue("emitScale", out scaleObj)) { scale = (Vector3)scaleObj; } else { scale = Vector3.one; } Vector3 lookDir = dest - m_StartPos; Quaternion q = Quaternion.LookRotation(lookDir); m_ControlPos = m_StartPos + Vector3.Scale(q * dir * Vector3.forward, scale * lookDir.magnitude * 0.5f); string effectPath = SkillParamUtility.RefixResourceVariable("emitEffect", instance, senderObj.ConfigData.resources); m_Effect = ResourceSystem.Instance.NewObject(effectPath, m_Lifetime) as GameObject; if (null != m_Effect) { senderObj.TrackEffectObj = m_Effect; TriggerUtil.SetObjVisible(m_Effect, true); m_Effect.SetActive(false); m_Effect.transform.position = m_StartPos; m_Effect.transform.localRotation = q; m_Effect.SetActive(true); } else { if (string.IsNullOrEmpty(effectPath)) { LogSystem.Warn("[skill:{0} dsl skill id:{1}] track effect is empty.", senderObj.SkillId, instance.DslSkillId); } else { LogSystem.Warn("[skill:{0} dsl skill id:{1}] track effect {2} can't find.", senderObj.SkillId, instance.DslSkillId, effectPath); } } } else if (null != m_Effect) { if (!m_NotMove && !m_IsHit) { Vector3 dest; if (null != m_BoneTransform) { dest = m_BoneTransform.position; } else { dest = obj.transform.position; dest.y += 1.5f; } dest = Utility.FrontOfTarget(m_StartPos, dest, 0.1f); //m_Effect.transform.position = Vector3.MoveTowards(m_Effect.transform.position, dest, m_RealSpeed * Time.deltaTime); m_Effect.transform.position = Utility.GetBezierPoint(m_StartPos, m_ControlPos, dest, (curSectionTime - StartTime) / 1000.0f / m_Lifetime); if ((dest - m_Effect.transform.position).sqrMagnitude <= 0.01f) { m_HitEffectRotation = Quaternion.LookRotation(m_StartPos - dest); if (m_NoImpact) { instance.SetVariable("hitEffectRotation", m_HitEffectRotation); } else { int impactId = EntityController.Instance.GetTrackSendImpact(senderObj.ObjId, senderObj.Seq, instance.Variables); Dictionary <string, object> args; TriggerUtil.CalcImpactConfig(0, impactId, instance, senderObj.ConfigData, out args); if (args.ContainsKey("hitEffectRotation")) { args["hitEffectRotation"] = m_HitEffectRotation; } else { args.Add("hitEffectRotation", m_HitEffectRotation); } EntityController.Instance.TrackSendImpact(senderObj.ObjId, senderObj.SkillId, senderObj.Seq, impactId, args); int senderId, targetId; EntityController.Instance.CalcSenderAndTarget(senderObj, out senderId, out targetId); } m_IsHit = true; } } if (curSectionTime > StartTime + m_Lifetime * 1000) { m_Effect.SetActive(false); ResourceSystem.Instance.RecycleObject(m_Effect); m_Effect = null; instance.StopCurSection(); return(false); } } else { return(false); } //GameFramework.LogSystem.Debug("EmitEffectTriger:{0}", m_EffectPath); return(true); } else { return(true); } } else { instance.StopCurSection(); return(false); } }
protected override bool ExecCommand(StoryInstance instance, StoryValueParam <int, float, float, float> _params, long delta) { Robot robot = instance.Context as Robot; if (null != robot) { if (m_CurTime < 2000) { m_CurTime += delta; int skillId = _params.Param1Value; float x = _params.Param2Value; float z = _params.Param3Value; float dir = _params.Param4Value; switch (m_CurPhase) { case 0: { m_CurPhase = 1; if (IsExSkill(skillId) || skillId == 120741 || skillId == 161501) { LogSystem.Warn("robot cast ex skill {0}", skillId); } robot.RoomNetworkSystem.SyncPlayerSkill(skillId, x, z, dir); SkillInstance skillInst = robot.SkillAnalysis.Analyze(skillId); if (null != skillInst) { m_ImpactsToOther = skillInst.EnableImpactsToOther; m_ImpactsToMyself = skillInst.EnableImpactsToMyself; } robot.RoomNetworkSystem.SyncGfxMoveControlStart(robot.MyselfId, x, z, skillId, true); } break; case 1: if (m_CurTime > 1000) { m_CurPhase = 2; if (null != m_ImpactsToMyself) { foreach (int impactId in m_ImpactsToMyself) { robot.RoomNetworkSystem.SyncSendImpact(robot.MyselfId, impactId, robot.MyselfId, skillId, 1000, 10, 10, 10, 0); } } if (null != m_ImpactsToOther) { foreach (int impactId in m_ImpactsToOther) { foreach (int objId in robot.OtherIds) { robot.RoomNetworkSystem.SyncSendImpact(robot.MyselfId, impactId, objId, skillId, 1000, 10, 10, 10, 0); } } } } break; case 2: if (m_CurTime > 1500) { m_CurPhase = 3; robot.RoomNetworkSystem.SyncGfxMoveControlStop(robot.MyselfId, x, z, skillId, true); robot.RoomNetworkSystem.SyncPlayerStopSkill(skillId); } break; } return(true); } } return(false); }
public bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime) { GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo; if (null == senderObj) { return(false); } if (senderObj.ConfigData.type == (int)SkillOrImpactType.Skill) { return(false);//track只能在impact或buff里使用 } GameObject obj = senderObj.GfxObj; if (null != obj) { if (curSectionTime >= m_TriggerProxy.StartTime) { if (!m_IsStarted) { m_IsStarted = true; Vector3 dest; string trackBone = m_TrackBone.Get(instance); m_BoneTransform = Utility.FindChildRecursive(obj.transform, trackBone); if (null != m_BoneTransform) { dest = m_BoneTransform.position; } else { dest = obj.transform.position; dest.y += 1.5f; LogSystem.Warn("[skill:{0} dsl skill id:{1}] trackbullet bone {2} can't find.", senderObj.SkillId, instance.DslSkillId, trackBone); } m_StartPos = EntityController.Instance.GetImpactSenderPosition(senderObj.ObjId, senderObj.SkillId, senderObj.Seq); object speedObj; if (instance.Variables.TryGetValue("emitSpeed", out speedObj)) { m_Speed = (float)speedObj; } else { return(false); } long duration = m_Duration.Get(instance); m_Lifetime = duration / 1000.0f; if (Geometry.DistanceSquare(m_StartPos.x, m_StartPos.z, dest.x, dest.z) > 0.01f) { m_TargetPos = Utility.FrontOfTarget(dest, m_StartPos, m_Speed * m_Lifetime); } else { m_TargetPos = obj.transform.TransformPoint(0, 0, m_Speed * m_Lifetime); } long newSectionDuration = m_TriggerProxy.StartTime + (long)(m_Lifetime * 1000); if (instance.CurSectionDuration < newSectionDuration) { instance.SetCurSectionDuration(newSectionDuration); } Quaternion dir; object dirObj; if (instance.Variables.TryGetValue("emitDir", out dirObj)) { dir = (Quaternion)dirObj; } else { dir = Quaternion.identity; } Vector3 scale; object scaleObj; if (instance.Variables.TryGetValue("emitScale", out scaleObj)) { scale = (Vector3)scaleObj; } else { scale = Vector3.one; } Vector3 lookDir = dest - m_StartPos; Quaternion q = Quaternion.LookRotation(lookDir); m_ControlPos = m_StartPos + Vector3.Scale(q * dir * Vector3.forward, scale * lookDir.magnitude * 0.5f); string effectPath = SkillParamUtility.RefixResourceVariable("emitEffect", instance, senderObj.ConfigData.resources); m_Effect = ResourceSystem.Instance.NewObject(effectPath, m_Lifetime) as GameObject; if (null != m_Effect) { senderObj.TrackEffectObj = m_Effect; TriggerUtil.SetObjVisible(m_Effect, true); m_Effect.SetActive(false); m_Effect.transform.position = m_StartPos; m_Effect.transform.localRotation = q; m_Effect.SetActive(true); EffectManager em = instance.CustomDatas.GetData <EffectManager>(); if (em == null) { em = new EffectManager(); instance.CustomDatas.AddData <EffectManager>(em); } em.AddEffect(m_Effect); em.SetParticleSpeed(instance.EffectScale); } else { if (string.IsNullOrEmpty(effectPath)) { LogSystem.Warn("[skill:{0} dsl skill id:{1}] trackbullet effect is empty.", senderObj.SkillId, instance.DslSkillId); } else { LogSystem.Warn("[skill:{0} dsl skill id:{1}] trackbullet effect {2} can't find.", senderObj.SkillId, instance.DslSkillId, effectPath); } } } else if (null != m_Effect) { Vector3 dest; if (null != m_BoneTransform) { dest = m_BoneTransform.position; } else { dest = obj.transform.position; dest.y += 1.5f; } dest = Utility.FrontOfTarget(m_StartPos, dest, 0.1f); //m_Effect.transform.position = Vector3.MoveTowards(m_Effect.transform.position, m_TargetPos, m_RealSpeed * Time.deltaTime); m_Effect.transform.position = Utility.GetBezierPoint(m_StartPos, m_ControlPos, m_TargetPos, (curSectionTime - m_TriggerProxy.StartTime) / 1000.0f / m_Lifetime); var pos = m_Effect.transform.position; if (!m_IsHit) { float distSqr = float.MaxValue; if (m_LastPos.sqrMagnitude > Geometry.c_FloatPrecision) { ScriptRuntime.Vector2 np; ScriptRuntime.Vector2 targetPos = new ScriptRuntime.Vector2(dest.x, dest.z); ScriptRuntime.Vector2 lastPos = new ScriptRuntime.Vector2(m_LastPos.x, m_LastPos.z); distSqr = Geometry.PointToLineSegmentDistanceSquare(targetPos, lastPos, new ScriptRuntime.Vector2(pos.x, pos.z), out np); } else { distSqr = (dest - pos).sqrMagnitude; } m_LastPos = pos; if (distSqr <= m_BulletRadiusSquare) { float curTime = Time.time; float interval = m_DamageInterval.Get(instance) / 1000.0f; if (m_LastTime + interval <= curTime) { m_LastTime = curTime; m_HitEffectRotation = Quaternion.LookRotation(m_StartPos - dest); int impactId = TriggerUtil.GetSkillImpactId(instance.Variables, senderObj.ConfigData); Dictionary <string, object> args; TriggerUtil.CalcImpactConfig(0, impactId, instance, senderObj.ConfigData, out args); if (args.ContainsKey("hitEffectRotation")) { args["hitEffectRotation"] = m_HitEffectRotation; } else { args.Add("hitEffectRotation", m_HitEffectRotation); } EntityController.Instance.TrackSendImpact(senderObj.ObjId, senderObj.SkillId, senderObj.Seq, impactId, args); //m_IsHit = true; } } } if (curSectionTime > m_TriggerProxy.StartTime + m_Lifetime * 1000) { m_Effect.SetActive(false); ResourceSystem.Instance.RecycleObject(m_Effect); m_Effect = null; instance.StopCurSection(); return(false); } } else { return(false); } return(true); } else { return(true); } } else { instance.StopCurSection(); return(false); } }
internal static TokenData GetAuthenticated(string tokenCode, string address, CommonParam param) { TokenData result = null; try { if (String.IsNullOrWhiteSpace(tokenCode) || String.IsNullOrWhiteSpace(address)) { return(null); } if (String.IsNullOrWhiteSpace(Config.BASE_URI)) { LogSystem.Warn("Khong co cau hinh dia chi AAS"); return(null); } using (var client = new HttpClient()) { client.BaseAddress = new Uri(Config.BASE_URI); client.DefaultRequestHeaders.Accept.Clear(); client.Timeout = new TimeSpan(0, 0, Config.TIME_OUT); client.DefaultRequestHeaders.Add(HttpHeaderConstant.TOKEN_PARAM, tokenCode); client.DefaultRequestHeaders.Add(HttpHeaderConstant.ADDRESS_PARAM, address); HttpResponseMessage respenseMessage = client.GetAsync(AAS.URI.AasToken.GET_AUTHENTICATED).Result; LogSystem.Debug(string.Format("Request URI: {0}{1}", Config.BASE_URI, AAS.URI.AasToken.GET_AUTHENTICATED)); if (respenseMessage.IsSuccessStatusCode) { string responseData = respenseMessage.Content.ReadAsStringAsync().Result; LogSystem.Debug(string.Format("Response data: {0}", responseData)); ApiResultObject <TokenData> data = JsonConvert.DeserializeObject <ApiResultObject <TokenData> >(responseData); if (data != null && data.Data != null && data.Success) { result = data.Data; } else { LogSystem.Info(String.Format("Khong lay duoc TokenData. TokeCode = {0}, Address = {1}", tokenCode, address)); if (data.Param != null && data.Param.Messages != null && data.Param.Messages.Count > 0) { param.Messages.AddRange(data.Param.Messages); } if (data.Param != null && data.Param.BugCodes != null && data.Param.BugCodes.Count > 0) { param.BugCodes.AddRange(data.Param.BugCodes); } } } else { throw new Exception(string.Format("Loi khi goi API: {0}{1}. StatusCode: {2}", Config.BASE_URI, AAS.URI.AasToken.GET_AUTHENTICATED, respenseMessage.StatusCode.GetHashCode())); } } } catch (Exception ex) { LogSystem.Error(ex); result = null; } return(result); }
internal static bool Set(string tokenCode, string dataKey, string data, CommonParam param) { bool result = false; try { if (String.IsNullOrWhiteSpace(tokenCode) || String.IsNullOrWhiteSpace(dataKey) || String.IsNullOrWhiteSpace(dataKey)) { return(false); } if (String.IsNullOrWhiteSpace(Config.BASE_URI)) { LogSystem.Warn("Khong co cau hinh dia chi AAS"); return(false); } using (var client = new HttpClient()) { client.BaseAddress = new Uri(Config.BASE_URI); client.DefaultRequestHeaders.Accept.Clear(); client.Timeout = new TimeSpan(0, 0, Config.TIME_OUT); client.DefaultRequestHeaders.Add(HttpHeaderConstant.TOKEN_PARAM, tokenCode); CredentialData credentialData = new CredentialData(Config.BACKEND_CODE, tokenCode, dataKey, data); HttpResponseMessage responseMessage = client.PostAsJsonAsync(AAS.URI.AasToken.SET_CREDENTIAL_DATA, credentialData).Result; LogSystem.Debug(string.Format("Request URI: {0}{1}", Config.BASE_URI, AAS.URI.AasToken.SET_CREDENTIAL_DATA)); if (responseMessage.IsSuccessStatusCode) { string responseData = responseMessage.Content.ReadAsStringAsync().Result; LogSystem.Debug(string.Format("Response data: {0}", responseData)); ApiResultObject <bool> dataRs = JsonConvert.DeserializeObject <ApiResultObject <bool> >(responseData); if (dataRs != null && dataRs.Data) { result = dataRs.Data; } else { LogSystem.Info(String.Format("Khong set duoc CredentialData. TokeCode = {0}, DataKey = {1}, Data = {2}", tokenCode, dataKey, data)); if (dataRs.Param != null && dataRs.Param.Messages != null && dataRs.Param.Messages.Count > 0) { param.Messages.AddRange(dataRs.Param.Messages); } if (dataRs.Param != null && dataRs.Param.BugCodes != null && dataRs.Param.BugCodes.Count > 0) { param.BugCodes.AddRange(dataRs.Param.BugCodes); } } } else { throw new Exception(string.Format("Loi khi goi API: {0}{1}. StatusCode: {2}", Config.BASE_URI, AAS.URI.AasToken.SET_CREDENTIAL_DATA, responseMessage.StatusCode.GetHashCode())); } } } catch (Exception ex) { LogSystem.Error(ex); result = false; } return(result); }
public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime) { GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo; if (null == senderObj) { return(false); } GameObject obj = senderObj.GfxObj; if (null == obj) { return(false); } GameObject targetObj = senderObj.TargetGfxObj; if (null != senderObj.TrackEffectObj) { obj = senderObj.TrackEffectObj; targetObj = senderObj.GfxObj; } bool isTower = !EntityController.Instance.IsMovableEntity(obj); if (isTower) { return(false); } if (!m_TargetChecked) { m_TargetChecked = true; m_RealDuration = m_Duration; m_RealVelocity = m_Velocity; if (m_RealDuration <= 0) { m_RealDuration += instance.CurSectionDuration; } if (m_RealDuration <= 0) { LogSystem.Warn("jump duration is 0, skill id:{0} dsl skill id:{1}", senderObj.SkillId, instance.DslSkillId); return(false); } if (null != targetObj || m_IsForRoundMove) { Vector3 srcPos = obj.transform.position; Vector3 targetPos = Vector3.zero; if (null != targetObj) { targetPos = targetObj.transform.position; } if (m_IsForRoundMove) { TriggerUtil.GetSkillStartPosition(srcPos, senderObj.ConfigData, instance, senderObj.ActorId, senderObj.TargetActorId, ref targetPos); } if (targetPos.sqrMagnitude > Geometry.c_FloatPrecision) { float degree = Geometry.GetYRadian(new ScriptRuntime.Vector2(srcPos.x, srcPos.z), new ScriptRuntime.Vector2(targetPos.x, targetPos.z)); ScriptRuntime.Vector2 newPos = new ScriptRuntime.Vector2(targetPos.x, targetPos.z) + Geometry.GetRotate(new ScriptRuntime.Vector2(m_Offset.x, m_Offset.z), degree); targetPos = new Vector3(newPos.X, targetPos.y + m_Offset.y, newPos.Y); m_TargetPos = targetPos; if (m_StopAtTarget == (int)StopAtTargetType.AdjustVelocity) { m_RealVelocity = (long)(1000.0f * (targetPos - srcPos).magnitude / m_RealDuration); } else if (m_StopAtTarget == (int)StopAtTargetType.AdjustTime) { m_RealDuration = (long)(1000.0f * (targetPos - srcPos).magnitude / m_RealVelocity); CalcYVelocityAndG(); } m_Forward = targetPos - srcPos; m_Forward.y = 0; m_Forward.Normalize(); } else { m_Forward = obj.transform.forward; } } else { m_Forward = obj.transform.forward; } m_InitY = obj.transform.position.y; } if (curSectionTime < StartTime) { return(true); } else if (curSectionTime <= StartTime + m_RealDuration) { float t = (float)(int)(curSectionTime - StartTime) / 1000.0f; float disty = m_YVelocity * t - m_G * t * t / 2; float dist = TriggerUtil.ConvertToSecond(delta) * m_RealVelocity; Vector3 targetPos = obj.transform.position + m_Forward * dist; targetPos.y = m_InitY + disty; TriggerUtil.MoveObjTo(obj, targetPos); return(true); } else { Vector3 srcPos = obj.transform.position; if (m_IsForRoundMove && m_TargetPos.sqrMagnitude > Geometry.c_FloatPrecision) { srcPos = m_TargetPos; } obj.transform.position = new Vector3(srcPos.x, m_InitY, srcPos.z); return(false); } }
public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime) { GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo; if (null == senderObj) { return(false); } Scene scene = senderObj.Scene; EntityInfo obj = senderObj.GfxObj; if (null != obj) { if (curSectionTime >= StartTime) { int senderId; int targetId; scene.EntityController.CalcSenderAndTarget(senderObj, out senderId, out targetId); string effectPath = SkillParamUtility.RefixResourceVariable(m_EffectPath, instance, senderObj.ConfigData.resources); string emitBone = SkillParamUtility.RefixStringVariable(m_EmitBone, instance); float emitSpeed = m_EmitSpeed; if (!string.IsNullOrEmpty(effectPath)) { EntityInfo target = scene.EntityController.GetGameObject(targetId); if (null != target) { int emitImpact = m_EmitImpact; if (!m_IsExternalImpact) { emitImpact = SkillInstance.GenInnerEmitSkillId(m_EmitImpact <= 0 ? 1 : m_EmitImpact); } int impactId = TriggerUtil.GetSkillImpactId(instance.Variables, senderObj.ConfigData); Dictionary <string, object> args; TriggerUtil.CalcImpactConfig(emitImpact, impactId, instance, senderObj.ConfigData, out args); Dictionary <string, object> addArgs = new Dictionary <string, object>() { { "emitEffect", effectPath }, { "emitSpeed", emitSpeed }, { "emitDir", m_Dir }, { "emitScale", m_Scale } }; foreach (var pair in addArgs) { if (args.ContainsKey(pair.Key)) { args[pair.Key] = pair.Value; } else { args.Add(pair.Key, pair.Value); } } scene.EntityController.TrackImpact(senderObj.ConfigData, senderObj.Seq, senderObj.ActorId, senderId, targetId, emitBone, m_EmitImpact, m_Pos, args); } } else { LogSystem.Warn("[skill:{0} dsl skill id:{1}] emit effect is empty.", senderObj.SkillId, instance.DslSkillId); } return(false); } else { return(true); } } else { return(false); } }