//------------------------------------------------- // All shape management functions (add shapes, save shapes to metadata etc. //------------------------------------------------- public void AddShape(Vector3 shapePosition, Quaternion shapeRotation, int shapeType, string Shapename) { ShapeInfo shapeInfo = new ShapeInfo(); shapeInfo.px = shapePosition.x; shapeInfo.py = shapePosition.y; shapeInfo.pz = shapePosition.z; shapeInfo.qx = shapeRotation.x; shapeInfo.qy = shapeRotation.y; shapeInfo.qz = shapeRotation.z; shapeInfo.qw = shapeRotation.w; shapeInfo.shapeType = shapeType.GetHashCode(); shapeInfo.name = Shapename; shapeInfo.infoIndex = inputmanager.index; shapeInfo.linkMapID = inputmanager.LinkID; shapeInfoList.Add(shapeInfo); Debug.Log(shapeInfo.name); GameObject shape = ShapeFromInfo(shapeInfo, false); // instantiate shape from info NodeCount++; DestinationTarget temp = shape.GetComponent <DestinationTarget>(); if (temp != null) { NodeCount--; } shapeObjList.Add(shape); inputmanager.ResetNameAndIndex(); }
void VisitNextPatrolPathDestination() { if (PatrolPath.Count > 0) { DestinationTarget destinationTarget = new DestinationTarget(PatrolPath[++CurrentPatrolPathDestinationIndex % PatrolPath.Count], null); SetDestinationTarget(destinationTarget); } }
public override void SetDestinationTarget(DestinationTarget destinationTarget) { Destination = TransformCached.position; NextDestinations.Clear(); Vector3 dest = destinationTarget.Destination; RaycastHit hit = new RaycastHit(); if (Physics.Raycast(TransformCached.position, TransformCached.forward, out hit)) { dest = new Vector3(hit.point.x, hit.transform.root.position.y, hit.point.z); } NextDestinations.Push(dest); Target = destinationTarget.Target; }
//------------------------------------------------- // All shape management functions (add shapes, save shapes to metadata etc. //------------------------------------------------- public void AddShape(Vector3 shapePosition, Quaternion shapeRotation, bool isDestination, string name) { int typeIndex = 0; //sphere if (isDestination) { typeIndex = 1; //diamond } Debug.Log(typeIndex); ShapeInfo shapeInfo = new ShapeInfo(); shapeInfo.px = shapePosition.x; shapeInfo.py = shapePosition.y; shapeInfo.pz = shapePosition.z; shapeInfo.qx = shapeRotation.x; shapeInfo.qy = shapeRotation.y; shapeInfo.qz = shapeRotation.z; shapeInfo.qw = shapeRotation.w; shapeInfo.shapeType = typeIndex.GetHashCode(); shapeInfo.name = name; shapeInfo.infoIndex = inputmanager.index; shapeInfo.linkMapID = inputmanager.LinkID; shapeInfoList.Add(shapeInfo); Debug.Log(shapeInfo.name); GameObject shape = ShapeFromInfo(shapeInfo, false); // instantiate shape from info NodeCount++; DestinationTarget temp = shape.GetComponent <DestinationTarget>(); if (temp != null) { NodeCount--; /*temp.Activate(true); * temp.DestinationName = name; * temp.linkMapID = inputmanager.LinkID;*/ } shapeObjList.Add(shape); inputmanager.ResetNameAndIndex(); }
public virtual void SetDestinationTarget(DestinationTarget destinationTarget) { List <Vector3> path = PathFinder.Dijkstra(LevelManager.CurrentLevel, TransformCached.position, LevelManager.LevelGridCoords(destinationTarget.Destination)); if (path.Count < 1) { HandleNoPathToDestination(); } else { path.Add(TransformCached.position); path = PathFinder.SmoothenPath(path); path[0] = destinationTarget.Destination; Destination = TransformCached.position; NextDestinations.Clear(); foreach (Vector3 point in path) { NextDestinations.Push(point); } Target = destinationTarget.Target; } }
void Start() { nameText = GetComponent <TextMeshProUGUI>(); destination = GetComponentInParent <DestinationTarget>(); nameText.text = destination.DestinationName; }
public override void SetDestinationTarget(DestinationTarget destinationTarget) { base.SetDestinationTarget(destinationTarget); remainingRestTimeSeconds = RestTimeSeconds; }