Esempio n. 1
0
    public void ChangeState(WorkerStateTrigger trigger)
    {
        TransitionBundle transition = workerStateTransition.ChangeState(trigger, currentState);

        currentState = transition.Destination;
        Output(transition.Output);
    }
Esempio n. 2
0
    private void ProcessBundle(TransitionBundle bundle)
    {
        if (bundle.effects.Contains(Menu.Effect.EXCLUSIVE))
        {
            ClearMenus();
        }
        if (bundle.menu == null)
        {
            return;
        }
        switch (bundle.transition)
        {
        case Menu.Transition.HIDE:
            bundle.menu.CanvasGroup.blocksRaycasts = false;
            bundle.menu.CanvasGroup.interactable   = false;
            menuStack.RemoveAll((cmp) => { return(cmp.MenuName == bundle.menu.MenuName); });
            break;

        case Menu.Transition.SHOW:
            deadNavButton.gameObject.SetActive(false);
            bundle.menu.CanvasGroup.blocksRaycasts = true;
            bundle.menu.CanvasGroup.interactable   = true;
            menuStack.Add(bundle.menu);
            break;

        case Menu.Transition.TOGGLE:
            // Do nothing, a SHOW or HIDE will come through soon.
            break;

        case Menu.Transition.SPECIAL:
            // There's nothing to do.. we don't know if a show is coming or not..
            break;
        }
    }
Esempio n. 3
0
    private void OnTriggerEnter(Collider other)
    {
        WorkerStateTrigger trigger = workerStateScripts[currentState].Collide(other, ref health);

        if (trigger != WorkerStateTrigger.Null)
        {
            TransitionBundle transition = workerStateTransition.ChangeState(trigger, currentState);
            currentState = transition.Destination;
            Output(transition.Output, other);
        }
    }
Esempio n. 4
0
    void LoseHealth()
    {
        DestructableObstacleCollision other   = Instantiate(testSample);
        WorkerStateTrigger            trigger = workerStateScripts[currentState].Collide(other.GetComponent <Collider>(), ref health);

        if (trigger != WorkerStateTrigger.Null)
        {
            TransitionBundle transition = workerStateTransition.ChangeState(trigger, currentState);
            currentState = transition.Destination;
            Output(transition.Output);
        }
    }
Esempio n. 5
0
    private void Update()
    {
        //healthText.text = health.ToString();
        // Check if there is an output trigger from current state
        WorkerStateTrigger trigger = workerStateScripts[currentState].InputTrigger();

        if (trigger != WorkerStateTrigger.Null)
        {
            TransitionBundle transition = workerStateTransition.ChangeState(trigger, currentState);
            currentState = transition.Destination;
            Output(transition.Output);
        }
    }
Esempio n. 6
0
    private void Update()
    {
        if (transitionQueue.Count > 0)
        {
            EnableEventSystem(false);
            while (transitionQueue.Count > 0)
            {
                TransitionBundle bundle = transitionQueue.Dequeue();
                ProcessBundle(bundle);
                bundle.menu.DoTransition(bundle.transition, bundle.effects);
            }
            EnableEventSystem(true);
        }

        // Check if we should switch between mouse mode or not
        bool mouseInput = InputManager.Instance.Player.controllers.Mouse.GetAnyButton();

        if (!mouseMode && (InputManager.Instance.Player.controllers.Mouse.GetAnyButtonDown() ||
                           Input.GetAxis("Mouse X") != 0 || Input.GetAxis("Mouse Y") != 0))
        {
            MouseMode = true;
        }
        else if (!mouseInput && mouseMode && (
                     InputManager.Instance.Player.controllers.Joysticks.Any((joystick) => joystick.GetAnyButton()) ||
                     InputManager.Instance.Player.controllers.Joysticks.Any((joystick) => joystick.Axes.Any((axis) => axis.value != 0))
                     ))
        {
            MouseMode = false;
        }

        // Coerce back to keyboard navigation if necessary
        if ((UnityES.current.currentSelectedGameObject == null || UnityES.current.currentSelectedGameObject == deadNavButton.gameObject) &&
            InputManager.Instance.QueryAxes(Strings.Input.UI.NAVIGATION).sqrMagnitude > 0)
        {
            StartCoroutine(SelectNextFrame());
        }
    }