private void ResetJoystick() { m_widget_joystick.alpha = 0.5f; m_widget_joystick.gameObject.transform.localPosition = m_trans_joystickPos.localPosition; m_sprite_joystickThumb.transform.localPosition = Vector3.zero; m_sprite_joystickBg.transform.localPosition = Vector3.zero; m_sprite_joystickThumb.GetComponent <BoxCollider>().enabled = false; Client.IControllerSystem controllerSys = Client.ClientGlobal.Instance().GetControllerSystem(); if (controllerSys != null) { Client.IController ctrl = controllerSys.GetActiveCtrl(); if (ctrl != null) { ctrl.OnMessage(Engine.MessageCode.MessageCode_JoystickEnd); } } Engine.Utility.EventEngine.Instance().DispatchEvent((int)(int)Client.GameEventID.JOYSTICK_UNPRESS, null); if (MainPlayerHelper.GetMainPlayer() != null) { ISkillPart part = MainPlayerHelper.GetMainPlayer().GetPart(EntityPart.Skill) as ISkillPart; if (part != null) { int st = part.GetCurSkillState(); if (st == (int)SkillState.None || st == (int)SkillState.Prepare) { stForbiddenJoystick info = new stForbiddenJoystick(); info.playerID = MainPlayerHelper.GetPlayerUID(); info.bFobidden = false; EventEngine.Instance().DispatchEvent((int)GameEventID.SKILL_FORBIDDENJOYSTICK, info); } } } }
//static uint nLastTaskID = 0; public void VisitNpc(bool bDirectly, uint nMapID, uint nNpcID, uint nTaskID) { //bool bProcess = true; //if (nLastTaskID == nTaskID && nProcessTaskID == nTaskID) //{ // bProcess = false; //} //else //{ // nLastTaskID = nTaskID; //} //if (bProcess == false) // return; Client.IControllerSystem cs = Client.ClientGlobal.Instance().GetControllerSystem(); if (cs == null) { return; } Client.IController controller = cs.GetActiveCtrl(); if (controller == null) { Engine.Utility.Log.Error("IController is null"); return; } //bDirectly = false; if (bDirectly)//是否直接跨地图去接取 { if (EqualsMapID(nMapID)) { controller.VisiteNPC(nMapID, nNpcID); } else { //下载地图检查 if (!KHttpDown.Instance().SceneFileExists(nMapID)) { //打开下载界面 DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.DownloadPanel); return; } controller.VisiteNPCDirectly(nMapID, nNpcID, nTaskID, 100, 100); } } else { controller.VisiteNPC(nMapID, nNpcID, false); } }
Client.IController GetController() { Client.IControllerSystem ctrlSys = ClientGlobal.Instance().GetControllerSystem(); if (ctrlSys == null) { return(null); } Client.IController ctrl = ctrlSys.GetActiveCtrl(); if (ctrl == null) { return(null); } return(ctrl); }
private void OnThumbDrag(GameObject obj, Vector2 delta) { if (m_bIgnore) { return; } if (MainPlayerHelper.GetMainPlayer().IsDead()) { return; } Vector2 touchPos = UICamera.currentTouch.pos; float fDis = Vector2.Distance(m_LastJoystickBgScreenPos, touchPos); if (m_bJoystickStable) { Vector2 touchDelta2 = touchPos - m_LastJoystickBgScreenPos; m_sprite_joystickThumb.transform.position = UICamera.currentCamera.ScreenToWorldPoint(new Vector3(touchPos.x, touchPos.y, 0)); if (fDis < m_fMaxDis) { Vector2 pos = m_LastJoystickBgScreenPos + touchDelta2; Vector3 pp = UICamera.currentCamera.ScreenToWorldPoint(new Vector3(pos.x, pos.y, 0)); m_sprite_joystickThumb.transform.position = new Vector3(pp.x, pp.y, 0); } else { Vector2 dt = touchDelta2.normalized; Vector2 pos = m_LastJoystickBgScreenPos + dt * m_fMaxDis; Vector3 pp = UICamera.currentCamera.ScreenToWorldPoint(new Vector3(pos.x, pos.y, 0)); m_sprite_joystickThumb.transform.position = new Vector3(pp.x, pp.y, 0); } } else { m_sprite_joystickThumb.transform.position = UICamera.currentCamera.ScreenToWorldPoint(new Vector3(touchPos.x, touchPos.y, 0)); if (fDis > m_fMaxDis) { Vector2 dir = (new Vector2(touchPos.x, touchPos.y) - m_LastJoystickBgScreenPos).normalized; Vector2 pos = dir * (fDis - m_fMaxDis); m_LastJoystickBgScreenPos += pos; m_sprite_joystickBg.transform.position = UICamera.currentCamera.ScreenToWorldPoint(new Vector3(m_LastJoystickBgScreenPos.x, m_LastJoystickBgScreenPos.y, 0)); } } m_LastTouchPos = touchPos; //if (m_bSkillLongPress) //{ // return; //} if (fDis < 10) { return; } Vector2 touchDelta = touchPos - m_LastJoystickBgScreenPos; // 根据 touchDelta 计算角度 垂直向上 float fAngle = Vector2.Angle(Vector2.up, touchDelta); if (touchDelta.x < 0) { fAngle = -fAngle; } fAngle += CameraFollow.Instance.YAngle; Client.IControllerSystem controllerSys = Client.ClientGlobal.Instance().GetControllerSystem(); if (controllerSys != null) { Client.IController ctrl = controllerSys.GetActiveCtrl(); if (ctrl != null) { ctrl.OnMessage(Engine.MessageCode.MessageCode_JoystickChanging, (object)fAngle); if (m_bSkillLongPress) { //点击摇杆 解除长按 Controller.CmdManager.Instance().Clear(); stSkillLongPress longPress = new stSkillLongPress(); longPress.bLongPress = false; EventEngine.Instance().DispatchEvent((int)GameEventID.SKLL_LONGPRESS, longPress); } } } }
void OnSkillUse(GameObject go) { Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.MAINBTN_ONTOGGLE, new Client.stMainBtnSet() { pos = 1, isShow = false }); if (parent != null) { Client.IPlayer mainPlayer = ClientGlobal.Instance().MainPlayer; if (mainPlayer == null) { Log.Error("mainPlayer is null"); return; } if (IsCDing) { Log.Error("IsCDing"); return; } bool bRide = DataManager.Manager <RideManager>().IsRide; if (bRide) {//使用任何一个技能都下马 if (m_skillBtnIndex != 0) { parent.ReqUseSkill((uint)m_skillid); } else { DataManager.Instance.Sender.RideDownRide(); parent.ReqUseSkill((uint)m_skillid); } } else { if (m_skillBtnIndex != 10) { LearnSkillDataManager skilldata = DataManager.Manager <LearnSkillDataManager>(); uint commonSkill = skilldata.GetCommonSkillIDByJob(); if (commonSkill != m_skillid) {//普工不走cd if (m_skillBtnIndex == 9) { if (CheckItem()) { var cmd = new GameCmd.stMultiAttackUpMagicUserCmd_C(); cmd.wdSkillID = (uint)m_skillid; Client.IController cs = GetController(); if (cs != null) { IEntity target = cs.GetCurTarget(); if (target != null) { stMultiAttackUpMagicUserCmd_C.Item item = new stMultiAttackUpMagicUserCmd_C.Item(); item.byEntryType = (target.GetEntityType() == EntityType.EntityType_Player ? SceneEntryType.SceneEntry_Player : SceneEntryType.SceneEntry_NPC); item.dwDefencerID = target.GetID(); cmd.data.Add(item); ReqUsePetSkill(cmd); } else { SkillDatabase db = GameTableManager.Instance.GetTableItem <SkillDatabase>(m_skillid); if (db != null) { if (db.targetType != 0) { ReqUsePetSkill(cmd); } else { if (db.targetParam == 4 || db.targetParam == 7 || db.targetParam == 8) { ReqUsePetSkill(cmd); } else { TipsManager.Instance.ShowTips("该技能需要目标"); } } } } } //宠物技能使用 } } else { parent.ReqUseSkill((uint)m_skillid); } } } else { parent.ChangeSkill(this.gameObject); } } parent.OnClickSkillBtn(go, 50010); } else { Log.Error("parent is null"); } }
// 同步技能消息 public void SyncSkill(uint uSkillID, Client.IEntity target, Vector3 targetPos) { if(uSkillID == 0) { Log.Error("SyncSkill skillid is 0"); return; } // 填充数据 Vector3 pos = m_Master.GetPos(); SkillDatabase database = GetSkillDataBase(uSkillID); Client.IControllerSystem ctrlSys = m_ClientGlobal.GetControllerSystem(); if (ctrlSys == null) { return; } Client.IController ctrl = ctrlSys.GetActiveCtrl(); if (ctrl == null) { return; } if (targetPos == Vector3.zero) { int skillerror = 0; bool bCanUse = ctrl.FindTargetBySkillID(CurSkillID, ref targetPos, ref target, out skillerror); if (!bCanUse) { Log.LogGroup("ZDY", "不符合规则 不能放技能"); return; } } var cmd = new GameCmd.stMultiAttackUpMagicUserCmd_C(); cmd.dwAttackerID = (uint)m_ClientGlobal.MainPlayer.GetID(); cmd.wdSkillID = uSkillID; cmd.byEntryType = SceneEntryType.SceneEntry_Player; cmd.srcx = (uint)(pos.x); cmd.srcy = (uint)(-pos.z); Vector3 rot = m_Master.GetRotate(); cmd.byDirect = (uint)rot.y; Vector3 sendTargetPos = GetSendTargetPos(database, targetPos); cmd.x = (uint)(sendTargetPos.x * 100); cmd.y = (uint)(-sendTargetPos.z * 100); if (target != null) { stMultiAttackUpMagicUserCmd_C.Item item = new stMultiAttackUpMagicUserCmd_C.Item(); if (target != null) { item.byEntryType = (target.GetEntityType() == EntityType.EntityType_Player ? SceneEntryType.SceneEntry_Player : SceneEntryType.SceneEntry_NPC); item.dwDefencerID = (uint)target.GetID(); } else { item.dwDefencerID = 0; } cmd.data.Add(item); } m_uDamageID++; cmd.tmpid = m_uDamageID; // 填充数据 m_ClientGlobal.netService.Send(cmd); }
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); } }