// Update is called once per frame void Update() { switch (currentState) { case SquadMemberState.IDLE: // Wander around break; case SquadMemberState.INTERACTING: Interact(); break; case SquadMemberState.NAVIGATING: // If squad member is near object if (Vector3.Distance(gameObject.transform.position, currentTask.taskObject.transform.position) <= 2) { Debug.Log("NEAR OBJECT"); // Interact with object and stop moving currentState = SquadMemberState.INTERACTING; gameObject.GetComponent <AISimpleLerp>().canMove = false; } break; } /*if (isInspecting) * { * Inspect(); * currentState = SquadMemberState.INTERACTING; * }*/ currentTime += Time.deltaTime; differenceTime = currentTime - activateTime; }
public void CompleteTask() { currentTask.taskObject.GetComponent <EntityStats>().tasked = false; currentTask = null; Debug.Log(gameObject.ToString() + " state: " + currentState.ToString()); currentState = SquadMemberState.IDLE; //Debug.Log(gameObject.ToString() + " state: " + currentState.ToString()); }
public void GiveTask(Task t) { currentTask = t; currentState = SquadMemberState.NAVIGATING; // Set target position and allow squad member to move gameObject.GetComponent <AISimpleLerp>().target = t.taskObject.transform; gameObject.GetComponent <AISimpleLerp>().canMove = true; }