public virtual void InteractionMouseClick(PointerEventData data)
        {
            string gameObjectTag = data.pointerPress.tag;


            if (gameObjectTag.Equals(interactableTag))
            {
                // GameObject should has Interactable controller attached to it because it is tagged as such.
                InteractionTrigger interactable = data.pointerPress.GetComponent <InteractionTrigger>();

                // If null, stop executing the method and inform
                if (!interactable)
                {
                    Debug.Log("No Interactable Trigger Component attached to GameObject: " + data.pointerPress.name);
                }
                else
                {
                    OnImmediateInteractableClick(interactable, data.clickCount);
                }
            }
            else
            {
                Debug.Log("No Interactable, Walkable or UnWalkable GameObject clicked: " + data.pointerPress.name);
            }
        }
Esempio n. 2
0
 private void hurtPlayer(bool triggered, InteractionTrigger trigger)
 {
     if (!triggered || !Origin)
     {
         return;
     }
 }
 void RotateObject(bool triggered, InteractionTrigger trigger)
 {
     if (coroutine == null)
     {
         coroutine = StartCoroutine(rotate(trigger.transform));
     }
 }
Esempio n. 4
0
    public ActivateArtifactState()
    {
        foundMonument               = false;
        buttonPressed               = false;
        artifactAssembled           = false;
        artifactActivator           = GameManager.GetArtifactActivator();
        findMonumentTrigger         = artifactActivator.GetComponentInChildren <StateTrigger>().gameObject.GetComponent <BoxCollider>();
        findMonumentTrigger.enabled = true;
        artifactPieces              = GameObject.FindGameObjectsWithTag("ArtifactPieceActivator");
        button = artifactActivator.GetComponentInChildren <ArtifactButton>();
        button.SetState(this);
        pickupArtifactTrigger = artifactActivator.GetComponentInChildren <InteractionTrigger>();
        pickupArtifactTrigger.SetObserver(this);

        //Calculate centroid
        artifactPosition = new Vector3(
            (artifactPieces[0].transform.parent.position.x + artifactPieces[1].transform.parent.position.x + artifactPieces[2].transform.parent.position.x) / 3,
            (artifactPieces[0].transform.parent.position.y + artifactPieces[1].transform.parent.position.y + artifactPieces[2].transform.parent.position.y) / 3 + 2f,
            (artifactPieces[0].transform.parent.position.z + artifactPieces[1].transform.parent.position.z + artifactPieces[2].transform.parent.position.z) / 3);
        artifactRotation = Quaternion.Euler(0f, 90f, 0f);

        //Save initial transform
        for (int i = 0; i < artifactPieces.Length; i++)
        {
            artifactStartPositions.Add(artifactPieces[i].transform.position);
            artifactStartRotations.Add(artifactPieces[i].transform.rotation);
            artifactPillars.Add(new ArtifactPillar(artifactPieces[i].transform.parent.gameObject, i, this));
        }
    }
Esempio n. 5
0
        private void calculateWaypoint()
        {
            // If time has passed, try to get another waypoint to make the npc goes to it.
            if (Time.time > nextMoveTime && currentInteractable == null && interactableList.Length > 0)
            {
                //Try to move
                Debug.Log("inside calculating waypoint");
                int nextIndex;

                if (randomWaypointOrder)
                {
                    do
                    {
                        nextIndex = Random.Range(0, interactableList.Length);
                    } while (nextIndex == currentInteractableIndex);
                }
                else
                {
                    //No randomized behaviour, so move to next waypoint
                    nextIndex = (currentInteractableIndex + 1) % interactableList.Length;
                }

                currentInteractableIndex = nextIndex;
                //Set the destination position to start moving the player towards it
                currentInteractable             = interactableList[currentInteractableIndex];
                npcMovement.destinationPosition = currentInteractable.interactionLocation;

                // And if time is randomized, get a new waiting time
                if (randomWaitingTime)
                {
                    secondsAtWaypoint = Random.Range(min, max);
                }
            }
        }
