Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 5
0
        }//OnSecondButton

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

        protected virtual void CancelInteract() {
            interactTarget = null;
            interacting = false;
            navAgent.path.ClearCorners();
            OnStop();
        }//CancelInteract
Esempio n. 7
0
        }//Interact

        public override void Interact(InteractableObject.InteractionType type = InteractionType.Primary) {
            FindObjectOfType<ObjectUIController>().UnsetObject();
            Contain();
        }//Interact
Esempio n. 8
0
 public void Spawn() {
     spawnInstance = GameObject.Instantiate<InteractableObject>(objectToSpawn); 
     spawnInstance.transform.position = transform.position; 
     spawnInstance.transform.SetParent(spawnParent);
 }//Spawn