void On_JoystickMove(MovingJoystick move) { float angle = move.Axis2Angle(true); qua = Quaternion.Euler(new Vector3(0, angle, 0)); wrap = QuaternionWrap.QuaternionToWrap(qua); string plainText = JSON.Instance.ToJSON(wrap); NpcAnimInfo info = new NpcAnimInfo() { ClientID = DeviceInfo.GUID, nextState = NpcAnimState.ManualInput, ui = new WarUIInfo() { ClientID = DeviceInfo.GUID, uniqueId = warCliMgr.clientTeam.activeNpc.UniqueID, camp = WarCamp2Camp.toWarCamp(warCliMgr.clientTeam.activeNpc.Camp), }, data = plainText, }; plainText = JSON.Instance.ToJSON(info); proxyServer.Move(plainText); if (warCliMgr.clientTeam.isAuto) { warCliMgr.clientTeam.SwitchAutoOrManual(false); } }
public virtual void On_ManualInput(WarMsgParam param) { if (canMove) { animMsg.nextAnim = WarMsg_Type.Running.ToString(); animMsg.uniqueId = cachedNpc.UniqueID; if (serMgr != null) { serMgr.realServer.proxyCli.NPCAnim(animMsg); } STATE = NpcAnimState.Run; SetHandler = RunHandle; string msg = param.param as string; if (msg != null) { NpcAnimInfo info = JSON.Instance.ToObject <NpcAnimInfo>(msg); QuaternionWrap wrap = JSON.Instance.ToObject <QuaternionWrap>(info.data); if (wrap != null) { Quaternion qua = QuaternionWrap.WrapToQuaternion(wrap); cachedTran.rotation = qua; } } } }
public void CastSkill(string CastInfo) { NpcAnimInfo info = JSON.Instance.ToObject <NpcAnimInfo>(CastInfo); ServerLifeNpc npc = monitor.CharactorPool.findActionNpc(info.ui); AsyncTask.QueueOnMainThread( () => { if (npc != null) { npc.SwitchAutoBattle(false); npc.CastSkill(info.index); } }); CastSkillInfo cInfo = new CastSkillInfo() { ClientID = DeviceInfo.GUID, index = info.index, cdTime = npc.runSkMd.getRuntimeSkill(info.index).skillCfg.BaseCD, }; processedMsg = new NetMQMessage(); processedMsg.Append(WarMsgConsts.CastSkRep); processedMsg.Append(JSON.Instance.ToJSON(cInfo)); }
IEnumerator CheckToSkill(WarMsgParam param) { val = 0f; while (cachedNpc.DisFromNextPos > 0.6f) { yield return(null); val -= 0.2f; if (val >= 0f && val <= 1f) { animator.SetLayerWeight(1, val); } } OnSwitchRun(false); OnSwitchAnimatorLayerWeight(1, 0); STATE = NpcAnimState.CastSkill; SetHandler = SkillHandle; string m_str = param.param as string; NpcAnimInfo info = JSON.Instance.ToObject <NpcAnimInfo>(m_str); if (info != null) { AnimationMsg msg = JSON.Instance.ToObject <AnimationMsg>(info.data); curMsg = msg; int index = msg.index; if (!string.IsNullOrEmpty(msg.animationName) && msg.animationName != "[]") { animator.CrossFade(msg.animationName, 0.1f); } animationTimer = msg.animationTimer - 0.02f; animationEventTimer = msg.animationEventTimer; canTriggerEvent = true; if (index == 0) { animator.SetBool("isSkill_1", true); CreateEffect(NpcAnimEffect.Skill_1_Start); } else if (index == 1) { animator.SetBool("isSkill_2", true); CreateEffect(NpcAnimEffect.Skill_2_Start); } else if (index == 2) { animator.SetBool("isSkill_3", true); CreateEffect(NpcAnimEffect.Skill_3_Start); } } }
void On_JoystickMoveEnd(MovingJoystick move) { string plainText = ""; NpcAnimInfo info = new NpcAnimInfo() { ClientID = DeviceInfo.GUID, nextState = NpcAnimState.Stand, ui = new WarUIInfo() { ClientID = DeviceInfo.GUID, uniqueId = warCliMgr.clientTeam.activeNpc.UniqueID, camp = WarCamp2Camp.toWarCamp(warCliMgr.clientTeam.activeNpc.Camp), }, data = plainText, }; plainText = JSON.Instance.ToJSON(info); proxyServer.MoveStop(plainText); }
public void MoveStop(string MoveStopInfo) { AsyncTask.QueueOnMainThread( () => { WarServerManager mgr = WarServerManager.Instance; if (mgr != null) { NpcAnimInfo info = JSON.Instance.ToObject <NpcAnimInfo>(MoveStopInfo); ServerLifeNpc npc = monitor.CharactorPool.findActionNpc(info.ui); WarSrcAnimParam param = new WarSrcAnimParam(); param.cmdType = WarMsg_Type.Stand; param.param = MoveStopInfo; mgr.npcMgr.SendMessageAsync(npc.UniqueID, npc.UniqueID, param); } } ); processedMsg = new NetMQMessage(); processedMsg.Append(WarMsgConsts.MoveStopRep); }
public void Attack(string AttackInfo) { AsyncTask.QueueOnMainThread( () => { WarServerManager mgr = WarServerManager.Instance; if (mgr != null) { NpcAnimInfo info = JSON.Instance.ToObject <NpcAnimInfo>(AttackInfo); ServerLifeNpc npc = monitor.CharactorPool.findActionNpc(info.ui); if (npc != null) { npc.Attack(); } } } ); processedMsg = new NetMQMessage(); processedMsg.Append(WarMsgConsts.AttackRep); }
public void On_Attack_Clicked() { string plainText = ""; NpcAnimInfo info = new NpcAnimInfo() { ClientID = DeviceInfo.GUID, nextState = NpcAnimState.Attack, ui = new WarUIInfo() { ClientID = DeviceInfo.GUID, uniqueId = warCliMgr.clientTeam.activeNpc.UniqueID, camp = WarCamp2Camp.toWarCamp(warCliMgr.clientTeam.activeNpc.Camp), }, data = "", }; plainText = JSON.Instance.ToJSON(info); proxyServer.Attack(plainText); if (warCliMgr.clientTeam.isAuto) { warCliMgr.clientTeam.SwitchAutoOrManual(false); } }
IEnumerator CheckForAttack(WarMsgParam param) { val = 0f; if (cachedNpc.movable) { while (cachedNpc.DisFromNextPos > 0.6f) { yield return(null); val -= 0.2f; if (val >= 0f && val <= 1f) { animator.SetLayerWeight(1, val); } } } else { yield return(null); } OnSwitchRun(false); OnSwitchAnimatorLayerWeight(1, 0); STATE = NpcAnimState.Attack; SetHandler = AttackHandle; isAnimating = true; string m_str = param.param as string; NpcAnimInfo info = JSON.Instance.ToObject <NpcAnimInfo>(m_str); if (info != null) { AnimationMsg msg = JSON.Instance.ToObject <AnimationMsg>(info.data); if (msg != null) { curMsg = msg; int index = msg.index; if (index < AttackCount) { if (!string.IsNullOrEmpty(msg.animationName) && msg.animationName != "[]") { animator.CrossFade(msg.animationName, 0.1f); } animationTimer = msg.animationTimer - 0.02f; animationEventTimer = msg.animationEventTimer; canTriggerEvent = true; if (index == 0) { CreateEffect(NpcAnimEffect.Attack_1_Start); } else if (index == 1) { CreateEffect(NpcAnimEffect.Attack_2_Start); } else if (index == 2) { CreateEffect(NpcAnimEffect.Attack_3_Start); } } } } }
public virtual void On_CastTrigger(WarMsgParam param) { if (STATE != NpcAnimState.Killed) { WarSrcAnimParam srcParam = param as WarSrcAnimParam; int index = param.arg1; List <ISkImp> ops = null; ISkImp sk = null; if (!sk_Imps.TryGetValue(index, out ops)) { ops = new List <ISkImp>(); sk_Imps.Add(index, ops); } sk = ops.Find(imp => imp.SkOp() == srcParam.OP); if (sk == null) { sk = SkImpFactory.getSkImp(srcParam.OP); ops.Add(sk); } sk.Reset(); sk.InitSk(cachedNpc, param); sk.CastSk(); } if (STATE != NpcAnimState.Killed && !isAttack && !isCastSkill) { WarSrcAnimParam srcParam = param as WarSrcAnimParam; skParam = srcParam; if (srcParam != null) { STATE = NpcAnimState.CastTrigger; Effect3DModelConfigData ecd = Core.Data.getIModelConfig <Effect3DModel>().get(srcParam.ShootAction); if (ecd != null) { isCastSkill = true; canNextAnim = false; canTriggerEvent = true; animationTimer = srcParam.ShootTime; animationEventTimer = 0.2f; SetHandler = Trigger_Handle; AnimationMsg msg = new AnimationMsg(); msg.animationTimer = animationTimer; msg.animationEventTimer = animationEventTimer; msg.ecd = ecd; msg.animationName = ecd.Anim; msg.targetId = 0; string a_data = JSON.Instance.ToJSON(msg); NpcAnimInfo info = new NpcAnimInfo() { ClientID = DeviceInfo.GUID, nextState = NpcAnimState.CastBuff, data = a_data, }; animMsg.nextAnim = WarMsg_Type.UseTrigger.ToString(); animMsg.uniqueId = cachedNpc.UniqueID; animMsg.data = JSON.Instance.ToJSON(info); if (serMgr != null) { serMgr.realServer.proxyCli.NPCAnim(animMsg); } } else { On_Stand(null); } } } }
public virtual void On_CastSkill(WarMsgParam param) { if (STATE != NpcAnimState.Killed && !isCastSkill) { // WarSrcAnimParam srcParam = param as WarSrcAnimParam; // int index = param.arg1; // List<ISkImp> ops = null; // ISkImp sk = null; // if (!sk_Imps.TryGetValue(index, out ops)) // { // ops = new List<ISkImp>(); // sk_Imps.Add(index, ops); // } // sk = ops.Find(imp => imp.SkOp() == srcParam.OP); // if (sk == null) // { // sk = SkImpFactory.getSkImp(srcParam.OP); // ops.Add(sk); // } // sk.Reset(); // sk.InitSk(cachedNpc, param); // sk.CastSk(); } if (STATE != NpcAnimState.Killed && !isAttack && !isCastSkill) { WarSrcAnimParam srcParam = param as WarSrcAnimParam; Debug.Log(JSON.Instance.ToJSON(param)); skParam = srcParam; if (srcParam != null) { STATE = NpcAnimState.CastSkill; Effect3DModelConfigData ecd = Core.Data.getIModelConfig <Effect3DModel>().get(srcParam.ShootAction); if (ecd != null) { isCastSkill = true; canNextAnim = false; canTriggerEvent = true; animationTimer = srcParam.ShootTime; animationEventTimer = srcParam.ShootEventTime; SetHandler = Skill_Handle; AnimationMsg msg = new AnimationMsg(); msg.animationTimer = animationTimer; msg.animationEventTimer = animationEventTimer; msg.index = param.arg1; msg.ecd = ecd; msg.animationName = ecd.Anim; msg.targetId = 0; if (srcParam.described != null && srcParam.OP == EffectOp.CtorNPC) { EndResult result = srcParam.described.srcEnd; CreatNpcDepandency cnd = (CreatNpcDepandency)result.obj; msg.objCrtV = cnd.TargetVector3; } WarTarAnimParam[] targets = skParam.InjureTar; BNPC npc = null; if (targets != null && targets.Length > 0) { msg.targetId = targets[0].described.target; npc = serMgr.npcMgr.GetNPCByUniqueID(targets[0].described.target); if (npc != null) { lastTarget = "Target:" + targets[0].described.target; Vector3 pos = npc.transform.position; pos.y = cachedTran.position.y; cachedTran.LookAt(pos); } } string a_data = JSON.Instance.ToJSON(msg); NpcAnimInfo info = new NpcAnimInfo() { ClientID = DeviceInfo.GUID, nextState = NpcAnimState.CastSkill, data = a_data, }; animMsg.nextAnim = WarMsg_Type.UseSkill.ToString(); animMsg.uniqueId = cachedNpc.UniqueID; animMsg.data = JSON.Instance.ToJSON(info); if (serMgr != null) { serMgr.realServer.proxyCli.NPCAnim(animMsg); } } else { On_Stand(null); } } } }
public virtual void On_Attack(WarMsgParam param) { if (STATE != NpcAnimState.Killed && !isAttack && !isCastSkill) { WarSrcAnimParam srcParam = param as WarSrcAnimParam; atkParam = srcParam; // Debug.Log(JSON.Instance.ToJSON(atkParam), gameObject); if (srcParam != null) { int index = cachedNpc.AttIndex; STATE = NpcAnimState.Attack; Effect3DModelConfigData ecd = Core.Data.getIModelConfig <Effect3DModel>().get(srcParam.ShootAction); if (ecd != null) { isAttack = true; canNextAnim = false; canTriggerEvent = true; animationTimer = srcParam.ShootTime; animationEventTimer = srcParam.ShootEventTime; attackWaitForNext = 0.3f; attackIndex = index; SetHandler = AttackHandle; WarTarAnimParam[] targets = atkParam.InjureTar; BNPC npc = null; if (targets != null && targets.Length > 0) { npc = serMgr.npcMgr.GetNPCByUniqueID(targets[0].described.target); if (npc != null) { lastTarget = "Target:" + targets[0].described.target; Vector3 pos = npc.transform.position; pos.y = cachedTran.position.y; cachedTran.LookAt(pos); } } AnimationMsg msg = new AnimationMsg(); msg.animationTimer = animationTimer; msg.animationEventTimer = animationEventTimer; msg.index = index; msg.ecd = ecd; msg.animationName = ecd.Anim; msg.targetId = (npc == null) ? 0 : npc.UniqueID; msg.arg1 = srcParam.described.targetEnd.param8; msg.arg2 = srcParam.described.targetEnd.param9; string a_data = JSON.Instance.ToJSON(msg); NpcAnimInfo info = new NpcAnimInfo() { ClientID = DeviceInfo.GUID, nextState = NpcAnimState.Attack, data = a_data, }; animMsg.nextAnim = WarMsg_Type.Attack.ToString(); animMsg.uniqueId = cachedNpc.UniqueID; animMsg.data = JSON.Instance.ToJSON(info); if (serMgr != null) { serMgr.realServer.proxyCli.NPCAnim(animMsg); } } else { On_Stand(null); } } } }