public uint Execute(PacketDistributed ipacket) { GC_PLAY_MODELSOTRY packet = (GC_PLAY_MODELSOTRY)ipacket; if (null == packet) { return((uint)PACKET_EXE.PACKET_EXE_ERROR); } //enter your logic if (packet.ModelStoryID == GlobeVar.YanMenGuan_ModelStoryID) { Obj_MainPlayer mainplayer = Singleton <ObjManager> .Instance.MainPlayer; if (mainplayer == null) { return((uint)PACKET_EXE.PACKET_EXE_ERROR); } //mainplayer.CameraController.InitCameraTrack(mainplayer.Position, curBoss.Position); mainplayer.ModelStoryID = packet.ModelStoryID; mainplayer.StopMove(); Vector3 posTarget = new Vector3(13.9f, 0, 27.4f); Vector3 posTargetTerrain = ActiveScene.GetTerrainPosition(posTarget); mainplayer.MoveTo(posTargetTerrain); } return((uint)PACKET_EXE.PACKET_EXE_CONTINUE); }
public override void UpdateAI() { base.UpdateAI(); if (m_player == null || m_player.Controller == null) { return; } if (m_player.IsDie()) { return; } if (m_player.Controller.CombatFlag == false) { return; } if (m_player.AutoComabat == false) { return; } //轻功状态下 不挂机 if (m_player.QingGongState) { return; } if (m_player.AcceleratedMotion != null && m_player.AcceleratedMotion.Going == true) { return; } //剧情播放中不挂机 if (m_player.IsInModelStory) { return; } // 跟随不挂机 if (false == m_player.IsTeamLeader() && m_player.IsInTeamFollow) { return; } if (Cutscene.CutsceneManager.Instance.IsPlayingMovieStory) { return; } //阻塞状态不挂机 if (Cutscene.CutsceneManager.Instance.BlockAutoBattle) { return; } //自动交接任务的寻路过程中不挂机 if (null != GameManager.gameManager.AutoSearch && true == GameManager.gameManager.AutoSearch.IsAutoSearching) { return; } //modify 普通攻击:可以连续按。在技能结束前可以再次释放不能直接return。 if (m_player.SkillCore.IsUsingSkill) { bool shouldReturn = true; if ((Time.time * 1000 - CurUseSkillStartTime) >= m_nNormalSkillInterval) { if (IsNormalSkill(CurUseSkillId)) { shouldReturn = false; } } if (shouldReturn) { return; } } #region UnUsed /* if (m_player.SkillCore.IsUsingSkill) * { * * return; * if (m_player.SkillCore.UsingSkillBaseInfo != null && m_player.SkillCore.UsingSkillExInfo !=null) * { * //正在使用祝融掌 则检测下当前目标是否还存在 不存在则重新选取目标 * //if (m_player.SkillCore.UsingSkillBaseInfo.Id ==(int)SKILLBASEID.ZLZ) * //{ * // if (m_player.SelectTarget ==null || m_player.SelectTarget.IsDie()) * // { * // Obj_Character _NewAttackCharacter = SeleCanAttackTar(m_player.SkillCore.UsingSkillExInfo.Radius); * // if (_NewAttackCharacter != null) * // { * // //设置新的选中目标 * // m_player.OnSelectTarget(_NewAttackCharacter.gameObject,false); * // m_player.MoveTo(_NewAttackCharacter.transform.position, _NewAttackCharacter.gameObject,1.0f); * // } * // } * //} * * //连续技特殊判定: * //1、判定玩家是否主动打断; * //2、不判定是否释放完成,一直尝试是否可释放; * if (IsPlayerBreakRepeatSkill()) * { * ClearPlayerBreakRepeatSkill(); * return; * } * //非连续技则等待一帧 * if (!IsUsingRepeatSkillWithNext()) * { * return; * } * } * } * else * { * if (m_fLastUseEndTime <=0.1f) * { * m_fLastUseEndTime = Time.time; * } * }*/ #endregion //留个缓冲时间 //if (Time.time -m_fLastUseEndTime <0.5f) //{ // return; //} //有轻功点了出现了 向轻功点移动 if (m_player.AutoMovetoQGPointId != -1) { //打断挂机状态 m_player.BreakAutoCombatState(); /*if (GameManager.gameManager.RunningScene == (int)Games.GlobeDefine.GameDefine_Globe.SCENE_DEFINE.SCENE_YANZIWU) * { * //燕子坞轻功点移动 * m_player.AutoFightFlyInYanZiWu(); * }*/ m_player.AutoMovetoQGPointId = -1; return; } m_fLastUseEndTime = 0.0f; int skillId = SeleSkill(); if (skillId == -1) { return; } Tab_SkillEx skillExInfo = TableManager.GetSkillExByID(skillId, 0); if (skillExInfo == null) { return; } Tab_SkillBase skillBaseInfo = TableManager.GetSkillBaseByID(skillExInfo.BaseId, 0); if (skillBaseInfo == null) { return; } Obj_Character CanAttackCharacter = null; //如果当前选中的目标是敌对的了 则不需要再次选取目标 if (m_player.SelectTarget != null && m_player.SelectTarget.IsDie() == false) { if (Reputation.IsEnemy(m_player.SelectTarget) || Reputation.IsNeutral(m_player.SelectTarget)) { CanAttackCharacter = m_player.SelectTarget; } } float skillRadius = skillExInfo.Radius; if (CanAttackCharacter == null || (CanAttackCharacter != null && IsDisStartPointTooFar(skillRadius, CanAttackCharacter.Position)) ) { CanAttackCharacter = SeleCanAttackTar(skillRadius); } //是否有攻击目标 没有攻击目标就不要自动放技能了 if (CanAttackCharacter == null) { /* * if (GameManager.gameManager.RunningScene == (int)Games.GlobeDefine.GameDefine_Globe.SCENE_DEFINE.SCENE_ZHENLONGQIJU) * { * Vector3 pos = new Vector3(18, m_player.gameObject.transform.position.y, 16); * m_player.MoveTo(pos, null, 0.0f); * * } * if (GameManager.gameManager.RunningScene == (int)Games.GlobeDefine.GameDefine_Globe.SCENE_DEFINE.SCENE_YANGWANGGUMU) * { * Vector3 pos = new Vector3(20, m_player.gameObject.transform.position.y, 21); * m_player.MoveTo(pos, null, 0.0f); * } * * if (GameManager.gameManager.RunningScene == (int)Games.GlobeDefine.GameDefine_Globe.SCENE_DEFINE.SCENE_YANZIWU) * { * m_player.AutoFightInYanziwu(); * } * if (GameManager.gameManager.RunningScene == (int)Games.GlobeDefine.GameDefine_Globe.SCENE_DEFINE.SCENE_FOURVILLAIN) * { * Singleton<ObjManager>.Instance.MainPlayer.AutoFightInFourVillain(); * } */ if (GameManager.gameManager.ActiveScene != null && GameManager.gameManager.ActiveScene.IsStoryCopyScene()) { if (Singleton <ObjManager> .GetInstance().MainPlayer != null) { if (Singleton <ObjManager> .GetInstance().MainPlayer.AutoComabat) { float x = 0.0f, y = 0.0f, z = 0.0f; if (GameManager.gameManager.ActiveScene.GetGuideDestination(ref x, ref z)) { y = GameManager.gameManager.ActiveScene.GetTerrainHeight(new Vector3(x, 0.0f, z)); Singleton <ObjManager> .GetInstance().MainPlayer.MoveTo(new Vector3(x, y, z), null, 0.0f); } } } } return; } //如果在野外场景攻击其它玩家return; if (CanAttackCharacter.ObjType == Games.GlobeDefine.GameDefine_Globe.OBJ_TYPE.OBJ_OTHER_PLAYER) { if (GameManager.gameManager.ActiveScene.IsWildeScene()) { return; } } //设置为选中目标 m_player.OnSelectTarget(CanAttackCharacter.gameObject, false); //距离不过 先跑过去 float dis = Vector3.Distance(m_player.Position, CanAttackCharacter.Position); float diffDistance = dis - skillRadius; m_player.CurUseSkillId = skillId; //需要向目标移动 则想目标移动 if (diffDistance > 0 && skillBaseInfo.IsMoveToTarInAutoCombat == 1) { //move if (m_player.IsMoving == false && m_player.IsCanOperate_Move()) { m_player.MoveTo(CanAttackCharacter.Position, CanAttackCharacter.gameObject, skillRadius - 1.0f); return; } } m_player.UseSkillOpt(skillId, null); }
void AnalyseTouchPos_Click(Vector3 posPressed, Touch touch) { if ((m_SceneTouchFingerID == -1) || (m_SceneTouchFingerID != -1 && touch.fingerId == m_SceneTouchFingerID)) { if (!UIManager.IsSubUIShow()) { Ray ray = Camera.main.ScreenPointToRay(posPressed); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { if (touch.phase != TouchPhase.Ended) { //if (null != PlayerFrameLogic.Instance() && !PlayerFrameLogic.Instance().Fold) //{ //PlayerFrameLogic.Instance().m_PlayerHeadButton.gameObject.GetComponent<UIPlayTween>().Play(false); //PlayerFrameLogic.Instance().PlayerFrameHeadOnClick(); //} // 客户单物品 点击拾取 if (hit.collider.gameObject.CompareTag("CollectItem")) { Singleton <CollectItem> .GetInstance().RemoveItem(hit.collider.gameObject); GameEvent gameEvent = new GameEvent(Games.GlobeDefine.GameDefine_Globe.EVENT_DEFINE.EVENT_TOUCH_OBJECT); Singleton <EventSystem> .GetInstance().PushEvent(gameEvent); return; } Obj_MainPlayer _mainPlayer = Singleton <ObjManager> .GetInstance().MainPlayer; if (null == _mainPlayer) { return; } //Obj点击操作,单击点选目标,双击移动过去 Obj_Character npcScript = hit.collider.gameObject.GetComponent <Obj_Character>(); if (npcScript) { if (m_bIsMouseDBClick || Reputation.IsEnemy(npcScript)) { //npcScript.FaceTo(Singleton<ObjManager>.GetInstance().MainPlayer.transform.position); if (_mainPlayer.IsCanOperate_Move()) { _mainPlayer.BreakAutoCombatState(); _mainPlayer.LeaveTeamFollow(); _mainPlayer.MoveTo(hit.collider.gameObject.transform.position, hit.collider.gameObject, 1.0f); _mainPlayer.FaceTo(hit.collider.transform.position); _mainPlayer.OnSelectTarget(hit.collider.gameObject); _mainPlayer.HasSendpos = false; } else { if (!_mainPlayer.HasSendpos) { _mainPlayer.HasSendpos = true; _mainPlayer.SynCleanCacheSkillToServer(); _mainPlayer.LastForceSynPosTime = Time.time; } } } else { //选择目标 _mainPlayer.OnSelectTarget(hit.collider.gameObject); } GameEvent gameEvent = new GameEvent(Games.GlobeDefine.GameDefine_Globe.EVENT_DEFINE.EVENT_TOUCH_OBJECT); Singleton <EventSystem> .GetInstance().PushEvent(gameEvent); } } } } } return; }
void AnalyseMousePos_Click(Vector3 posPressed) { if (null != UICamera.mainCamera) { Ray nUIRay = UICamera.mainCamera.ScreenPointToRay(posPressed); RaycastHit nHit; if (Physics.Raycast(nUIRay, out nHit)) { if (nHit.collider.gameObject.CompareTag("SubUI") || nHit.collider.gameObject.CompareTag("UI")) { return; } } } if (!UIManager.IsSubUIShow()) { Ray ray = Camera.main.ScreenPointToRay(posPressed); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { // 客户单物品 点击拾取 if (hit.collider.gameObject.CompareTag("CollectItem")) { Singleton <CollectItem> .GetInstance().RemoveItem(hit.collider.gameObject); GameEvent gameEvent = new GameEvent(Games.GlobeDefine.GameDefine_Globe.EVENT_DEFINE.EVENT_TOUCH_OBJECT); Singleton <EventSystem> .GetInstance().PushEvent(gameEvent); return; } Obj_MainPlayer _mainPlayer = Singleton <ObjManager> .GetInstance().MainPlayer; if (null == _mainPlayer) { return; } //Obj点击操作,单击点选目标,双击移动过去 Obj_Character npcScript = hit.collider.gameObject.GetComponent <Obj_Character>(); if (npcScript) { if (m_bIsMouseDBClick || Reputation.IsEnemy(npcScript)) { if (_mainPlayer.IsCanOperate_Move()) { _mainPlayer.BreakAutoCombatState(); _mainPlayer.LeaveTeamFollow(); _mainPlayer.MoveTo(hit.collider.gameObject.transform.position, hit.collider.gameObject, 1.0f); _mainPlayer.FaceTo(hit.collider.transform.position); _mainPlayer.OnSelectTarget(hit.collider.gameObject); _mainPlayer.HasSendpos = false; } else { if (!_mainPlayer.HasSendpos) { _mainPlayer.HasSendpos = true; _mainPlayer.SynCleanCacheSkillToServer(); _mainPlayer.LastForceSynPosTime = Time.time; } } } else { //选择目标 _mainPlayer.OnSelectTarget(hit.collider.gameObject); } GameEvent gameEvent = new GameEvent(Games.GlobeDefine.GameDefine_Globe.EVENT_DEFINE.EVENT_TOUCH_OBJECT); Singleton <EventSystem> .GetInstance().PushEvent(gameEvent); } Obj_Mount mountScript = hit.collider.gameObject.GetComponent <Obj_Mount>(); if (null != mountScript) { if (mountScript.PlayerObj == null) { return; } //Obj_Character Obj_Char = mountScript.PlayerObj.gameObject.GetComponent<Obj_Character>(); //if (Obj_Char == null) //{ // return; //} if (m_bIsMouseDBClick || Reputation.IsEnemy(mountScript.PlayerObj)) { //npcScript.FaceTo(Singleton<ObjManager>.GetInstance().MainPlayer.transform.position); if (_mainPlayer.IsCanOperate_Move()) { _mainPlayer.BreakAutoCombatState(); _mainPlayer.LeaveTeamFollow(); _mainPlayer.MoveTo(mountScript.PlayerObj.gameObject.transform.position, hit.collider.gameObject, 1.0f); _mainPlayer.FaceTo(mountScript.PlayerObj.ObjTransform.position); _mainPlayer.OnSelectTarget(mountScript.PlayerObj.gameObject); _mainPlayer.HasSendpos = false; } else { if (!_mainPlayer.HasSendpos) { _mainPlayer.HasSendpos = true; _mainPlayer.SynCleanCacheSkillToServer(); _mainPlayer.LastForceSynPosTime = Time.time; } } } else { //选择目标 _mainPlayer.OnSelectTarget(mountScript.PlayerObj.gameObject); } } } } return; }
bool AnalyseTouchPos_Stay(Vector3 posPressed, Touch touch) { if ((m_SceneTouchFingerID == -1) || (m_SceneTouchFingerID != -1 && touch.fingerId == m_SceneTouchFingerID)) { if (null != UICamera.mainCamera) { Ray nUIRay = UICamera.mainCamera.ScreenPointToRay(posPressed); RaycastHit nHit; if (Physics.Raycast(nUIRay, out nHit)) { if (nHit.collider.gameObject.CompareTag("SubUI") || nHit.collider.gameObject.CompareTag("UI")) { GameEvent gameEvent = new GameEvent(Games.GlobeDefine.GameDefine_Globe.EVENT_DEFINE.EVENT_TOUCH_UI); Singleton <EventSystem> .GetInstance().PushEvent(gameEvent); ReleaseTouch(); return(true); } } } Obj_MainPlayer curPlayer = Singleton <ObjManager> .GetInstance().MainPlayer; if (null == curPlayer) { return(false); } //if (curPlayer.CameraController != null && curPlayer.CameraController.IsPinching()) //{ // return true; //} if (m_bPinching) { return(true); } if (!UIManager.IsSubUIShow() && PlayerPreferenceData.SystemScreenMove == 1) { if (curPlayer.IsCanOperate_Move()) { Ray ray = Camera.main.ScreenPointToRay(posPressed); RaycastHit hit; if (Physics.Raycast(ray.origin, ray.direction, out hit, 100f, ActiveScene.MoveLayerMask.value | 1 << LayerMask.NameToLayer("LogicObj"))) { if (hit.collider.gameObject.layer == LayerMask.NameToLayer("MoveLayer")) { if (touch.phase != TouchPhase.Ended) { //可能点击地形非正常行走面,通过高度差进行判断,当发现高度差过大的时候,则认为非法 if (Math.Abs(hit.point.y - curPlayer.ObjTransform.position.y) > 5) { ReleaseTouch(); return(false); } curPlayer.BreakAutoCombatState(); curPlayer.LeaveTeamFollow(); curPlayer.MoveTo(hit.point, null, 0.5f); if (null != GameManager.gameManager.ActiveScene) { GameManager.gameManager.ActiveScene.ActiveMovingCircle(hit.point); } if (m_SceneTouchFingerID == -1) { m_SceneTouchFingerID = touch.fingerId; //m_bPlayerTouchMoving = true; } } else if (m_SceneTouchFingerID == touch.fingerId) { ReleaseTouch(); } GameEvent gameEvent = new GameEvent(Games.GlobeDefine.GameDefine_Globe.EVENT_DEFINE.EVENT_TOUCH_SCENE); Singleton <EventSystem> .GetInstance().PushEvent(gameEvent); return(true); } } curPlayer.HasSendpos = false; } else { if (!curPlayer.HasSendpos) { curPlayer.HasSendpos = true; curPlayer.SynCleanCacheSkillToServer(); curPlayer.LastForceSynPosTime = Time.time; } } } } return(false); }
public void UpdateSmoothedMovementDirection() { m_IsJoyMoving = false; if (null == m_MainPlayer) { m_MainPlayer = Singleton <ObjManager> .GetInstance().MainPlayer; if (null != m_MainPlayer) { m_MainPlayerTransform = m_MainPlayer.transform; } else { return; } } if (null == m_CameraTransform) { m_CameraTransform = Camera.main.transform; if (null == m_CameraTransform) { return; } } m_bIsMoving = Mathf.Abs(m_fHorizonRaw) > 0.1 || Mathf.Abs(m_fVerticalRaw) > 0.1; //如果玩家正在点击移动,则判断是否有输入,如果没有则不进行更新,否则打断 if (!m_bIsMoving && m_MainPlayer.IsMoving) { return; } if (false == m_MainPlayer.IsCanOperate_Move()) { return; } // Forward vector relative to the camera along the x-z plane Vector3 forward = m_CameraTransform.TransformDirection(Vector3.forward); forward.y = 0; forward = forward.normalized; // Right vector relative to the camera // Always orthogonal to the forward vector Vector3 right = new Vector3(forward.z, 0, -forward.x); // Target direction relative to the camera var targetDirection = m_fHorizonRaw * right + m_fVerticalRaw * forward; // We store speed and direction seperately, // so that when the character stands still we still have a valid forward direction // moveDirection is always normalized, and we only update it if there is user input. if (targetDirection != Vector3.zero) { // If we are really slow, just snap to the target direction if (m_fMoveSpeed < m_fWalkSpeed * 0.9) { m_vecMoveDirection = targetDirection.normalized; } // Otherwise smoothly turn towards it else { m_vecMoveDirection = Vector3.RotateTowards(m_vecMoveDirection, targetDirection, m_fRrotateSpeed * Mathf.Deg2Rad * Time.deltaTime, 1000); m_vecMoveDirection = m_vecMoveDirection.normalized; } } // Smooth the speed based on the current target direction // float curSmooth = m_fSpeedSmoothing * Time.deltaTime; // Choose target speed if (m_bIsMoving) { m_IsJoyMoving = true; m_fMoveSpeed = m_MainPlayer.m_fMoveSpeed; Vector3 movement = m_vecMoveDirection * m_fMoveSpeed; movement *= Time.deltaTime; //移动 m_MainPlayer.BreakAutoCombatState(); m_MainPlayer.LeaveTeamFollow(); Vector3 newPos = m_MainPlayerTransform.localPosition + movement * 10; //如果发动摇杆移动操作,清除掉地面点击特效 GameManager.gameManager.ActiveScene.DeactiveMovingCircle(); //进行移动操作 m_MainPlayer.MoveTo(newPos, null, 0.0f); // added by mawenbin // 挂机自动战斗时设置玩家主动移动 AI_PlayerCombat aiPlayerCombat = m_MainPlayer.GetComponent <AI_PlayerCombat>(); if (null != aiPlayerCombat && m_MainPlayer.IsOpenAutoCombat && m_MainPlayer.AutoComabat) { aiPlayerCombat.IsPlayerControlMove = true; } //设置模型方向 if (m_MainPlayer.SkillCore == null || m_MainPlayer.SkillCore.IsUsingSkill == false) // 播放旋风斩动画时不转向 { // 有自动寻路代理了,为什么还要自己设置转向? ,by lizhe if (m_MainPlayer.NavAgent == null) { m_MainPlayerTransform.rotation = Quaternion.LookRotation(m_vecMoveDirection); } } m_MainPlayer.CurObjAnimState = Games.GlobeDefine.GameDefine_Globe.OBJ_ANIMSTATE.STATE_WALK; } else { m_fMoveSpeed = 0.0f; if (false == Cutscene.CutsceneActionPlayAnim.m_bIsPlayingMainPlayerAnim) { m_MainPlayer.CurObjAnimState = Games.GlobeDefine.GameDefine_Globe.OBJ_ANIMSTATE.STATE_NORMOR; } } }