Beispiel #1
0
        /** Use this for initialization */
        public void Start () {
            seeker = GetComponent<Seeker>();
            controller = GetComponent<CharacterController>();
            navmeshController = GetComponent<NavmeshController>();
		
            tr = transform;
            Repath ();
        }
Beispiel #2
0
		public void OnDestroy (Seeker s) {
			if (s != null) {
				s.DeregisterModifier (this);
			}
		}
Beispiel #3
0
		public void Awake (Seeker s) {
			seeker = s;
			if (s != null) {
				s.RegisterModifier (this);
			}
		}
Beispiel #4
0
		/** Alerts the Seeker that this modifier exists */
		public void Awake () {
#if !PhotonImplementation
			seeker = GetComponent<Seeker>();
#endif

			if (seeker != null) {
				seeker.RegisterModifier (this);
			}
		}
Beispiel #5
0
        /** Initializes reference variables.
	 * If you override this function you should in most cases call base.Awake () at the start of it.
	  * */
        protected virtual void Awake () {
            seeker = GetComponent<Seeker>();

            //This is a simple optimization, cache the transform component lookup
            tr = transform;

            //Cache some other components (not all are necessarily there)
            controller = GetComponent<CharacterController>();
            navController = GetComponent<NavmeshController>();
            rvoController = GetComponent<RVOController>();
            if ( rvoController != null ) rvoController.enableRotation = false;
            rigid = GetComponent<Rigidbody>();
        }
Beispiel #6
0
		/** Use this for initialization.
		 *
		 * \param s Optionally provide in order to take tag penalties into account. May be null if you do not use a Seeker\
		 * \param p Path to follow
		 * \param mergePartEndpoints If true, then adjacent parts that the path is split up in will
		 * try to use the same start/end points. For example when using a link on a navmesh graph
		 * Instead of first following the path to the center of the node where the link is and then
		 * follow the link, the path will be adjusted to go to the exact point where the link starts
		 * which usually makes more sense.
		 * \param simplificationMode The path can optionally be simplified. This can be a bit expensive for long paths.
		 */
		public void Initialize (Seeker s, Path p, bool mergePartEndpoints, RichFunnel.FunnelSimplification simplificationMode) {

			if (p.error) throw new System.ArgumentException ("Path has an error");

			List<GraphNode> nodes = p.path;
			if (nodes.Count == 0) throw new System.ArgumentException ("Path traverses no nodes");

			seeker = s;
			// Release objects back to object pool
			// Yeah, I know, it's casting... but this won't be called much
			for (int i=0;i<parts.Count;i++) {
				     if (parts[i] is RichFunnel) ObjectPool<RichFunnel>.Release (parts[i] as RichFunnel);
				else if (parts[i] is RichSpecial) ObjectPool<RichSpecial>.Release (parts[i] as RichSpecial);
			}

			parts.Clear();
			currentPart = 0;

			// Initialize new

			//Break path into parts
			for (int i=0;i<nodes.Count;i++) {
				if (nodes[i] is TriangleMeshNode) {
					var funnelGraph = AstarData.GetGraph (nodes[i]) as IFunnelGraph;

					RichFunnel f = ObjectPool<RichFunnel>.Claim ().Initialize (this, funnelGraph);

					f.funnelSimplificationMode = simplificationMode;

					int sIndex = i;
					uint currentGraphIndex = nodes[sIndex].GraphIndex;


					for (; i < nodes.Count; i++) {
						if (nodes[i].GraphIndex != currentGraphIndex && !(nodes[i] is NodeLink3Node) ) {
							break;
						}
					}
					i--;

					if (sIndex == 0) {
						f.exactStart = p.vectorPath[0];
					} else {
						f.exactStart = (Vector3)nodes[mergePartEndpoints ? sIndex-1 : sIndex].position;
					}

					if (i == nodes.Count-1) {
						f.exactEnd = p.vectorPath[p.vectorPath.Count-1];
					} else {
						f.exactEnd = (Vector3)nodes[mergePartEndpoints ? i+1 : i].position;
					}

					f.BuildFunnelCorridor (nodes, sIndex, i);

					parts.Add (f);
				} else if (NodeLink2.GetNodeLink(nodes[i]) != null) {

					NodeLink2 nl = NodeLink2.GetNodeLink(nodes[i]);

					int sIndex = i;
					uint currentGraphIndex = nodes[sIndex].GraphIndex;

					for (i++; i < nodes.Count; i++) {
						if (nodes[i].GraphIndex != currentGraphIndex) {
							break;
						}
					}
					i--;

					if (i - sIndex > 1) {
						throw new System.Exception("NodeLink2 path length greater than two (2) nodes. " + (i - sIndex));
					} else if (i - sIndex == 0) {
						//Just continue, it might be the case that a NodeLink was the closest node
						continue;
					}

					RichSpecial rps = ObjectPool<RichSpecial>.Claim().Initialize (nl, nodes[sIndex]);
					parts.Add(rps);
				}
			}
		}
Beispiel #7
0
		void Awake () {
			seeker = GetComponent<Seeker>();
			controller = GetComponent<CharacterController>();
			rvoController = GetComponent<RVOController>();
			if ( rvoController != null ) rvoController.enableRotation = false;
			tr = transform;
		}
 public void Awake () {
     seeker = GetComponent<Seeker> ();
 }