public static pathing createPathFromListVector3(List <Vector3> listVectors, string name = "pathholder", Color?color = null) { GameObject map = GameObject.FindGameObjectsWithTag("map")[0]; GameObject pathHolder = new GameObject(name); pathHolder.tag = "Player"; pathHolder.AddComponent <pathing>(); pathHolder.transform.SetParent(map.transform); pathHolder.transform.position = listVectors[0]; int i = 0; foreach (Vector3 item in listVectors) { GameObject waypoint = new GameObject("point: " + i); waypoint.transform.position = item; waypoint.transform.SetParent(pathHolder.transform); i++; } pathing script = pathHolder.GetComponent <pathing>(); //ensures color != null color.GetValueOrDefault(Color.green); script.rayColor = (Color)color; return(script); }
private bool actorInTheWay(pathing.TILE myMove, out string actorName) { bool actorInWay = false; actorName = ""; foreach (ActorHandler.Actor myActor in TheActorHandler.ActorsHashTable.Values) { ActorHandler.position myPosition = TheActorHandler.GetUserPosition(myActor.id); if (myActor.pos.x == myMove.x && myActor.pos.y == myMove.y) { actorName = TheActorHandler.GetUsernameFromID(myActor.id); actorInWay = true; break; } } return actorInWay; }