Example #1
0
	public override bool checkProceduralPrecondition (GameObject agent)
	{
		// find the nearest rock that we can mine
		IronRockComponent[] rocks = FindObjectsOfType ( typeof(IronRockComponent) ) as IronRockComponent[];
		IronRockComponent closest = null;
		float closestDist = 0;
		
		foreach (IronRockComponent rock in rocks) {
			if (closest == null) {
				// first one, so choose it for now
				closest = rock;
				closestDist = (rock.gameObject.transform.position - agent.transform.position).magnitude;
			} else {
				// is this one closer than the last?
				float dist = (rock.gameObject.transform.position - agent.transform.position).magnitude;
				if (dist < closestDist) {
					// we found a closer one, use it
					closest = rock;
					closestDist = dist;
				}
			}
		}
		targetRock = closest;
		target = targetRock.gameObject;
		
		return closest != null;
	}
Example #2
0
 public override void reset()
 {
     mined      = false;
     targetRock = null;
     startTime  = 0;
 }
Example #3
0
	public override void reset ()
	{
		mined = false;
		targetRock = null;
		startTime = 0;
	}
Example #4
0
 /// <summary>
 /// Resets the action to its default values, so it can be used again.
 /// </summary>
 public override void Reset()
 {
     _mined      = false;
     _targetRock = null;
     StartTime   = 0;
 }