Esempio n. 1
0
    //Handler captures usage of controls
    void Handler(BaseControl control)
    {
        if (usermode)
        {
            if (control == controller.Controls.setting1 ||
                control == controller.Controls.setting2 ||
                control == controller.Controls.toggle2)
            {
                ContextSwitched();
            }
            else if (control == controller.Controls.toggle1)
            {
                PowerSystem system = GetCurrentSystem();

                system.on = !system.on;

                if (system.on)
                {
                    controller.Controls.yellowLight.Lit = true;
                    controller.Controls.redLight.Lit    = false;
                }
                else
                {
                    controller.Controls.redLight.Lit    = true;
                    controller.Controls.yellowLight.Lit = false;
                    controller.Controls.greenLight.Lit  = false;
                    system.ResetTimer();
                }
            }

            //light up buttons
            if (control == controller.Controls.button1)
            {
                int  ii    = 0;
                bool found = false;
                for (ii = 0; ii < level1systems.Count && !found; ++ii)
                {
                    if (level1systems[ii].on && level1systems[ii].WarmedUp)
                    {
                        found = true;
                    }
                }

                if (found)
                {
                    controller.Controls.setting1.option1.isOn = true;

                    switch (--ii)
                    {
                    case 0:
                        controller.Controls.setting2.option1.isOn = true;
                        break;

                    case 1:
                        controller.Controls.setting2.option2.isOn = true;
                        break;

                    case 2:
                        controller.Controls.setting2.option3.isOn = true;
                        break;
                    }

                    ContextSwitched();
                }
            }
            else if (control == controller.Controls.button2)
            {
                int  ii    = 0;
                bool found = false;
                for (ii = 0; ii < level2systems.Count && !found; ++ii)
                {
                    if (level2systems[ii].on && level2systems[ii].WarmedUp)
                    {
                        found = true;
                    }
                }

                if (found)
                {
                    controller.Controls.setting1.option2.isOn = true;

                    switch (--ii)
                    {
                    case 0:
                        controller.Controls.setting2.option1.isOn = true;
                        break;

                    case 1:
                        controller.Controls.setting2.option2.isOn = true;
                        break;

                    case 2:
                        controller.Controls.setting2.option3.isOn = true;
                        break;
                    }
                    ContextSwitched();
                }
            }
            else if (control == controller.Controls.button3)
            {
                int  ii    = 0;
                bool found = false;
                for (ii = 0; ii < level1systems.Count && !found; ++ii)
                {
                    if (level3systems[ii].on && level3systems[ii].WarmedUp)
                    {
                        found = true;
                    }
                }

                if (found)
                {
                    controller.Controls.setting1.option3.isOn = true;

                    switch (--ii)
                    {
                    case 0:
                        controller.Controls.setting2.option1.isOn = true;
                        break;

                    case 1:
                        controller.Controls.setting2.option2.isOn = true;
                        break;

                    case 2:
                        controller.Controls.setting2.option3.isOn = true;
                        break;
                    }
                    ContextSwitched();
                }
            }
        }
    }
    void Handler(BaseControl control)
    {
        if (usermode && !tutWait)
        {
            //tutorial stuff
            if (curState == TutState.WaitForToggle2 &&
                control == controller.Controls.toggle2)
            {
                tutWait = true;
                tut.Toggle2Hinta.SetActive(false);
                tut.ExplainMeter1b.SetActive(true);
                curState = TutState.ExplainMeter1b;
            }

            if (curState == TutState.ExplainSetting2c &&
                control == controller.Controls.setting2)
            {
                tut.ExplainSetting2c.GetComponentInChildren <Button>(true).gameObject.SetActive(true);
            }

            if (curState == TutState.WaitForToggle1 &&
                control == controller.Controls.toggle1)
            {
                tutWait = true;
                tut.Toggle1Hinta.SetActive(false);
                tut.RedLightHint.SetActive(false);
                tut.YellowLightHint.SetActive(true);
                curState = TutState.YellowLight;
            }

            if (curState == TutState.WaitForSetting1 &&
                control == controller.Controls.setting1)
            {
                tut.Setting1Hint.SetActive(false);
                tut.Setting2Hint.SetActive(true);
                curState = TutState.WaitForSetting2;
            }

            if (curState == TutState.WaitForSetting2 &&
                control == controller.Controls.setting2)
            {
                tut.Setting2Hint.SetActive(false);
                tut.Toggle1Hintb.SetActive(true);
                curState = TutState.WaitForToggle1b;
            }

            if (curState == TutState.WaitForToggle1b &&
                control == controller.Controls.toggle1)
            {
                tut.Toggle1Hintb.SetActive(false);
                tut.ExplainEnding.SetActive(true);
                curState = TutState.ExplainEnding;
            }

            //main logic
            if (control == controller.Controls.setting1 ||
                control == controller.Controls.setting2 ||
                control == controller.Controls.toggle2)
            {
                ContextSwitched();
            }
            else if (control == controller.Controls.toggle1)
            {
                PowerSystem system = GetCurrentSystem();

                system.on = !system.on;

                if (system.on)
                {
                    controller.Controls.yellowLight.Lit = true;
                    controller.Controls.redLight.Lit    = false;
                }
                else
                {
                    controller.Controls.redLight.Lit    = true;
                    controller.Controls.yellowLight.Lit = false;
                    controller.Controls.greenLight.Lit  = false;
                    system.ResetTimer();
                }
            }

            //light up buttons
            if (control == controller.Controls.button1)
            {
                int  ii    = 0;
                bool found = false;
                for (ii = 0; ii < level1systems.Count && !found; ++ii)
                {
                    if (level1systems[ii].on && level1systems[ii].WarmedUp)
                    {
                        found = true;
                    }
                }

                if (found)
                {
                    controller.Controls.setting1.option1.isOn = true;

                    switch (--ii)
                    {
                    case 0:
                        controller.Controls.setting2.option1.isOn = true;
                        break;

                    case 1:
                        controller.Controls.setting2.option2.isOn = true;
                        break;

                    case 2:
                        controller.Controls.setting2.option3.isOn = true;
                        break;
                    }

                    ContextSwitched();
                }
            }
            else if (control == controller.Controls.button2)
            {
                int  ii    = 0;
                bool found = false;
                for (ii = 0; ii < level2systems.Count && !found; ++ii)
                {
                    if (level2systems[ii].on && level2systems[ii].WarmedUp)
                    {
                        found = true;
                    }
                }

                if (found)
                {
                    controller.Controls.setting1.option2.isOn = true;

                    switch (--ii)
                    {
                    case 0:
                        controller.Controls.setting2.option1.isOn = true;
                        break;

                    case 1:
                        controller.Controls.setting2.option2.isOn = true;
                        break;

                    case 2:
                        controller.Controls.setting2.option3.isOn = true;
                        break;
                    }
                    ContextSwitched();
                }
            }
            else if (control == controller.Controls.button3)
            {
                int  ii    = 0;
                bool found = false;
                for (ii = 0; ii < level1systems.Count && !found; ++ii)
                {
                    if (level3systems[ii].on && level3systems[ii].WarmedUp)
                    {
                        found = true;
                    }
                }

                if (found)
                {
                    controller.Controls.setting1.option3.isOn = true;

                    switch (--ii)
                    {
                    case 0:
                        controller.Controls.setting2.option1.isOn = true;
                        break;

                    case 1:
                        controller.Controls.setting2.option2.isOn = true;
                        break;

                    case 2:
                        controller.Controls.setting2.option3.isOn = true;
                        break;
                    }
                    ContextSwitched();
                }
            }
        }
    }