Example #1
0
        }//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
Example #2
0
        }//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
Example #3
0
        }//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
Example #4
0
        }//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
Example #5
0
        }//OnSecondButton

        public override bool CanInteract(InteractableObject.InteractionType type = InteractionType.Primary) {
            return true;
        }//CanInteract
Example #6
0
        }//OnStop

        protected virtual void CancelInteract() {
            interactTarget = null;
            interacting = false;
            navAgent.path.ClearCorners();
            OnStop();
        }//CancelInteract
Example #7
0
        }//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