예제 #1
0
    void CheckForLookedAtObjects()
    {
        Vector3 endPoint = (transform.forward * maxDistanceToActivate) + transform.position;

        Debug.DrawLine(transform.position, endPoint, Color.red);

        RaycastHit raycastHit;

        if (Physics.Raycast(transform.position, transform.forward,
                            out raycastHit, maxDistanceToActivate, layerToCheckForInteractables))
        {
            //Debug.Log(raycastHit.transform.gameObject.name);

            lookedAtNPC       = raycastHit.transform.gameObject.GetComponent <IActivateable>();
            lookedAtNPCObject = raycastHit.transform.gameObject;
            if (lookedAtNPCObject.GetComponent <NPC>() != null)
            {
                lookedAtNPCObject.transform.GetChild(0).gameObject.SetActive(true); //indicator showing you can talk to NPC
            }
        }
        else
        {
            if (lookedAtNPCObject != null && lookedAtNPCObject.GetComponent <NPC>() != null)
            {
                lookedAtNPCObject.transform.GetChild(0).gameObject.SetActive(false);
            }                                                                                                                                                        //indicator showing you can talk to NPC
            lookedAtNPC       = null;
            lookedAtNPCObject = null;
        }
    }
예제 #2
0
 private void Awake()
 {
     player       = GameObject.Find("Player");
     _input       = player.GetComponent <playerInput>();
     activateable = GetComponent <IActivateable>();
     ePopup       = this.transform.GetChild(0).gameObject;
 }
예제 #3
0
 /**
  * Force an activatable to be unpressed even when the user has not released it.
  * Normally used when a button is about to be hidden.
  */
 public void ForceUnpress(IActivateable button)
 {
     if (pressedActivatableReleases.ContainsKey(button))
     {
         var unpress = pressedActivatableReleases[button];
         unpress();
         pressedActivatableReleases.Remove(button);
     }
 }
예제 #4
0
        void Awake()
        {
            activator = activatingGameObject.GetComponent <IActivateable>();
            if (activator == null)
            {
                return;
            }

            activator.OnActivated += onActivatorFired;
        }
 //calls the activate method in any activateable traits
 public void Activate()
 {
     TraitBase[] tempTraits = GetArray();
     for (int i = 0; i < tempTraits.Length; i++)
     {
         if (tempTraits[i] is IActivateable)
         {
             IActivateable activateable = (IActivateable)tempTraits[i];
             activateable.Activate();
         }
     }
 }
예제 #6
0
        void Awake()
        {
            if (enablingGameObject == null)
            {
                return;
            }

            enabler = enablingGameObject.GetComponent <IActivateable>();
            if (enabler == null)
            {
                return;
            }

            enabler.OnActivated += onEnablerTriggered;

            onMaterial = GetComponent <MeshRenderer>().material;
        }
예제 #7
0
    void CheckForLookedAtObjects()
    {
        Vector3 endPoint = (transform.forward * maxDistanceToActivate) + transform.position;

        Debug.DrawLine(transform.position, endPoint, Color.red);

        RaycastHit raycastHit;

        if (Physics.Raycast(transform.position, transform.forward,
                            out raycastHit, maxDistanceToActivate, layerToCheckForInteractables))
        {
            //Debug.Log(raycastHit.transform.gameObject.name);
            lookAtObjectText.gameObject.SetActive(true);
            lookedAtNPC           = raycastHit.transform.gameObject.GetComponent <IActivateable>();
            lookedAtNPCObject     = raycastHit.transform.gameObject;
            lookAtObjectText.text = "Activate " + raycastHit.transform.gameObject.name + " with 'Q'";
        }
        else
        {
            lookAtObjectText.gameObject.SetActive(false);
        }
    }
        // creates an auto scroller object for the tests
        private AutoScroller CreateAutoScroller(out IScrollView scrollView, out IRectangle content, out IActivateable elementToStartScroller)
        {
            scrollView             = A.Fake <IScrollView>();
            content                = A.Fake <IRectangle>();
            elementToStartScroller = A.Fake <IActivateable>();
            AutoScroller autoScroller = new AutoScroller(scrollView, content, elementToStartScroller);

            return(autoScroller);
        }
예제 #9
0
 public void AddToActivatable(IActivateable a)
 {
     activatable.Add(a);
 }
예제 #10
0
 public void AddToActivatable(IActivateable a)
 {
     activatable.Add(a);
 }