public FindPathLogicData FindRoomNode(Vector3 pos, int guid) { FindPathLogicData retNode = null; foreach (FindPathLogicData node in mFindPathDataList) { if ((pos.x >= node.LBPos.x && pos.z >= node.LBPos.z) && (pos.x <= node.RTPos.x && pos.z <= node.RTPos.z)) { retNode = node; if (guid != -1) { if (retNode.GUID != -1) { return(retNode); } } else { if (retNode.GUID == -1) { return(retNode); } } } } return(retNode); }
public override void Update() { base.BaseUpdate(); m_nextAITime -= Time.deltaTime; if (m_nextAITime > 0.0f) { return; } m_nextAITime = UnityEngine.Random.Range(0.1f, 0.5f); if (Self.IsActorExit) { return; //当前角色离场 } if (Portals()) //传送 { } else if (PlayerCMD())//玩家操作 { } else if (AutoBattle())//战斗 { } else if (m_curSceneRoom == null) { bool tmpBool = false; if (Owner.ActionControl.IsActionRunning(ActorAction.ENType.enStandAction)) {//检测是否在站立状态状态 tmpBool = true; } else if (Self.ActionControl.IsActionRunning(ActorAction.ENType.enMoveAction)) {//检测是否在移动状态 MoveAction action = Self.ActionControl.LookupAction(ActorAction.ENType.enMoveAction) as MoveAction; if (action.IsStopMove && m_autoMove) {//在移动状态停止移动 tmpBool = true; } } if (tmpBool) { FindPathLogicData roomFindPathData = SM.RandomRoomLevel.Singleton.FindRoomNode(Self.MainPos); if (roomFindPathData != null) { Vector3 m_linkPos = roomFindPathData.m_links[1].m_linkPos; ActionMoveTo(m_linkPos); } } } }
public void BuildRoomFindPathData(FindPathLogicData pathData) { int x = pathData.m_roomLogicX; int y = pathData.m_roomLogicY; if (FindPathLogicData.xMin > x) { FindPathLogicData.xMin = x; } if (FindPathLogicData.yMin > y) { FindPathLogicData.yMin = y; } if (FindPathLogicData.xMax < x) { FindPathLogicData.xMax = x; } if (FindPathLogicData.yMax < y) { FindPathLogicData.yMax = y; } pathData.Valid = true; mFindPathDataList.Add(pathData); }
public bool AutoPathing() { if (m_curSceneRoom == null) {//监测当前所站立位置死否有房间 return(false); } if (!m_curSceneRoom.IsOpenState) {//监测当前房间是否开门 return(false); } if (Self.ActionControl.IsActionRunning(ActorAction.ENType.enStandAction) && m_autoMove) {//监测当前是否在站立状态 m_autoMove = false; } else if (Self.ActionControl.IsActionRunning(ActorAction.ENType.enMoveAction)) {//检测是否在移动状态 MoveAction action = Self.ActionControl.LookupAction(ActorAction.ENType.enMoveAction) as MoveAction; if (action.IsStopMove && m_autoMove) {//在移动状态停止移动 m_autoMove = false; } } if (m_autoMove) { return(false); } SM.SceneRoom curSceneRoom = m_curSceneRoom; AutoMoveRoom curRoomMoveData = GetAutoMoveRoomData(curSceneRoom.ID); int moveToRoomID = -1; bool noRoomCanTo = true; for (int i = 0; i < curSceneRoom.CurRoomInfo.m_gateList.Count; i++) {//遍历当前房间闸门 SM.Gate curGate = curSceneRoom.CurRoomInfo.m_gateList[i]; if (curGate.GateToRoomObjID == -1) { continue; } if (!curGate.OutIsActive) {//检测当前房间房间门是否开放 noRoomCanTo = false; continue; } if (curRoomMoveData.NeedToSearch(curGate.gateId)) {//检测当前闸门是否还用再去探索 continue; } moveToRoomID = curGate.GateToRoomObjID; break; } if (moveToRoomID == -1) {//闸门没有可去的那么返回上一个房间 SM.SceneRoom preRoom = m_curSceneRoom.m_preRoom; if (preRoom == null) { return(false); } moveToRoomID = preRoom.ID; if (noRoomCanTo) { for (int i = 0; i < preRoom.CurRoomInfo.m_gateList.Count; i++) { SM.Gate gate = preRoom.CurRoomInfo.m_gateList[i]; if (gate.GateToRoomObjID == curSceneRoom.ID) {//将上一个房间通向这个房间的闸门标记为不再探索 GetAutoMoveRoomData(moveToRoomID).AcceptGatePathList(gate.gateId); } } } } FindPathLogicData logicData = ScenePathfinder.Singleton.FindRoomNode(m_curSceneRoom.CurRoomInfo.m_GUID); foreach (FindPathLogicData.LinkInfo linkData in logicData.m_links) { foreach (FindPathLogicData.LinkInfo linkData1 in linkData.m_linkRoom.m_links) { if (linkData1.m_linkRoom.GUID == moveToRoomID) { ActionMoveTo(linkData1.m_linkPos); m_autoMove = true; return(true); } } } return(false); }