Esempio n. 6
0
        /********************* IPointNClick Interface Methods ********************/
        public override void OnReachableInteractableClick(InteractionTrigger interactable, int numCliks)
        {
            // If the handle input flag is set to false then do nothing.
            if (!handleInput || inputMode == INPUT_MODE.GAMEPAD)
            {
                return;
            }

            // Store the interactble that was clicked on.
            if (!interactable.autoReact)
            {
                currentInteractable = interactable;
            }

            // Set the destination to the interaction location of the interactable.
            PlayerMovement3D_PNC pmPNC = playerMovement as PlayerMovement3D_PNC;

            // Agent speed
            if (numCliks == 1)
            {
                pmPNC.agent.speed = pmPNC.walkSpeed;
            }
            else if (numCliks == 2)
            {
                pmPNC.agent.speed = pmPNC.runSpeed;
            }

            // Agent destination
            pmPNC.setDestination(interactable.interactionLocation.position);
        }
 void Start()
 {
     interactionsDataBase = FindObjectOfType <InteractionsDataBase>();
     trigger = transform.parent.GetComponentInChildren <InteractionTrigger>();
     notifier.SetActive(false);
     androidNotifier.SetActive(false);
 }
        void LateUpdate()
        {
            // Find the closest InteractionTrigger that the character is in contact with
            int closestTriggerIndex = interactionSystem.GetClosestTriggerIndex();

            // Tick the timer if we are looking at the trigger...
            if (CanTrigger(closestTriggerIndex))
            {
                timer += Time.deltaTime;

                currentTrigger = interactionSystem.triggersInRange[closestTriggerIndex];                 // currentTrigger is not used by this script, but we assign it so that other scripts, like UI controllers, know what we are looking at
            }
            else
            {
                // ...reset if not
                timer          = 0f;
                currentTrigger = null;
                return;
            }

            // Its OK now to start the trigger
            if (timer >= triggerTime)
            {
                interactionSystem.TriggerInteraction(closestTriggerIndex, false);
                timer = 0f;
            }
        }
Esempio n. 9
0
 private void Start()
 {
     gm = FindObjectOfType <GameManager>();
     scrollWheelCountdown = scrollWheelDelay;
     player             = FindObjectOfType <Player>();
     interactionTrigger = FindObjectOfType <InteractionTrigger>();
 }
        private IEnumerator retardedRaycast()
        {
            if (rayFlag)
            {
                yield break;
            }

            rayFlag = true;

            hitData.hitEvent(fpsCamera.ScreenPointToRay(screenCenterPoint), rayLenght);
            if (hitData.hitGameObject)
            {
                cachedTrigger = hitData.hitGameObject.GetComponent <InteractionTrigger>();

                if (!cachedTrigger.autoReact)
                {
                    currentInteractable = cachedTrigger;
                }
            }
            else
            {
                currentInteractable = cachedTrigger = null;
            }

            yield return(raycastWait);

            rayFlag = false;
        }
Esempio n. 11
0
 private void Awake()
 {
     myTransform        = transform;
     rb                 = GetComponent <Rigidbody2D>();
     animator           = GetComponent <Animator>();
     interactionTrigger = GetComponentInChildren <InteractionTrigger>();
 }
Esempio n. 12
0
 private void trigger(bool triggered, InteractionTrigger trigger)
 {
     if (triggered)
     {
         DataPersitanceHelpers.SaveAll();
     }
 }
Esempio n. 13
0
 private void Trigger(bool triggered, InteractionTrigger trigger)
 {
     if (InteractionTrigger.AllTrue(Triggers))
     {
         FindObjectOfType <PlayerCamera>()?.ShakePosition(FallDelay, new Vector2(0.4f, 0.2f), -0.1f, 0.01f, 7.5f);
         StartCoroutine(Fall());
     }
 }
 void checkStopTriggers(bool triggered, InteractionTrigger trigger)
 {
     //check if all triggers are met if so invert spawn enemies
     if (InteractionTrigger.AllTrue(StopTriggers))
     {
         SpawnEnemies = false;
     }
 }
