Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit obj;

            if (Physics.Raycast(transform.position + transform.forward * 0.5f, transform.forward, out obj, 1.0f))
            {
                Trigger t = obj.collider.GetComponent <Trigger>();

                Debug.Log("Trying to click " + obj.collider.name + "...");

                if (t != null && t.triggerType == TriggerType.Clickable)
                {
                    if (t.state == State.Activated)
                    {
                        t.Deactivate();
                    }
                    else
                    {
                        t.Activate();
                    }
                }
            }
        }
    }
Esempio n. 2
0
        public void Setup()
        {
            someTrigger = new Trigger(() => testBoolean = true);
            someTrigger.Activate();

            failingTrigger = new Trigger(() => throw new Exception());
            failingTrigger.Activate();
        }
Esempio n. 3
0
 private void Update()
 {
     foreach (LightTrigger light in GameManager.Instance.Lights)
     {
         if (light.IsLit && Vector3.SqrMagnitude(light.transform.position - transform.position) < 16)
         {
             Trigger.Activate();
             break;
         }
     }
 }
Esempio n. 4
0
    private void Update()
    {
        bool inLight = false;

        foreach (LightTrigger light in GameManager.Instance.Lights)
        {
            if (light.IsLit && Vector3.SqrMagnitude(light.transform.position - transform.position) < 25)
            {
                inLight = true;
                break;
            }
        }
        if (!inLight)
        {
            Trigger.Activate();
        }
    }
Esempio n. 5
0
    //check for step triggers
    private void CheckForTrigger()
    {
        List <Collider2D> results = new List <Collider2D>();
        ContactFilter2D   filter  = new ContactFilter2D();

        filter.useTriggers = true;
        if (boxCollider.OverlapCollider(filter, results) > 0)
        {
            foreach (Collider2D item in results)
            {
                Trigger target = item.gameObject.GetComponent <Trigger>();
                if (target != null)
                {
                    target.Activate();
                }
            }
        }
    }
Esempio n. 6
0
    private void Update()
    {
        bool allActive     = true;
        bool allActiveOnce = true;

        foreach (Trigger trigger in Triggers)
        {
            if (!trigger.Activated)
            {
                allActive = false;
            }
            if (!trigger.ActivatedOnce)
            {
                allActiveOnce = false;
            }
        }

        if (AllActiveTrigger != null)
        {
            if (allActive)
            {
                if (!AllActiveTriggered)
                {
                    AllActiveTrigger.Activate(null);
                    AllActiveTriggered = true;
                }
            }
            else
            {
                AllActiveTriggered = false;
            }
        }

        if (AllActiveOnceTrigger != null && allActiveOnce && !AllActiveOnceTriggered)
        {
            AllActiveOnceTrigger.Activate(null);
            AllActiveOnceTriggered = true;
        }
    }
Esempio n. 7
0
    /* Update Method
     * Send out a raycast forward to return what it hits
     * If the hit object has the tag Button and is in the LayerMask
     * If the user left clicks, the button will be activated
     * Don't worry about double activation, button script will handle with states
     */
    void Update()
    {
        if (Physics.Raycast(transform.position, transform.forward, out hitInfo, buttonPressDist, pickupMask))
        {
            Trigger t = hitInfo.collider.GetComponent <Trigger>();

            if (t != null && t.triggerType == TriggerType.Clickable)
            {
                //TODO Display some GUI thing that'll tell the user he can interact.
                pointedAt = true;
                Debug.DrawRay(transform.position, buttonPressDist * transform.forward, Color.green);
                if (Input.GetMouseButtonDown(0))
                {
                    if (t.state == State.Activated)
                    {
                        t.Deactivate();
                    }
                    else
                    {
                        t.Activate();
                    }

                    audio.PlayOneShot(buttonSound, 1);
                }
            }
            else
            {
                pointedAt = false;
                Debug.DrawRay(transform.position, buttonPressDist * transform.forward, Color.yellow);
            }
        }
        else
        {
            pointedAt = false;
            Debug.DrawRay(transform.position, buttonPressDist * transform.forward, Color.red);
        }
    }
Esempio n. 8
0
 public void OnTurnEnd(TurnManager turnManager, Character unit)
 {
     onTurnEndTriggers.Activate(unit.Stats, turnManager, _ui);
 }
Esempio n. 9
0
 public void OnKill(TurnManager turnManager, Character unit)
 {
     onKillTriggers.Activate(unit.Stats, turnManager, _ui);
 }