}//Awake protected void Update() { if (interactTarget != null) { if (interacting) { if (interactionTime > timeToInteract) { interactTarget.Interact(interactionType); interactTarget = null; interacting = false; indicator.Hide(); OnInteract(); } else { interactionTime += Time.deltaTime; } } else { if (Vector3.Distance(transform.position, interactTarget.transform.position) < interactRange) { if (interactTarget.CanInteract()) { interacting = true; navAgent.path.ClearCorners(); OnStop(); indicator.ShowIcon(); } else { CancelInteract(); } } } } }//Update
}//UpdateAnimation public void SetInteractionTarget(InteractableObject obj, InteractableObject.InteractionType type = InteractableObject.InteractionType.Primary, float timeToComplete = 0f) { interactTarget = obj; interactionType = type; navAgent.SetDestination(obj.transform.position); interacting = false; interactionTime = 0f; timeToInteract = timeToComplete; }//SetInteractionTarget
}//OnFirstButton public override bool CanInteract(InteractableObject.InteractionType type = InteractionType.Primary) { if (type == InteractionType.Primary) { if (Top.GAME.playerCharacter.IsHoldingObject()) { return true; } else { Top.GAME.SetMessageText("You have nothing to use!", Color.red); Top.GAME.PlayGlobalSound(Top.GAME.GetRandomSound("robotError")); return false; } } return true; }//CanInteract
}//Reset public new void SetInteractionTarget(InteractableObject obj, InteractableObject.InteractionType type = InteractableObject.InteractionType.Primary, float timeToComplete = 0f) { UpdateMoveIndicator(obj.transform.position); base.SetInteractionTarget(obj, type, timeToComplete); PlaySound(Top.GAME.GetRandomSound("robotMove")); PlaySound(Top.GAME.GetRandomSound("robotMoveLoop"), 1); }//SetInteractionTarget
}//OnSecondButton public override bool CanInteract(InteractableObject.InteractionType type = InteractionType.Primary) { return true; }//CanInteract
}//OnStop protected virtual void CancelInteract() { interactTarget = null; interacting = false; navAgent.path.ClearCorners(); OnStop(); }//CancelInteract
}//Interact public override void Interact(InteractableObject.InteractionType type = InteractionType.Primary) { FindObjectOfType<ObjectUIController>().UnsetObject(); Contain(); }//Interact
public void Spawn() { spawnInstance = GameObject.Instantiate<InteractableObject>(objectToSpawn); spawnInstance.transform.position = transform.position; spawnInstance.transform.SetParent(spawnParent); }//Spawn