Esempio n. 15
0
 void unlockTrigger(bool triggered, InteractionTrigger trigger)
 {
     if (IsLocked)
     {
         IsLocked = false;
         UnlockSound?.Play();
     }
 }
Esempio n. 16
0
        // TODO refactor this funcionality with the pointClick Event System
        //This function is called by the EventTrigger on an Interactable, and trigger instantaneously
        public override void OnImmediateInteractableClick(InteractionTrigger interactable, int numCliks) {
            Debug.Log("Click on Interactable: " + interactable.gameObject.transform.name);
            //If the handle input flag is set to false then do nothing.
            if (!handleInput)
                return;

            //Interact onClick
            interactable.React();
        }
Esempio n. 17
0
 public ArtifactPillar(GameObject pillar, int pieceID, ActivateArtifactState artifactState)
 {
     placePieceTrigger = pillar.GetComponentInChildren <InteractionTrigger>();
     placePieceTrigger.SetObserver(this);
     placePieceTrigger.gameObject.GetComponent <BoxCollider>().enabled = true;
     material = pillar.GetComponent <Renderer>().materials[2];
     id       = pieceID;
     state    = artifactState;
 }
Esempio n. 18
0
 void Start()
 {
     m_col = gameObject.GetComponent <Collider2D>();
     //m_promptUI = GameObject.Find("Interaction_prompt").GetComponentInChildren<Text>();
     OverlapInteractions = new List <Interactable>();
     m_interactionHitbox = Instantiate(ListHitboxes.Instance.InteractBox, transform).GetComponent <InteractionTrigger>();
     m_interactionHitbox.transform.parent = transform;
     m_interactionHitbox.MasterInteractor = this;
     m_orient = GetComponent <Orientation>();
 }
Esempio n. 19
0
        private void Start()
        {
            rbody = GetComponent <Rigidbody2D>();
            interactionTrigger = GetComponentInChildren <InteractionTrigger>();
            Facing             = Vector2.right;
            animLogic          = transform.GetComponentInChildren <AnimatorLogicManager>();

            InteractionsEnabled = true;
            MovementEnabled     = true;
        }
Esempio n. 20
0
 private void checkInteraction()
 {
     if (currentInteractable != null && transform.position == currentInteractable.interactionLocation.position)
     {
         //We are exactly at the reaction position
         Debug.Log("NPC interacting");
         nextMoveTime = Time.time + secondsAtWaypoint;
         //nextMoveTime += interactableList[currentInteractableIndex].React();     //Must be executed after Interaction, otherwhise totalReactionsTime would be 0
         currentInteractable = null;
     }
 }
Esempio n. 21
0
 private void checkTriggers(bool triggered, InteractionTrigger trigger)
 {
     if (InteractionTrigger.AllTrue(Triggers))
     {
         previousTargetPortal = TargetPortalIndex;
         TargetPortalIndex    = TargetPortalOnTrigger;
     }
     else
     {
         TargetPortalIndex = previousTargetPortal;
     }
 }
Esempio n. 22
0
        //This function is called by the EventTrigger on an Interactable, the Interactable component is passed into it.
        public override void OnReachableInteractableClick(InteractionTrigger interactable, int numCliks) {
            Debug.Log("Click on Interactable: " + interactable.gameObject.transform.name);
            //If the handle input flag is set to false then do nothing.
            if (!handleInput)
                return;

            //Store the interactble that was clicked on.
            currentInteractable = interactable;

            //Set the destination to the interaction location of the interactable.
            playerMovement.destinationPosition.position = currentInteractable.interactionLocation.position;
        }
 private void translate(bool triggered, InteractionTrigger trigger)
 {
     //check if all triggers are met
     if (InteractionTrigger.CheckTriggers(TriggerType, Triggers))
     {
         targetPosition = origin - TriggeredPositionOffset;
     }
     else
     {
         targetPosition = origin;
     }
 }
