public TargetInfo(int _toMap, Vector3 _dest, float _ra, Move.PathFinished _arrived) { this.toMapId = _toMap; this.destination = _dest; this.radius = _ra; this.pathFinished = _arrived; }
public void clear() { this.targetType = RunToTarget.TargetType.Type_Null; this.targetArrived = null; this.goTarget = null; this.moveType = 0; }
private void SearchPathInArea(Vector3 _dst, Move.PathFinished _arrived) { NNInfo nearest = AstarPath.active.GetNearest(_dst); NNInfo nearest2 = AstarPath.active.GetNearest(this._self.transform.position); if (this.areaNavPath != null) { ListPool <GraphNode <AreaPathfinding.AreaInfo> > .Release(this.areaNavPath); } if (this.areaNavPath == null || this.areaNavPath.Count == 0) { this.areaNavPath = Singleton <AreaPathfinding> .Instance.FindPath((int)nearest2.node.Area, (int)nearest.node.Area); } if (this.areaNavPath != null) { if (this.areaNavPath.Count <= 1) { Debug.LogError("area path find error!"); return; } this.finalDestination = _dst; this.TrySearchPath(this.areaNavPath[0].Value.FindPoint(this.areaNavPath[1].Value.id), _arrived); } else { Debug.LogError(string.Format("Target position cannot be arrived (area{0} to area{1}", (int)nearest2.node.Area, (int)nearest.node.Area)); Singleton <WorldPathfinding> .Instance.StopWorldPathfinding(); this.StopPath(); } }
public void DoCallBack(Move.PathFinished callback = null) { if (callback != null) { callback(); } }
public void ResearchPathAfterJump() { if (Vector3.Distance(this._self.transform.position, this.finalDestination) < this.endReachedDistance) { Move.PathFinished pathFinished = this.pathFinished; this.StopPath(); if (pathFinished != null) { pathFinished(); } } else { this.lastRepath = 0f; if (this._self.entityType != RoleManager.EntityType.EntityType_Self || this.IsPathPossible(this.finalDestination)) { if (this.areaNavPath != null) { this.areaNavPath.Clear(); } this.TrySearchPath(this.finalDestination, this.pathFinished); } else { this.endReachedDistance = 0.1f; this.SearchPathInArea(this.finalDestination, this.pathFinished); } } }
public QueueItem(int type, float ra, Vector3 vec, Move.TargetAction act, Move.PathFinished finished) { this.walkType = type; this.radius = ra; this.target = vec; this.action = act; this.callback = finished; }
public void Target(Vector3 pos, float _radius = 0.6f, Move.PathFinished _delegate = null, int type = 0) { this.clear(); this.targetType = RunToTarget.TargetType.Type_Position; this.posTarget = pos; this.radius = _radius; this.moveType = type; this.targetArrived = _delegate; this.isWalkTo = false; this.Update(); }
public void Target(GameObject _go, float _radius = 0.6f, Move.PathFinished _delegate = null, int type = 0) { this.clear(); if (_go == null) { return; } this.targetType = RunToTarget.TargetType.Type_GameObject; this.goTarget = _go; this.radius = _radius; this.moveType = type; this.targetArrived = _delegate; }
public void SkillRunToTarget(SceneEntity attacker, GameObject targetGo, float radius, bool needDash) { if (attacker == null || targetGo == null || attacker.roleAction.Stop()) { return; } Move.PathFinished pathFinished = new Move.PathFinished(this.OnDashFinished); attacker.runToTarget.Target(targetGo, radius, (!needDash) ? null : pathFinished, (!needDash) ? 0 : 1); if (attacker.entityType == RoleManager.EntityType.EntityType_Self) { attacker.roleState.AddState(1); } }
private void Stop() { if (this.path != null) { this.path.Release(this, false); this.path = null; } this.pathFinished = null; this.ClearFinalDestination(); this.destination = Vector3.zero; this.isAutoRunning = false; this._self.runToTarget.clear(); }
public float TrySearchPath(Vector3 _dst, Move.PathFinished _arrived) { if (Time.time - this.lastRepath >= this.repathRate && this.canSearchAgain && this.canSearch) { this.pathFinished = _arrived; this.destination = _dst; this.isAutoRunning = true; this.SearchPath(); return(this.repathRate); } float num = this.repathRate - (Time.time - this.lastRepath); return((num >= 0f) ? num : 0f); }
public bool WalkTo(Vector3 _dst, float _radius = 0.1f, int type = 0, Move.PathFinished _arrived = null, bool searchImmediate = false) { if (_dst == this.destination || this._self == null) { return(false); } if (this.jumpMode != 0) { return(false); } if (this._self.entityType == RoleManager.EntityType.EntityType_Self) { Singleton <RoleManager> .Instance.cf.CameraTargetToSelf(false); } if (Vector3.Distance(this._self.transform.position, _dst) < _radius) { this.StopPath(); if (_arrived != null) { _arrived(); } return(false); } this.walkType = type; if (_radius < 0.1f) { _radius = 0.1f; } if (searchImmediate) { this.lastRepath = 0f; } if (this._self.entityType != RoleManager.EntityType.EntityType_Self || this.IsPathPossible(_dst)) { this.finalDestination = _dst; this.endReachedDistance = _radius; if (this.areaNavPath != null) { this.areaNavPath.Clear(); } this.TrySearchPath(_dst, _arrived); } else { this.endReachedDistance = _radius; this.SearchPathInArea(_dst, _arrived); } return(true); }
public override void OnTargetReached() { if (this.targetReached) { Move.PathFinished pathFinished = this.pathFinished; this.StopPath(); if (pathFinished != null) { pathFinished(); } } else { this.currentWaypointIndex++; } }
private static int get_targetArrived(IntPtr L) { object obj = null; int result; try { obj = ToLua.ToObject(L, 1); RunToTarget runToTarget = (RunToTarget)obj; Move.PathFinished targetArrived = runToTarget.targetArrived; ToLua.Push(L, targetArrived); result = 1; } catch (Exception ex) { result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index targetArrived on a nil value"); } return(result); }
private static int get_pathFinished(IntPtr L) { object obj = null; int result; try { obj = ToLua.ToObject(L, 1); WorldPathfinding.TargetInfo targetInfo = (WorldPathfinding.TargetInfo)obj; Move.PathFinished pathFinished = targetInfo.pathFinished; ToLua.Push(L, pathFinished); result = 1; } catch (Exception ex) { result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index pathFinished on a nil value"); } return(result); }
public void SearchPathInWorld(int toMap, Vector3 _dst, float radius, Move.PathFinished _arrived) { if (Singleton <RoleManager> .Instance.curSceneNo != toMap) { List <GraphNode <WorldPathfinding.MapPathInfo> > list = Singleton <WorldPathfinding> .Instance.FindPath(Singleton <RoleManager> .Instance.curSceneNo, toMap); if (list != null && list.Count > 1) { bool flag = this.WalkTo(list[0].Value.FindPoint(list[1].Value.id), 0.1f, 0, null, true); } else if (Singleton <RoleManager> .Instance.sceneType != 2) { Debug.LogError(string.Format("world path finding error: {0}:{1}", toMap, _dst)); } } else { _dst = Util.Convert2RealPosition((int)_dst.x, _dst.y, (int)_dst.z); Singleton <WorldPathfinding> .Instance.StopWorldPathfinding(); bool flag = this.WalkTo(_dst, radius, 0, _arrived, true); } }
private void StartPlotJump(SceneEntity entity) { if (entity.move.InFindingPath()) { Vector3 destination = entity.move.finalDestination; Move.PathFinished pathFinished = entity.move.pathFinished; float radius = entity.move.endReachedDistance; entity.StartPlotJump(this.doorNo, this.endMap, delegate { if (!Singleton <WorldPathfinding> .Instance.CheckWorldPathfinding()) { entity.move.WalkTo(destination, radius, 0, pathFinished, false); } }); } else { entity.StartPlotJump(this.doorNo, this.endMap, null); } Singleton <RoleManager> .Instance.cf.CameraTargetToSelf(true); this.SendPlotJumpStart(entity); }
public void BeginWorldPathfinding(int toMap, int x, float y, int z, float ra = 0.1f, Move.PathFinished callback = null, bool midPoint = false) { if (Singleton <RoleManager> .Instance.mainRole != null) { if (Singleton <RoleManager> .Instance.mainRole.move.jumpMode != 0) { Util.CallMethod("CtrlManager", "CSPopUpNotifyText", new object[] { "PlotJumpTip" }); return; } Vector3 vector = new Vector3((float)x, y, (float)z); if (toMap == 0 || vector == Vector3.zero) { return; } if (this.targetInfo == null || (this.targetInfo.toMapId != toMap && toMap != 0) || (this.targetInfo.destination != vector && vector != Vector3.zero)) { this.targetInfo = new WorldPathfinding.TargetInfo(toMap, vector, ra, callback); } Singleton <RoleManager> .Instance.mainRole.roleState.AddState(16); Singleton <RoleManager> .Instance.mainRole.move.SearchPathInWorld(toMap, vector, ra, delegate { Singleton <RoleManager> .Instance.mainRole.roleState.RemoveState(16); if (callback != null) { callback(); } }); Util.CallMethod("HERO", "SetMidPointWalk", new object[] { midPoint }); } }
public void MoveEnqueue(Vector3 position, int type, int walkType = 0, float radius = 0.1f, Move.PathFinished callback = null, string module = "", string func = "", params object[] param) { if (this._self == null) { return; } if (this.moveQueue.Count >= 2) { this.speed = this.defaultSpeed * 1.5f; } else if (this.speed != this.defaultSpeed && this.defaultSpeed != 0f) { this.speed = this.defaultSpeed; } if ((float)this.moveQueue.Count >= 3f && this.inProcess) { this.moveQueue.Clear(); this.inProcess = false; this.speed = this.defaultSpeed; } if (this.inProcess && type == 1) { if (this.moveQueue.Count > 0) { Move.QueueItem queueItem = this.moveQueue[this.moveQueue.Count - 1]; if (queueItem.action == Move.TargetAction.Skill) { if (Vector3.Distance(queueItem.target, position) < 0.5f) { return; } } else if (queueItem.action == Move.TargetAction.Move) { walkType = queueItem.walkType; this.moveQueue.RemoveAt(this.moveQueue.Count - 1); this.inProcess = false; } } else if (this.curQueueItem != null) { if (this.curQueueItem.action == Move.TargetAction.Skill) { if (Vector3.Distance(this.curQueueItem.target, position) < 0.5f) { return; } } else if (this.curQueueItem.action == Move.TargetAction.Move && this.curQueueItem.walkType != 1) { this.inProcess = false; } } } this.moveQueue.Add(new Move.QueueItem(walkType, radius, position, (Move.TargetAction)type, delegate { this.inProcess = false; if (!string.IsNullOrEmpty(module) && !string.IsNullOrEmpty(func)) { Util.CallMethod(module, func, param); } else if (callback != null) { callback(); } })); }
public void SetServerPos(Vector3 pos, float sSpeed = 0f, int type = 0, int walkType = 0, float radius = 0.1f, bool correctNow = true, Move.PathFinished callback = null) { if (this._self == null) { return; } if (correctNow) { this._self.transform.position = pos; } else { if (this._self.entityType != RoleManager.EntityType.EntityType_Self && this._self.entityType != RoleManager.EntityType.EntityType_Role) { this.speed = sSpeed; } if (this.defaultSpeed != this.speed && this.speed != 0f) { this.defaultSpeed = this.speed; } if (this._self.entityType != RoleManager.EntityType.EntityType_Self) { this.MoveEnqueue(pos, 1, walkType, radius, callback, string.Empty, string.Empty, new object[0]); } else { this.WalkTo(pos, 0.1f, type, null, true); } } }
public void Clear() { this.toMapId = 0; this.destination = Vector3.zero; this.pathFinished = null; }
private void OnJumpFinished(SceneEntity entity, Vector3 destination, Move.PathFinished pathFinished) { }