本文整理汇总了C#中Waypoint类的典型用法代码示例。如果您正苦于以下问题:C# Waypoint类的具体用法?C# Waypoint怎么用?C# Waypoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Waypoint类属于命名空间,在下文中一共展示了Waypoint类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: push
public void push(Waypoint w, float cost)
{
PNode node = new PNode (w, cost);
if (count == 0) {
head = node;
tail = node;
} else {
// find the place to insert
PNode curr = head;
while (curr != null && curr.cost < node.cost) {
curr = curr.next;
}
if (curr == null) {
// we are inserting at the end
tail.next = node;
node.prev = tail;
node.next = null;
tail = node;
} else if (curr == head) {
// we are insterint at the beginning
head.prev = node;
node.next = head;
node.prev = null;
head = node;
} else {
// somewhere in the middle
curr.prev.next = node;
node.prev = curr.prev;
node.next = curr;
curr.prev = node;
}
}
count++;
}
开发者ID:Morgan10E,项目名称:PewPewLightShips,代码行数:35,代码来源:PQueue.cs
示例2: CsvLoadTripRoutes
public static void CsvLoadTripRoutes(string filename, bool lngFirst)
{
// load trip routes
Dictionary<string, LinkedList<Waypoint>> routes = new Dictionary<string, LinkedList<Waypoint>>();
using (CsvFileReader reader = new CsvFileReader(filename))
{
CsvRow row = new CsvRow();
while (reader.ReadRow(row, ','))
{
string routeID = row[0];
double distance = 0;
double lat = Convert.ToDouble(lngFirst ? row[2] : row[1]);
double lng = Convert.ToDouble(lngFirst ? row[1] : row[2]);
if (routes.ContainsKey(routeID))
distance = routes[routeID].First.Value.GetDistance(new Location(lat, lng, "null"));
Waypoint waypoint = new Waypoint(lat, lng, TimeSpan.Parse(row[3]), distance, row[4].Replace("\"", ""));
// Scenario #1
if (!routes.ContainsKey(routeID))
routes[routeID] = new LinkedList<Waypoint>();
routes[routeID].AddLast(waypoint);
}
}
foreach (LinkedList<Waypoint> w in routes.Values)
{
Route r = new Route(w.ToArray());
string key = Route.GetKey(r.start, r.end);
MapTools.routes.Add(key, r);
}
}
开发者ID:TripThru,项目名称:Gateway,代码行数:31,代码来源:1397817436$MapTools.cs
示例3: Start
public override void Start()
{
base.Start ();
startRotation = -180f;
activeWaypoint = Waypoint.startingWaypoint;
player = GameObject.FindGameObjectWithTag("Player");
enemies = GameObject.FindGameObjectsWithTag("Enemy");
for (int i = 0; i < enemies.Length; i++)
if (enemies[i] == this.gameObject)
enemies[i] = player;
obstacles = GameObject.FindGameObjectsWithTag("Terrain");
timeToDestroy = 0.0f;
rotation += startRotation;
syncStartPosition = GetComponent<Rigidbody>().position;
syncEndPosition = GetComponent<Rigidbody>().position;
syncStartRotation = GetComponent<Rigidbody>().rotation;
syncEndRotation = GetComponent<Rigidbody>().rotation;
nextBurst = true;
burstTime = 0.0f;
flare = turboFlare.GetComponent<ParticleSystem> ();
core = turboCore.GetComponent<ParticleSystem> ();
flare.startSize = 2.0f;
core.startSize = 2.0f;
flare.startRotation = transform.eulerAngles.y *Mathf.Deg2Rad;
core.startRotation = transform.eulerAngles.y *Mathf.Deg2Rad;
turboFlare.SetActive (false);
turboCore.SetActive (false);
}
开发者ID:brikp,项目名称:HoverRally_scripts,代码行数:28,代码来源:EnemyController.cs
示例4: Update
void Update()
{
if (Input.GetMouseButtonDown(0))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
Waypoint waypoint = hit.collider.GetComponent<Waypoint>();
if (waypoint != null)
{
path = graphManager.GetPath(currentWaypoint, waypoint);
}
}
}
if (path != null &&
path.Count > 0 &&
Vector3.Distance(transform.position, currentWaypoint.transform.position) < reachThreshold)
{
currentWaypoint = path[0];
path.RemoveAt(0);
}
transform.position = Vector3.Lerp(transform.position, currentWaypoint.transform.position, lerpRatio * Time.deltaTime);
}
开发者ID:KoltesDigital,项目名称:Unity-ICAN-2016,代码行数:26,代码来源:PlayerBehavior.cs
示例5: Waypoint
public Waypoint(long timeVal, Tile tileVal, Waypoint prevVal, List<UnitSelection> startVal)
{
time = timeVal;
tile = tileVal;
prev = prevVal;
start = startVal;
}
开发者ID:ad510,项目名称:plausible-deniability,代码行数:7,代码来源:Waypoint.cs
示例6: OnTriggerEnter
public override void OnTriggerEnter(Collider trigger)
{
base.OnTriggerEnter (trigger);
if (activeWaypoint.GetComponent<Collider>() == trigger) {
activeWaypoint = activeWaypoint.getNextWaypoint();
}
}
开发者ID:brikp,项目名称:HoverRally_scripts,代码行数:7,代码来源:EnemyController.cs
示例7: CreateMajorRoutes
private string CreateMajorRoutes(string locationString)
{
string results = "";
string key = "ArLeGdHOcc5h7j3L4W37oFGcU9E-LF3tAZi4o0DfhXbPJ8aiyTGbIDNHex08R2u7";
MajorRoutesRequest majorRoutesRequest = new MajorRoutesRequest();
// Set the credentials using a valid Bing Maps key
majorRoutesRequest.Credentials = new RouteService.Credentials();
majorRoutesRequest.Credentials.ApplicationId = key;
// Set the destination of the routes from major roads
Waypoint endPoint = new Waypoint();
endPoint.Location = new RouteService.Location();
string[] digits = locationString.Split(',');
endPoint.Location.Latitude = double.Parse(digits[0].Trim());
endPoint.Location.Longitude = double.Parse(digits[1].Trim());
endPoint.Description = "Location";
// Set the option to return full routes with directions
MajorRoutesOptions options = new MajorRoutesOptions();
options.ReturnRoutes = true;
majorRoutesRequest.Destination = endPoint;
majorRoutesRequest.Options = options;
// Make the route-from-major-roads request
RouteServiceClient routeService = new RouteServiceClient("BasicHttpBinding_IRouteService");
// The result is an MajorRoutesResponse Object
MajorRoutesResponse majorRoutesResponse = routeService.CalculateRoutesFromMajorRoads(majorRoutesRequest);
Regex regex = new Regex("<[/a-zA-Z:]*>",
RegexOptions.IgnoreCase | RegexOptions.Multiline);
if (majorRoutesResponse.StartingPoints.Length > 0)
{
StringBuilder directions = new StringBuilder();
for (int i = 0; i < majorRoutesResponse.StartingPoints.Length; i++)
{
directions.Append(String.Format("Coming from {1}\n", i + 1,
majorRoutesResponse.StartingPoints[i].Description));
for (int j = 0;
j < majorRoutesResponse.Routes[i].Legs[0].Itinerary.Length; j++)
{
//Strip tags
string step = regex.Replace(
majorRoutesResponse.Routes[i].Legs[0].Itinerary[j].Text, string.Empty);
directions.Append(String.Format(" {0}. {1}\n", j + 1, step));
}
}
results = directions.ToString();
}
else
results = "No Routes found";
return results;
}
开发者ID:ali-fatolahi,项目名称:Ali_Saeed,代码行数:60,代码来源:DefaultMap.aspx.cs
示例8: ShortestPath
public List<Waypoint> ShortestPath(Waypoint a, Waypoint b)
{
Dictionary<Waypoint, Waypoint> cameFrom = new Dictionary<Waypoint, Waypoint> ();
Dictionary<Waypoint, float> costSoFar = new Dictionary<Waypoint, float> ();
PQueue frontier = new PQueue();
cameFrom[a] = null;
costSoFar [a] = 0f;
frontier.push (a, 0);
while (!frontier.empty ()) {
Waypoint current = frontier.pop ();
if (current == b)
break;
foreach (Waypoint next in current.connections) {
float newCost = costSoFar [current] + Waypoint.distance (current, next);
if (!costSoFar.ContainsKey(next) || newCost < costSoFar[next]) {
costSoFar [next] = newCost;
frontier.push (next, newCost);
cameFrom [next] = current;
}
}
}
List<Waypoint> path = new List<Waypoint> ();
Waypoint point = b;
while (point != a) {
path.Add (point);
point = cameFrom[point];
}
path.Add (a);
path.Reverse ();
return path;
}
开发者ID:Morgan10E,项目名称:PewPewLightShips,代码行数:32,代码来源:WaypointGraph.cs
示例9: GetRoadTime
public long GetRoadTime(Point[] points)
{
DBC.Assert(points.Length == 2, "Calculating road time requires exactly 2 points. " + points.Length + " were provided.");
var cacheResult = routeCache.GetTime(points[0].address, points[1].address);
if (cacheResult != null)
{
Log(points, true);
return cacheResult.Value;
}
Log(points, false);
var router = new RouteServiceClient();
var request = new RouteRequest();
request.Credentials = new Credentials();
request.Credentials.Token = GetToken();
request.Waypoints = new Waypoint[points.Length];
for (int i = 0; i < points.Length; i++)
{
var p = points[i];
var waypoint = new Waypoint();
waypoint.Description = p.address;
waypoint.Location = new Location();
waypoint.Location.Latitude = p.lat;
waypoint.Location.Longitude = p.lon;
request.Waypoints[i] = waypoint;
}
RouteResponse response = router.CalculateRoute(request);
var seconds = response.Result.Summary.TimeInSeconds;
routeCache.Add(points, seconds);
return seconds;
}
开发者ID:liammclennan,项目名称:shortest-path,代码行数:35,代码来源:RoadPathService.cs
示例10: MoveToWaypoit
void MoveToWaypoit(Waypoint waypoint)
{
//als de waypoint afstand kleiner is als 0.1 dan haal nieuwe waypoint op
if (Vector2.Distance(waypoint.gameObject.transform.position, this.transform.position) < 0.1)
{
this.targetWaypoint = waypoint.NextWaypoint;
}
else
{
//reken de vector richting de waypoint uit
Vector2 vectorRichtingWaypoint = waypoint.transform.position - this.transform.position;
//normalize deze vector(dat betekend dat de lengte van de vector terug naar 1 gebracht word)
vectorRichtingWaypoint.Normalize();
//vermenigvuldig deze vector met de (speed*deltatime) die we willen hebben(dit betekend de lengte van de vector word nu zo groot als de speed*detltatime)
vectorRichtingWaypoint *= Speed * Time.fixedDeltaTime;
//voeg deze nieuwe vector aan onze positie en we bewegen richting de waypoint
this.transform.position += new Vector3(vectorRichtingWaypoint.x, vectorRichtingWaypoint.y);
//convert v3 naar v2
Vector2 thispos = new Vector2(this.transform.position.x, this.transform.position.y);
this.drawLineTo(this.movementLine, this.transform.position, thispos + vectorRichtingWaypoint.normalized * Speed);
this.bewegingsVector = vectorRichtingWaypoint;
}
}
开发者ID:Kickerino,项目名称:TowerDefenceDebug,代码行数:25,代码来源:Enemy.cs
示例11: AddRotationWaypoint
public void AddRotationWaypoint()
{
GameObject go = new GameObject();
go.AddComponent("RotationWaypoint");
Waypoint w = go.GetComponent<Waypoint>();
w.manager = this;
if (count > 0) {
if (last != null) {
go.transform.position = last.transform.position;
last.next = w;
last = w;
} else {
last = first;
while (last.next != null) {
last = last.next;
}
go.transform.position = last.transform.position;
last.next = w;
last = w;
}
} else {
first = w;
last = w;
go.transform.position = transform.position;
}
count++;
Selection.activeObject = go;
go.name = "Waypoint " + count + " (rotation)";
go.transform.parent = transform;
}
开发者ID:GameResearchAtMcGill,项目名称:Visual,代码行数:30,代码来源:WaypointManager.cs
示例12: Start
// Use this for initialization
void Start()
{
animation.Play();
myController = GetComponent<CharacterController>();
initialPosition = transform.position;
initialWaypoint = waypoint;
}
开发者ID:abelsiqueira,项目名称:medrash-assets,代码行数:8,代码来源:Fugitive.cs
示例13: Reset
public void Reset()
{
m_isMoving = false;
m_levelStartWp = null;
m_levelEndWp = null;
m_nextWaypoint = null;
}
开发者ID:EricEspinoza,项目名称:GalleryRailShooter,代码行数:7,代码来源:CameraMove.cs
示例14: Connect
public void Connect(Waypoint other)
{
if (other == null)
throw new ArgumentNullException("other");
this.AddNeighbour(other);
other.AddNeighbour(this);
}
开发者ID:rharel,项目名称:unity-pacman,代码行数:8,代码来源:Waypoint.cs
示例15: StationaryPointParameter
// Game freaks out without a default constructor. I never use it.
public StationaryPointParameter()
{
targetBody = Planetarium.fetch.Home;
longitude = 0.0;
wp = new Waypoint();
submittedWaypoint = false;
this.successCounter = 0;
}
开发者ID:stanbeard,项目名称:FinePrint,代码行数:9,代码来源:StationaryPointParameter.cs
示例16: ResumeMovement
public override void ResumeMovement(Transform target)
{
if (target == null)
{
CurrWaypoint = waypointManager.GetWaypoint(this.gameObject);
this.target = CurrWaypoint.transform;
}
}
开发者ID:stevesolomon,项目名称:MicroDungeonPrototype,代码行数:8,代码来源:MovementToWaypoint.cs
示例17: CanSeePlayer
private bool CanSeePlayer(Waypoint waypoint)
{
RaycastHit2D hit = MazeManager.RayCast(
CurrentPosition, waypoint, waypoint.Position - CurrentPosition,
VISION_ANGLE_LIMIT, PLAYER_LAYER_MASK);
return hit.collider != null;
}
开发者ID:rharel,项目名称:unity-pacman,代码行数:8,代码来源:GhostMovementController.cs
示例18: decideNextPatrolPoint
private void decideNextPatrolPoint()
{
// Keep track of the previous patrol point to prevent backtracking
previousWaypoint = parent.CurrentWaypoint;
// Set our target to go to
parent.FinalTargetWaypoint = parent.CurrentWaypoint.GetRandomNeighbour(previousWaypoint);
}
开发者ID:Pycorax,项目名称:SP4Unity,代码行数:8,代码来源:PatrolState.cs
示例19: WalkingQueue
private int waypointWriteOffset = 0; //location where it can write next waypoint in array.
#endregion Fields
#region Constructors
public WalkingQueue(Player player)
{
this.player = player;
for(int i = 0; i < MAX_WALKING_WAYPOINTS; i++)
walkingQueue[i] = new Waypoint(0, 0, -1);
this.lastDirection = 6;
resetWalkingQueue();
}
开发者ID:Krill156,项目名称:SharpEMU,代码行数:14,代码来源:WalkingQueue.cs
示例20: Start
float targInnaccuracy = 2f; // Extra innaccuray to simulate mouse hand shake or something
// Use this for initialization
void Start () {
netChar = GetComponent<NetworkCharacter>();
if(waypoints == null) {
waypoints = GameObject.FindObjectsOfType<Waypoint>();
}
destination = GetClosestWaypoint();
}
开发者ID:kleptodorf,项目名称:Unity-Learning,代码行数:12,代码来源:BotController.cs
注:本文中的Waypoint类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论