void OnEvent(int eventID, object param) { switch ((Client.GameEventID)eventID) { case GameEventID.BUFF_ADDTOTARGETBUFF: OnEeventAddBuff(eventID, (Client.stAddBuff)param); break; case GameEventID.BUFF_DELETETARGETBUFF: OnEventRemoveBuff(eventID, (Client.stRemoveBuff)param); break; case GameEventID.BUFF_UPDATEARGETBUFF: break; case GameEventID.ENTITYSYSTEM_TARGETCHANGE: { stTargetChange tc = (stTargetChange)param; IEntity en = tc.target; if (en != null) { IBuffPart bp = en.GetPart(EntityPart.Buff) as IBuffPart; if (bp != null) { List <stAddBuff> list = null; bp.GetBuffList(out list); if (list != null) { targetBuffList.Clear(); for (int i = 0; i < list.Count; i++) { targetBuffList.Insert(0, list[i]); } } } } } break; case GameEventID.RECONNECT_SUCESS: { stReconnectSucess reconnectSucess = (stReconnectSucess)param; if (reconnectSucess.isLogin) { ClearAllBuff(); } } break; } }
/// <summary> /// 设置重连标志 /// </summary> /// <param name="bRec">false 是重连成功,ture表示开始重连 在重连状态中</param> /// islogin 表示是否重新走登录流程 /// <param name="?"></param> public void SetReconnect(bool bRec, bool isLogin = false) { IsReconnecting = bRec; if (!bRec) { if (isLogin) { Log.Error("重连成功 清空除ui和登录数据 ResetByReconnect"); DataManager.Instance.ResetByReconnect(); } else { Log.Error("重连成功 不清除数据"); } stReconnectSucess rs = new stReconnectSucess(); rs.isLogin = isLogin; EventEngine.Instance().DispatchEvent((int)Client.GameEventID.RECONNECT_SUCESS, rs); } }
void DoGameEvent(int eventID, object param) { if (eventID == (int)GameEventID.ENTITYSYSTEM_RELIVE) { stEntityRelive stRelive = (stEntityRelive)param; if (ClientGlobal.Instance().IsMainPlayer(stRelive.uid)) { PanelID panelId = UIFrameManager.Instance.CurrShowPanelID; DataManager.Manager <UIPanelManager>().HidePanel(PanelID.ReLivePanel); } } else if (eventID == (int)GameEventID.SKILL_RELIVE) { stSkillRelive skillRe = (stSkillRelive)param; if (!ClientGlobal.Instance().IsMainPlayer(skillRe.id)) { return; } //武斗场不使用技能复活 if (DataManager.Manager <ArenaManager>().EnterArena) { return; } DataManager.Manager <UIPanelManager>().HidePanel(PanelID.ReLivePanel); //如果人是活的 if (false == Client.ClientGlobal.Instance().MainPlayer.IsDead()) { return; } uint time = GameTableManager.Instance.GetGlobalConfig <uint>("ReliveCountdown"); TipsManager.Instance.ShowTipWindow(0, time, TipWindowType.CancelOk, "是否复活", () => { GameCmd.stOKReliveUserCmd_C cmd = new GameCmd.stOKReliveUserCmd_C(); cmd.byType = (uint)GameCmd.ReliveType.ReliveType_Skill; cmd.dwUserTempID = ClientGlobal.Instance().MainPlayer.GetID(); cmd.dwNpcID = 0; NetService.Instance.Send(cmd); }, () => { GameCmd.stOKReliveUserCmd_C cmd = new GameCmd.stOKReliveUserCmd_C(); cmd.byType = (uint)GameCmd.ReliveType.ReliveType_Home; cmd.dwUserTempID = ClientGlobal.Instance().MainPlayer.GetID(); cmd.dwNpcID = 0; NetService.Instance.Send(cmd); }); } else if (eventID == (int)GameEventID.RECONNECT_SUCESS) { stReconnectSucess reconnectSucess = (stReconnectSucess)param; if (reconnectSucess.isLogin) { MainPlayerRelive(); } } else if (eventID == (int)GameEventID.ENTITYSYSTEM_ENTITYDEAD) { stEntityDead ed = (stEntityDead)param; if (ClientGlobal.Instance().IsMainPlayer(ed.uid)) { this.m_deadTime = Time.realtimeSinceStartup; } } }
private void OnEvent(int nEventID, object param) { // 地表没有创建成功的时候,就已经收到了角色和NPC的创建 这里重新设置位置和地表做碰撞 if (nEventID == (int)GameEventID.SYSTEM_LOADSCENECOMPELETE) { //List<IPlayer> lstPlayer; FindAllEntity <IPlayer>(ref lstPlayer); for (int i = 0; i < lstPlayer.Count; ++i) { Vector3 pos = lstPlayer[i].GetPos(); lstPlayer[i].SendMessage(EntityMessage.EntityCommand_SetPos, (object)pos); } lstPlayer.Clear(); //List<INPC> lstNPC; FindAllEntity <INPC>(ref lstNPC); for (int i = 0; i < lstNPC.Count; ++i) { Vector3 pos = lstNPC[i].GetPos(); lstNPC[i].SendMessage(EntityMessage.EntityCommand_SetPos, (object)pos); } lstNPC.Clear(); //List<IBox> lstBox; FindAllEntity <IBox>(ref lstBox); for (int i = 0; i < lstBox.Count; ++i) { Vector3 pos = lstBox[i].GetPos(); pos.y += 0.2f; lstBox[i].SendMessage(EntityMessage.EntityCommand_SetPos, (object)pos); } lstBox.Clear(); //List<IRobot> lstRobot; FindAllEntity <IRobot>(ref lstRobot); for (int i = 0; i < lstRobot.Count; ++i) { Vector3 pos = lstRobot[i].GetPos(); lstRobot[i].SendMessage(EntityMessage.EntityCommand_SetPos, (object)pos); } lstRobot.Clear(); // 请求同步移动时间 ReqMoveServerTime(); } else if (nEventID == (int)GameEventID.RECONNECT_SUCESS) // 重新连接成功 { stReconnectSucess st = (stReconnectSucess)param; if (st.isLogin) { Clear(false); // 不清理除主角 // 请求同步移动时间 ReqMoveServerTime(); } else {//强制同步 GameCmd.stUserMoveMoveUserCmd_C cmd = new GameCmd.stUserMoveMoveUserCmd_C(); cmd.client_time = 0; List <GameCmd.Pos> list = new List <GameCmd.Pos>(); GameCmd.Pos pp = new GameCmd.Pos(); pp.x = 0; pp.y = 0; list.Add(pp); cmd.poslist.AddRange(list); m_ClientGlobal.netService.Send(cmd); } } else if (nEventID == (int)GameEventID.NETWORK_CONNECTE_CLOSE)// 网络断开 { if (m_ClientGlobal.MainPlayer != null) { m_ClientGlobal.MainPlayer.SendMessage(EntityMessage.EntityCommand_RemoveLinkAllEffect); } } else if (nEventID == (int)GameEventID.ENTITYSYSTEM_ENTITYDEAD) // 实体死亡 { stEntityDead ed = (stEntityDead)param; if (m_ClientGlobal.IsMainPlayer(ed.uid)) { Engine.IRenderSystem rs = Engine.RareEngine.Instance().GetRenderSystem(); if (rs != null) { rs.EnableGray(true); } } IEntity en = FindEntity(ed.uid); if (en != null) { AddEffectOnEntity(en, false); } } else if (nEventID == (int)GameEventID.ENTITYSYSTEM_RELIVE) { stEntityRelive ed = (stEntityRelive)param; if (m_ClientGlobal.IsMainPlayer(ed.uid)) { Engine.IRenderSystem rs = Engine.RareEngine.Instance().GetRenderSystem(); if (rs != null) { rs.EnableGray(false); } } IEntity en = FindEntity(ed.uid); if (en != null) { AddEffectOnEntity(en, true); } } else if (nEventID == (int)GameEventID.PLAYER_LOGIN_SUCCESS) { Engine.IRenderSystem rs = Engine.RareEngine.Instance().GetRenderSystem(); if (rs != null) { rs.EnableGray(false); } // 请求同步移动时间 ReqMoveServerTime(); } else if (nEventID == (int)GameEventID.ENTITYSYSTEM_LEAVEMAP) // 离开地图 { // 清理地图上所有对象 Clear(false); // 切地图时让主角停止移动 IPlayer mainPlayer = EntitySystem.m_ClientGlobal.MainPlayer; if (mainPlayer != null) { bool ismoving = (bool)mainPlayer.SendMessage(Client.EntityMessage.EntityCommand_IsMove, null); if (ismoving) { mainPlayer.SendMessage(Client.EntityMessage.EntityCommand_StopMove, mainPlayer.GetPos()); } } } else if (nEventID == (int)GameEventID.ENTITYSYSTEM_CHANGEAREA) // 区域变化 动作处理 { stEntityChangeArea changeArea = (stEntityChangeArea)param; IEntity en = FindEntity(changeArea.uid); if (en != null && en.GetEntityType() == EntityType.EntityType_Player) { string strCurAni = (string)en.SendMessage(EntityMessage.EntityCommand_GetCurAni, null); bool bChangeArea = false; if (changeArea.eType == MapAreaType.Safe || changeArea.eType == MapAreaType.Fish) { if (strCurAni == EntityAction.Stand_Combat) { strCurAni = EntityAction.Stand; bChangeArea = true; } if (strCurAni == EntityAction.Run_Combat) { strCurAni = EntityAction.Run; bChangeArea = true; } } else { if (strCurAni == EntityAction.Stand) { strCurAni = EntityAction.Stand_Combat; bChangeArea = true; } if (strCurAni == EntityAction.Run) { strCurAni = EntityAction.Run_Combat; bChangeArea = true; } } if (bChangeArea) { PlayAni anim_param = new PlayAni(); anim_param.strAcionName = strCurAni; anim_param.fSpeed = 1; anim_param.nStartFrame = 0; anim_param.nLoop = -1; anim_param.fBlendTime = 0.1f; en.SendMessage(EntityMessage.EntityCommand_PlayAni, anim_param); } } } else if (nEventID == (int)GameEventID.ENTITYSYSTEM_CREATEENTITY) { stCreateEntity create = (stCreateEntity)param; IEntity en = FindEntity(create.uid); if (en != null) { EntityManager.Instance().OnCreateEntity(en); } } }