private bool EqualsMapID(uint nMapID) { Client.IMapSystem ms = Client.ClientGlobal.Instance().GetMapSystem(); if (ms == null) { return(false); } return(ms.GetMapID() == nMapID); }
public void ShowMain(bool bFirst = false) { ClearCacheStack(); if (!IsShowPanel(PanelID.RoleStateBarPanel)) { ShowPanel(PanelID.RoleStateBarPanel); } if (DataManager.Manager <ArenaManager>().EnterArena == false) { ShowPanel(PanelID.MissionAndTeamPanel); } ShowPanel(PanelID.MainPanel); Client.IMapSystem ms = Client.ClientGlobal.Instance().GetMapSystem(); if (ms != null) { if (ms.GetMapID() != GameTableManager.Instance.GetGlobalConfig <int>("HomeSceneID")) { //ShowPanel( PanelID.SkillPanel ); } } //阵营战 打开战斗界面 if (DataManager.Manager <CampCombatManager>().isEnterScene) { DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.CampFightingPanel); } //城战 打开城战战斗界面 if (DataManager.Manager <CityWarManager>().EnterCityWar) { DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.CityWarFightingPanel); } ShowPanel(PanelID.GuideUnconstrainPanel); //if (DataManager.Manager<ComBatCopyDataManager>().EnterCopyID ==0)//非副本才显示 if (!DataManager.Manager <ComBatCopyDataManager>().IsEnterCopy)//非副本才显示 { ShowPanel(PanelID.MessagePushPanel); } ShowPanel(PanelID.EffectDiplayPanel); if (bFirst) { Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.SYSTEM_LOADUICOMPELETE); } }
void OnBtnTopClick(GameObject go) { // m_goSelect.transform.parent = m_trans_pkmodel.transform; m_transBtnBg.gameObject.SetActive(true); m_transBtnBg.transform.DestroyChildren(); Client.IMapSystem ms = Client.ClientGlobal.Instance().GetMapSystem(); if (ms == null) { return; } table.MapDataBase mapdata = GameTableManager.Instance.GetTableItem <table.MapDataBase>(ms.GetMapID()); if (mapdata == null) { return; } GameObject curBtn = null; if (ClientGlobal.Instance().MainPlayer != null) { int nmodel = ClientGlobal.Instance().MainPlayer.GetProp((int)PlayerProp.PkMode); int index = 0; for (int i = (int)PLAYERPKMODEL.PKMODE_M_NONE + 1; i <= (int)PLAYERPKMODEL.PKMODE_M_JUSTICE; i++, index++) { PLAYERPKMODEL model = (PLAYERPKMODEL)i; GameObject btn = NGUITools.AddChild(m_transBtnBg.gameObject, m_btnPrefab); btn.transform.localPosition = new UnityEngine.Vector3(174, -28 - index * 52, 0); btn.gameObject.SetActive(true); btn.GetComponentInChildren <UILabel>().text = GetDesByPkModel(model); btn.name = i.ToString(); Transform flagTrans = btn.transform.Find("flag"); if (flagTrans != null) { UISprite sp = flagTrans.GetComponent <UISprite>(); if (sp != null) { sp.spriteName = GetFlagByPkModel(model); } } SetSelect(btn, false); SetMask(btn, true); if ((int)model == nmodel) { curBtn = btn; } if (mapdata.supportModel == "0") { UIEventListener.Get(btn).onClick = OnClickBtn; SetMask(btn, false); } else { string[] param = mapdata.supportModel.Split('_'); for (int m = 0; m < param.Length; m++) { int value = int.Parse(param[m]); if (i == value) { UIEventListener.Get(btn).onClick = OnClickBtn; SetMask(btn, false); } else { UIEventListener.Get(btn).onClick = onClickUnenble; } } } } if (curBtn != null) { SetSelect(curBtn, true); SetMask(curBtn, false); } } }
private object StopMove(object param) { if (m_Owner == null) { return(null); } Client.IMapSystem mapSys = EntitySystem.m_ClientGlobal.GetMapSystem(); if (mapSys == null) { return(null); } if (param != null) { Vector3 pos = (Vector3)param; if (m_bMoving) { m_param.m_speed = m_Owner.GetProp((int)WorldObjProp.MoveSpeed) * EntityConst.MOVE_SPEED_RATE; m_vSpeed = (m_param.m_speed * m_fSpeedFact * m_fSpeedTerrainFact) * m_dir; long nCurTime = Engine.Utility.TimeHelper.GetTickCount(); Vector3 ds = m_vSpeed * ((nCurTime - m_LastTime) * 0.001f); pos = m_vLastPos + ds; m_fDistance += ds.magnitude; m_LastTime = nCurTime; if (EntitySystem.m_ClientGlobal.IsMainPlayer(m_Owner)) { m_uServerTime = EntityConfig.serverTime; } } // 停止时如果是阻挡点客户端做一下修正 目前的同步方案可能会和服务器之间不同步 测试再看效果 if (!mapSys.CanWalk(pos)) { pos = m_lastWalkPos; } m_Owner.SendMessage(EntityMessage.EntityCommand_SetPos, pos); m_LastTime = Engine.Utility.TimeHelper.GetTickCount(); //Engine.Utility.Log.Error("Move stop: ({0},{1}) {2} {3} speed:{4}", pos.x, pos.z, m_LastTime, m_fDistance, m_fDistance / (m_LastTime - m_BeginTime)); // 切换到Normal状态 Creature owner = m_Owner as Creature; if (owner != null) { if (!m_bIgnoreMoveAction && !owner.IsDead()) { if (m_param != null) { owner.ChangeState(CreatureState.Normal, (object)(m_param.m_ignoreStand?1:0)); } else { owner.ChangeState(CreatureState.Normal); } } } else { m_Owner.PlayAction(EntityAction.Stand, 0, m_fSpeedFact); } } m_LastTime = 0; // 强制同步 SyncPos(true); // 停止同步 Client.stEntityStopMove stopEntity = new Client.stEntityStopMove(); stopEntity.uid = m_Owner.GetUID(); stopEntity.bExternal = m_bExternalStop; m_vSpeed = Vector3.zero; m_nPathIndex = -1; if (m_param != null) { m_param.m_speed = 0; } m_bMoving = false; m_hasTarget = false; //Engine.Utility.TimerAxis.Instance().KillTimer(0, this); if (m_Owner.GetEntityCallback() != null && m_param != null) { m_Owner.GetEntityCallback().OnMoveEnd(m_Owner, m_param.param); } Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_ENTITYSTOPMOVE, stopEntity); return(null); }
//public virtual void OnTimer(uint uTimerID) //{ // MoveUpdate(); //} public override void Update() { if (m_Owner == null) { return; } if (m_curScene == null) { return; } if (!m_bMoving) { return; } // 实时取对象身上的速度值 m_param.m_speed = m_Owner.GetProp((int)WorldObjProp.MoveSpeed) * EntityConst.MOVE_SPEED_RATE; m_vSpeed = (m_param.m_speed * m_fSpeedFact * m_fSpeedTerrainFact) * m_dir; long nCurTime = Engine.Utility.TimeHelper.GetTickCount(); Vector3 ds = m_vSpeed * ((nCurTime - m_LastTime) * 0.001f); Vector3 pos = m_vLastPos + ds; m_LastTime = nCurTime; // 获取服务器时间 if (EntitySystem.m_ClientGlobal.IsMainPlayer(m_Owner)) { m_uServerTime = EntityConfig.serverTime; } if (pos.Equals(m_vLastPos)) { return; } Client.IMapSystem mapSys = EntitySystem.m_ClientGlobal.GetMapSystem(); if (mapSys == null) { return; } m_fDistance += ds.magnitude; // 检测是否到达目标点 if (ChkMove(pos) && !m_bMoveDir) // pos 已经超过目标点 { m_nPathIndex++; if (m_nPathIndex < m_param.path.Count) // 路径上的点还没有走完 { // 处理路径上点切换 SwitchTarget(m_param.path[m_nPathIndex], ref pos); // 贴地处理 CloseTerrainPos(ref pos); if (mapSys.CanWalk(pos)) { m_lastWalkPos = pos; } // 设置当前位置 m_Owner.SetPos(ref pos); // 同步玩家位置 发送实体移动事件 SyncPos(); m_vLastPos = pos; } else { Vector3 pp = m_target; // 贴地处理 CloseTerrainPos(ref pp); if (mapSys.CanWalk(pp)) { m_lastWalkPos = pp; } //pp.y = pos.y; m_bMoving = false; // 停止移动 m_bExternalStop = false; // 非外部因素 StopMove(pp); m_bExternalStop = true; } } else { // 设置新位置 //if (mapSys.CanWalk(pos)) { // 贴地处理 CloseTerrainPos(ref pos); if (mapSys.CanWalk(pos)) { m_lastWalkPos = pos; } //Engine.Utility.Log.Error("SetPos:{0},{1}", pos.x, pos.z); m_Owner.SetPos(ref pos); SyncPos(); m_vLastPos = pos; } //else //{ // // 遇到障碍就停止 // m_Owner.SetPos(ref m_vLastPos); // StopMove(m_vLastPos); //} } // 设置场景草扰动 if (m_Owner.GetEntityType() == EntityType.EntityType_Player) { mapSys.AddGrassWaveForce(pos, 0.8f, 1.2f); } }
/// <summary> /// 请求读条上马 /// </summary> public bool TryUsingRide(Action <object> callback, object param) { Client.IMapSystem ms = Client.ClientGlobal.Instance().GetMapSystem(); if (ms == null) { return(false); } table.MapDataBase mapdata = GameTableManager.Instance.GetTableItem <table.MapDataBase>(ms.GetMapID()); if (mapdata == null) { return(false); } if (mapdata.canUsingRide != 1) { TipsManager.Instance.ShowTips("该地图不能上马"); if (callback != null) { callback(param); } return(false); } Client.IPlayer mainPlayer = Client.ClientGlobal.Instance().MainPlayer; if (mainPlayer != null) { Client.ISkillPart skillpart = mainPlayer.GetPart(Client.EntityPart.Skill) as Client.ISkillPart; if (skillpart != null) { if (skillpart.GetCurSkillState() != (int)Client.SkillState.None) { TipsManager.Instance.ShowTips(LocalTextType.Ride_Commond_shifangjinengzhongwufashangma); if (callback != null) { callback(param); } return(false); } } bool isChangeBody = (bool)mainPlayer.SendMessage(Client.EntityMessage.EntityCommand_IsChange, null); if (isChangeBody) { if (callback != null) { callback(param); } return(false); } bool bRide = DataManager.Manager <RideManager>().IsRide; if (bRide) { if (callback != null) { callback(param); } return(false); } else if (Auto_Ride == 0) { if (callback != null) { callback(param); } return(false); } } UsingRideCallback = callback; UsingRideCallbackParam = param; if (Auto_Ride != 0) { //先发送读条 读条 结束在上马 Client.stUninterruptMagic stparam = new Client.stUninterruptMagic(); if (GetRideDataById(Auto_Ride) != null) { stparam.time = GetRideDataById(Auto_Ride).spellTime; } stparam.type = GameCmd.UninterruptActionType.UninterruptActionType_DEMON; stparam.uid = MainPlayerHelper.GetPlayerUID(); Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.SKILLGUIDE_PROGRESSSTART, stparam); //NetService.Instance.Send(new stUsingRideUserCmd_C()); } return(true); }
private void OnDoingTask(QuestTraceInfo taskInfo) { DataManager.Manager <TaskDataManager>().DoingTaskID = taskInfo.taskId; Client.IController controller = Client.ClientGlobal.Instance().GetControllerSystem().GetActiveCtrl(); if (controller == null) { Engine.Utility.Log.Error("IController is null"); return; } table.QuestDataBase questDB = taskInfo.QuestTable; if (questDB == null) { Engine.Utility.Log.Error("QuestTable is null"); return; } UnityEngine.Vector2 pos; uint npcid = 0; PanelID pid; int copyID; int tab = 0; uint jumpId; //背包满了 无法执行任务 if (false == taskInfo.TaskItemCanPutInKanpsack()) { TipsManager.Instance.ShowTips(LocalTextType.Task_Commond_3); return; } if (MainPlayerIsChangeBody()) { return; } else if (taskInfo.taskSubType == TaskSubType.SubmitLimit) //断档任务 { if (taskInfo.IsOpenUI(out jumpId)) { ItemManager.DoJump(jumpId); } else { string des = string.Format("将等级提升到{0}级继续主线任务", taskInfo.finishLevel); TipsManager.Instance.ShowTips(des); } return; } else if (taskInfo.IsDynamicCommitItem) //动态道具递交(蚩尤乱世除外) { taskInfo.DoJump(); return; } else if (DataManager.Manager <ComBatCopyDataManager>().IsEnterCopy == false && taskInfo.IsOpenUI(out jumpId)) { ItemManager.DoJump(jumpId); return; } else if (taskInfo.IsMoveToTargetPos(out pos)) { //if (DataManager.Manager<TaskDataManager>().IsShowSlider) if (DataManager.Manager <SliderDataManager>().IsReadingSlider) { return; } Client.IControllerSystem cs = Client.ClientGlobal.Instance().GetControllerSystem(); if (cs == null) { return; } if (!m_bAddStopMoveListener) { m_bAddStopMoveListener = true; Engine.Utility.EventEngine.Instance().AddEventListener((int)Client.GameEventID.ENTITYSYSTEM_ENTITYSTOPMOVE, OnEvent); } if (EqualsMapID(questDB.destMapID)) { cs.GetCombatRobot().Stop(); DataManager.Manager <RideManager>().TryUsingRide(delegate(object o) { //if (!m_bAddStopMoveListener) //{ // m_bAddStopMoveListener = true; // Engine.Utility.EventEngine.Instance().AddEventListener((int)Client.GameEventID.ENTITYSYSTEM_ENTITYSTOPMOVE, OnEvent); //} m_nDoingTaskID = taskInfo.taskId; controller.GotoMap(questDB.destMapID, new Vector3(pos.x, 0, -pos.y)); }, null); return; } else { DataManager.Manager <RideManager>().TryUsingRide(delegate(object o) { if (questDB.dwHelpDoing) { m_nDoingTaskID = taskInfo.taskId; //下载地图检查 if (!KHttpDown.Instance().SceneFileExists(questDB.destMapID)) { //打开下载界面 DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.DownloadPanel); return; } controller.GotoMapDirectly(questDB.destMapID, new Vector3(pos.x, 0, -pos.y), questDB.dwID); } }, null); } } else if (taskInfo.IsVisitCollectNpc(out npcid) || taskInfo.IsDeleverItem(out npcid)) { AddCollectNpcEffect(taskInfo); DataManager.Manager <RideManager>().TryUsingRide(delegate(object o) { VisitNpc(questDB.dwHelpDoing, questDB.destMapID, npcid, questDB.dwID); }, null); } else if (taskInfo.IsDirectlyVisitCopy(taskInfo.copyId) && false == EqualsMapID(questDB.destMapID)) { //直接跳副本 VisitCopy(taskInfo.copyId); } else if (taskInfo.IsKillMonster(out npcid)) { Client.ICombatRobot robot = Client.ClientGlobal.Instance().GetControllerSystem().GetCombatRobot(); if (robot == null) { Engine.Utility.Log.Error("robotis null"); return; } if (robot.Status == Client.CombatRobotStatus.RUNNING && robot.TargetId == npcid) { Engine.Utility.Log.Info("已经在挂机杀怪{0}", npcid); return; } //TODO 优化 bool getPos = false; if (EqualsMapID(questDB.destMapID)) { Client.IMapSystem ms = Client.ClientGlobal.Instance().GetMapSystem(); if (ms.GetClienNpcPos((int)npcid, out pos)) { getPos = true; Vector3 mainPos = Client.ClientGlobal.Instance().MainPlayer.GetPos(); if ((mainPos - new Vector3(pos.x, mainPos.y, -pos.y)).sqrMagnitude < 5) { Client.IControllerSystem cs = Client.ClientGlobal.Instance().GetControllerSystem(); if (cs != null) { cs.GetCombatRobot().StartWithTarget((int)npcid); Engine.Utility.Log.LogGroup("ZCX", "挂机杀怪物{0}", npcid); return; } } } } DataManager.Manager <RideManager>().TryUsingRide(delegate(object o) { if (!m_bAddStopMoveListener) { m_bAddStopMoveListener = true; Engine.Utility.EventEngine.Instance().AddEventListener((int)Client.GameEventID.ENTITYSYSTEM_ENTITYSTOPMOVE, OnEvent); } m_nDoingTaskID = taskInfo.taskId; if (getPos) { controller.MoveToTarget(new Vector3(pos.x, 0, -pos.y), null, true); } else if (EqualsMapID(questDB.destMapID)) { Client.IMapSystem ms = Client.ClientGlobal.Instance().GetMapSystem(); if (ms.GetClienNpcPos((int)npcid, out pos)) { controller.MoveToTarget(new Vector3(pos.x, 0, -pos.y), null, true); } } else { VisitNpc(questDB.dwHelpDoing, questDB.destMapID, npcid, questDB.dwID); } }, null); } }
private void OnPlayerStopMove(ref Client.stEntityStopMove stopEntity, int nEventId) { if (!Client.ClientGlobal.Instance().IsMainPlayer(stopEntity.uid)) { return; } if (m_nDoingTaskID == 0) { Engine.Utility.EventEngine.Instance().RemoveEventListener(nEventId, OnEvent); m_bAddStopMoveListener = false; return; } QuestTraceInfo questInfo = QuestTranceManager.Instance.GetQuestTraceInfo(m_nDoingTaskID); if (questInfo == null) { Engine.Utility.EventEngine.Instance().RemoveEventListener(nEventId, OnEvent); m_bAddStopMoveListener = false; return; } if (EqualsMapID(questInfo.QuestTable.destMapID)) { Engine.Utility.EventEngine.Instance().RemoveEventListener(nEventId, OnEvent); m_bAddStopMoveListener = false; uint npcid; Vector2 pos; if (questInfo.IsKillMonster(out npcid)) { Client.IMapSystem ms = Client.ClientGlobal.Instance().GetMapSystem(); if (ms.GetClienNpcPos((int)npcid, out pos)) { UnityEngine.Vector3 mainPos = Client.ClientGlobal.Instance().MainPlayer.GetPos(); if (mainPos.x == pos.x && mainPos.z == -pos.y) { Client.IControllerSystem cs = Client.ClientGlobal.Instance().GetControllerSystem(); if (cs != null) { cs.GetCombatRobot().StartWithTarget((int)npcid); Engine.Utility.Log.LogGroup("ZCX", "挂机杀怪物{0}", npcid); } } } } else if (questInfo.IsMoveToTargetPos(out pos)) { Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.ROBOTCOMBAT_SEARCHPATH, false); UnityEngine.Vector3 mainPos = Client.ClientGlobal.Instance().MainPlayer.GetPos(); if (mainPos.x == pos.x && mainPos.z == -pos.y) { if (DataManager.Manager <UIPanelManager>().IsShowPanel(PanelID.MainUsePanel)) { return; } MainUsePanelData mainUsePanelData = new MainUsePanelData(); mainUsePanelData.type = 2; // type = 2为item mainUsePanelData.Id = questInfo.QuestTable.usecommitItemID; mainUsePanelData.onClick = MainUsePanelItemOnClick; this.usecommitItemID = questInfo.QuestTable.usecommitItemID; DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.MainUsePanel, data: mainUsePanelData); // DataManager.Manager<UIPanelManager>().ShowPanel(PanelID.MainUsePanel, data: questInfo.QuestTable.usecommitItemID); } } } }
public void OnEnterCopy(stEntertCopyUserCmd_S cmd) { m_dicTeammateStatus.Clear(); m_dicEnterZoneStatus.Clear(); m_dicSendEnterZoneTime.Clear(); CopyDataBase cdb = GameTableManager.Instance.GetTableItem <CopyDataBase>(cmd.copy_base_id); if (cdb != null) { m_uEnterCopyID = cmd.copy_base_id; uint campCopyId = 4001; //阵营战 if (m_uEnterCopyID != campCopyId) { m_uCopyCountDown = cdb.keepTime - cmd.copy_live_time; } Client.IMapSystem mapsys = ClientGlobal.Instance().GetMapSystem(); if (mapsys != null) { mapsys.SetEnterZoneCallback(OnEnterZone); } //进入副本时 初始化波数数据 InitWaveIdListByCopyId(); //进入副本接口 ICopy copy = GetCopyByCopyID(m_uEnterCopyID); if (copy != null) { copy.EnterCopy(); } else { stCopyInfo info = new stCopyInfo(); info.bShow = true; info.bShowBattleInfoBtn = false; DataManager.Manager <UIPanelManager>().SendMsg(PanelID.MainPanel, UIMsgID.eShowCopyInfo, info); this.CopyCDAndExitData = new CopyCDAndExitInfo { bShow = true, bShowBattleInfoBtn = false }; } //副本中关闭消息推送界面 if (DataManager.Manager <UIPanelManager>().IsShowPanel(PanelID.MessagePushPanel)) { DataManager.Manager <UIPanelManager>().HidePanel(PanelID.MessagePushPanel); } if (DataManager.Manager <UIPanelManager>().IsShowPanel(PanelID.MissionAndTeamPanel)) { DataManager.Manager <UIPanelManager>().SendMsg(PanelID.MissionAndTeamPanel, UIMsgID.eCopyEnter, null); } Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.COMBOT_ENTER_EXIT, new Client.stCombotCopy() { copyid = cmd.copy_base_id, enter = true }); //进入副本标志 m_bIsEnterCopy = true; } }
void ClearCopyData() { //退出副本 stExitCopyUserCmd_CS cmd = new stExitCopyUserCmd_CS() { copy_base_id = 0 }; Client.IMapSystem mapsys = ClientGlobal.Instance().GetMapSystem(); if (mapsys != null) { mapsys.SetEnterZoneCallback(null); } ICopy copy = GetCopyByCopyID(m_uEnterCopyID); if (copy != null) { copy.ExitCopy(); } m_uEnterCopyID = 0; m_nLastKillWave = 0; m_nLastTransmitWave = 0; m_dicEnterZoneStatus.Clear(); m_dicSendEnterZoneTime.Clear(); this.CopyCDAndExitData = null; //清副本目标数据 CleanCopyTargetData(); stCopyInfo info = new stCopyInfo(); info.bShow = false; DataManager.Manager <UIPanelManager>().SendMsg(PanelID.MainPanel, UIMsgID.eShowCopyInfo, info); if (DataManager.Manager <UIPanelManager>().IsShowPanel(PanelID.MissionAndTeamPanel)) { DataManager.Manager <UIPanelManager>().SendMsg(PanelID.MissionAndTeamPanel, UIMsgID.eCopyExit, null); } Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.COMBOT_ENTER_EXIT, new Client.stCombotCopy() { copyid = cmd.copy_base_id, exit = true }); IControllerSystem cs = ClientGlobal.Instance().GetControllerSystem(); if (cs == null) { Engine.Utility.Log.Error("ExecuteCmd: ControllerSystem is null"); return; } if (cs.GetCombatRobot().Status != CombatRobotStatus.STOP) { cs.GetCombatRobot().Stop(); } IPlayer player = ClientGlobal.Instance().MainPlayer; if (player != null) { player.SendMessage(EntityMessage.EntityCommand_StopMove, player.GetPos()); CmdManager.Instance().Clear();//清除寻路 } //退出副本标志 m_bIsEnterCopy = false; }