public void trackTarget(LabelHandle target)
 {
     trackedTargets.Add(target);
     target.getPosition();
     foreach (InherentEndeavourFactory factory in inherentEndeavours)
     {
         if (factory.isApplicable(target))
         {
             Endeavour action = factory.constructEndeavour(this, target);
             if (action != null)
             {
                 availableEndeavours.Add(action);
                 dirty = true;
             }
         }
     }
     if (target.label != null)
     {
         foreach (Endeavour action in target.label.getAvailableEndeavours(this))
         {
             availableEndeavours.Add(action);
             dirty = true;
         }
     }
 }
 public void updateInfo(LabelHandle target)
 {
     if (getSightings() > 0) {
         updatePosition(target.getPosition());
         updateTime(System.DateTime.Now);
         updateAttachedTags(target.getTags());
         if (target.getDirection() != null) {
             updateDirection(target.getDirection());
         }
     }
 }
示例#3
0
    private void goToTarget()
    {
        if (target != null)
        {
            if (hasReachedTargetLocation())
            {
                if (!hasMatchedTargetRotation())
                {
                    roboController.transform.rotation = Quaternion.RotateTowards(Quaternion.LookRotation(roboController.transform.forward), Quaternion.LookRotation(target.label.transform.forward), nav.angularSpeed * Time.deltaTime);
                }
                else
                {
                    roboController.enqueueMessage(new RobotMessage(RobotMessage.MessageType.ACTION, "target reached", target, target.getPosition(), null));
                    target = null;
                    return;
                }
            }

            if (nav.enabled)
            {
                nav.speed = regularSpeed;
                nav.SetDestination(target.getPosition());

#if UNITY_EDITOR
                if (roboController.debug)
                {
                    Destroy(dest);
                    GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                    cube.transform.position = target.getPosition();
                    cube.GetComponent <MeshRenderer>().material.color = Color.green;
                    Destroy(cube.GetComponent <BoxCollider>());
                    cube.transform.localScale = new Vector3(.3f, .3f, .3f);
                    dest = cube;
                }
#endif
            }
        }
    }
示例#4
0
	private bool hasReachedTargetLocation(LabelHandle targetLocation) {
		float xzDist = Vector2.Distance(new Vector2(roboController.transform.position.x, roboController.transform.position.z),
								new Vector2(targetLocation.getPosition().x, targetLocation.getPosition().z));
		float yDist = Mathf.Abs((roboController.transform.position.y - .4f) - targetLocation.getPosition().y);
		if(xzDist < .5f && yDist < .8f) {
			return true;
		}
		return false;
	}
    public void trackTarget(LabelHandle target)
    {
        trackedTargets.Add(target);
        target.getPosition();
        foreach(InherentEndeavourFactory factory in inherentEndeavours) {
            if(factory.isApplicable(target)) {
                Endeavour action = factory.constructEndeavour(this, target);
                if(action != null) {
                    availableEndeavours.Add(action);
                    dirty = true;

                }
            }
        }
        if(target.label != null) {
            foreach(Endeavour action in target.label.getAvailableEndeavours(this)) {
                availableEndeavours.Add(action);
                dirty = true;

            }
        }
    }