public static void InitNavigation(List <System> eveSystems, List <JumpBridge> jumpBridges) { MapNodes = new Dictionary <string, MapNode>(); TheraLinks = new List <string>(); // build up the nav structures foreach (System sys in eveSystems) { MapNode mn = new MapNode { Name = sys.Name, HighSec = sys.TrueSec > 0.45, Connections = new List <string>(), JumpableSystems = new List <JumpLink>(), Cost = 1, MinCostToStart = 0, X = sys.ActualX, Y = sys.ActualY, Z = sys.ActualZ, F = 0 }; foreach (string s in sys.Jumps) { mn.Connections.Add(s); } MapNodes[mn.Name] = mn; } UpdateJumpBridges(jumpBridges); double MaxRange = 10 * 9460730472580800.0; // now create the jumpable system links foreach (MapNode mn in MapNodes.Values) { foreach (System sys in eveSystems) { // cant jump into highsec systems if (sys.TrueSec > 0.45) { continue; } double Distance = EveManager.Instance.GetRangeBetweenSystems(sys.Name, mn.Name); if (Distance < MaxRange && Distance > 0) { JumpLink jl = new JumpLink(); jl.System = sys.Name; jl.RangeLY = Distance / 9460730472580800.0; mn.JumpableSystems.Add(jl); } } } }
void CalcuJumpLink(Vector3 offPoint, Vector3 startSpeed, bool isLeft) { List <Vector2> jumpNodes = new List <Vector2>(); Vector2 tempPoint = (Vector2)offPoint; Vector2 speed = (Vector2)startSpeed; if (!isLeft) { speed = new Vector2(-speed.x, speed.y); } int cnt = maxIteration; while (cnt > 0) { jumpNodes.Add(tempPoint); test_points.Add((Vector3)tempPoint); test_dirs.Add((Vector3)speed * interval); RaycastHit2D hit; hit = Physics2D.Raycast(tempPoint, speed * interval, speed.magnitude * interval); if (hit) { jumpNodes.Add(tempPoint); test_points.Add((Vector3)tempPoint); test_dirs.Add((Vector3)speed * interval); if (hit.normal == Vector2.up) { result.Add(new JumpLink(offPoint, startSpeed, isLeft, 0)); print("goal"); } else { print("side"); } hitpoint = (Vector3)hit.point; break; } tempPoint += speed * interval; speed += Physics2D.gravity * interval; RaycastHit2D hitVerti; hitVerti = Physics2D.Raycast(tempPoint + speed * interval, Vector2.down, jumpOffsetVerti); if (hitVerti) { jumpNodes.Add(tempPoint); test_points.Add((Vector3)tempPoint); JumpLink jumplink = new JumpLink(offPoint, startSpeed, isLeft, 0); jumplink.jumpNodes = jumpNodes.ToArray(); result.Add(jumplink); print("goal_verti"); hitpoint = (Vector3)hit.point; break; } cnt--; } }
// Use this for initialization void Start() { cntJN = 0; jumplink = navMngr.result[0]; isGrounded = false; rigidbody = GetComponent <Rigidbody2D>(); rigidbody.isKinematic = true; nextJN = transform.position; currentJN = transform.position; //StartCoroutine(IterateNodeTimer(1f, jumplink.jumpNodes.Length)); }
private void Start() { CircleCollider2D startCollider = start.gameObject.AddComponent <CircleCollider2D> (); startCollider.radius = agentRadius * 0.5f; startCollider.isTrigger = true; if (biDirectional) { JumpLink link = end.gameObject.AddComponent <JumpLink>(); link.traverseTime = traverseTime; link.start = end; link.end = start; link.agentRadius = agentRadius; } }