private void ReturnToHill() { Vector3 currentPosition = transform.position; Vector3 direction = (dropPosition - currentPosition).normalized; velocity = direction * speed; carrying.transform.position = currentPosition + carryingPosition; if (currentPosition.x > dropPosition.x - DROP_ZONE_RADIUS && currentPosition.x < dropPosition.x + DROP_ZONE_RADIUS && currentPosition.y > dropPosition.y - DROP_ZONE_RADIUS && currentPosition.y < dropPosition.y + DROP_ZONE_RADIUS && currentPosition.z > dropPosition.z - DROP_ZONE_RADIUS && currentPosition.z < dropPosition.z + DROP_ZONE_RADIUS) { carrying.transform.position = transform.position; CarriableBehavior carriableBehavior = carrying.GetComponent <CarriableBehavior>(); carriableBehavior.isStored = true; carriableBehavior.beingCarriedBy = null; carrying = null; currentAntState = AntState.SEARCH; } }
private void Search(List <GameObject> carriableList) { searchSeconds -= Time.deltaTime; if (searchSeconds <= 0.0f) { Vector3 direction = new Vector3(Random.Range(-1.0f, 1.0f), 0, Random.Range(-1.0f, 1.0f)).normalized; velocity = direction * speed; searchSeconds = Random.Range(0.0f, MAX_SEARCH_SECONDS); } foreach (GameObject carriable in carriableList) { CarriableBehavior carriableBehavior = carriable.GetComponent <CarriableBehavior>(); if (!carriableBehavior.beingApproachedBy && !carriableBehavior.beingCarriedBy && !carriableBehavior.isStored && carriableBehavior.InSearchArea(transform)) { approaching = carriable; carriableBehavior.beingApproachedBy = this; currentAntState = AntState.GET_THING; break; } } }