Esempio n. 24
0
    private void moveUp(bool triggered, InteractionTrigger trigger)
    {
        if (!triggered || !Origin)
        {
            return;
        }

        transform.position = Origin.position;
        if (TriggerAudioSource && TriggerAudioSource.clip)
        {
            TriggerAudioSource.PlayOneShot(TriggerAudioSource.clip);
        }
    }
Esempio n. 25
0
        private void OnTriggerExit(Collider other)
        {
            if (other.gameObject.CompareTag(interactableTag))
            {
                InteractionTrigger interAux = other.gameObject.GetComponent <InteractionTrigger>();

                if (!interAux.autoReact)
                {
                    interactionTriggersInRange.Remove(interAux);
                    Debug.Log("Interactable Removed");
                }
            }
        }
Esempio n. 26
0
    void OnTriggerEnter(Collider other)
    {
        InteractionTrigger interaction = other.GetComponent <InteractionTrigger>();

        if (interaction != null)
        {
            AgentOrder order = AgentOrderFactory.Create(AgentOrder.E_OrderType.E_USE);
            order.InteractionObject = interaction;
            order.Position          = order.InteractionObject.GetEntryTransform().position;
            order.Interaction       = E_InteractionType.On;
            Owner.BlackBoard.OrderAdd(order);
            return;
        }
    }
    bool hasCompleted()
    {
        switch (completeState)
        {
        case CompleteState.CompleteOnTrigger:
            return(InteractionTrigger.AllTrue(StopTriggers));

        case CompleteState.CompleteOnSpawnLimit:
            return(currentSpanwedCount >= SpawnLimit);

        default:
            return(false);
        }
    }
Esempio n. 28
0
    void lockTrigger(bool triggered, InteractionTrigger trigger)
    {
        if (!IsLocked)
        {
            IsLocked = true;

            if (IsLocked)
            {
                Animator.SetBool(OnTriggerAnimation, false);
            }

            LockSound?.Play();
        }
    }
Esempio n. 29
0
    // Update is called once per frame
    void Update()
    {
        // Reset current trigger this frame
        currentTrigger = null;

        // Make sure that we want to allow raycasting
        if ((controller.IsGrounded == true) && (Singleton.Get <MenuManager>().PauseMenu.CurrentState == IMenu.State.Hidden))
        {
            // Update ray-casting
            rayCache.origin    = transform.position;
            rayCache.direction = transform.forward;

            // Ray cast
            if (Physics.Raycast(rayCache, out info, RaycastDistance, raycastMask) == true)
            {
                // Grab ray-casted object
                currentTrigger = info.collider.GetComponent <InteractionTrigger>();

                // Interact with the trigger
                if (currentTrigger != null)
                {
                    if (lastTrigger != currentTrigger)
                    {
                        currentTrigger.OnGazeEnter(this);
                    }
                    if (CrossPlatformInputManager.GetButton(GazeInteractInput) == true)
                    {
                        switch (currentTrigger.OnInteract(this))
                        {
                        case SoundEffectType.PickUpKey:
                            pickup.Play();
                            break;

                        case SoundEffectType.DropKey:
                            drop.Play();
                            break;
                        }
                    }
                }
            }
        }

        // Update lastTrigger
        if ((lastTrigger != null) && (lastTrigger != currentTrigger))
        {
            lastTrigger.OnGazeExit(this);
        }
        lastTrigger = currentTrigger;
    }
    private void fire(bool triggered, InteractionTrigger trigger)
    {
        if (!triggered || !Projectile || !Origin)
        {
            return;
        }

        GameObject projectileObject = Instantiate(Projectile.gameObject, Origin.position, Origin.rotation);

        projectileObject.GetComponent <Projectile>().HitLayerMask = ProjectileLayerMask;

        if (TriggerAudioSource && TriggerAudioSource.clip)
        {
            TriggerAudioSource.PlayOneShot(TriggerAudioSource.clip);
        }
    }