Beispiel #1
0
        public override void Enter(ActivityBase a, StateProcessor previousState)
        {
            base.Enter(a, previousState);

            ControllerInput.Instance.PointerMode = ControllerInput.EnPointerMode.Pointing;

            if (infoPanel)
            {
                infoPanel.SetText(string.Format(startPrompt, Utils.Minutised(timeToCompleteActivity)));
            }

            if (continueButton)
            {
                continueButton.Activate(continuePrompt, (continueButton) =>
                {
                    ActivityManager.Instance.FadeOutThen(() => { ActivityManager.Instance.Next(); });
                });
            }

            switch1.NotifyOnSwitch = Switched1;
            switch2.NotifyOnSwitch = Switched2;

            circuitState = Circuit.CircuitType.Open;
            circuit.CallOnTraceComplete = OnTraceComplete;

            foreach (Block b in blockComponents)
            {
                b.OnConnectionChanged = ConnectionUpdated;
            }

            ControllerInput.Instance.PlayVoiceover(voiceover);
        }
        public override void Enter(ActivityBase a, StateProcessor previousState)
        {
            base.Enter(a, previousState);

            ControllerInput.Instance.PointerMode = ControllerInput.EnPointerMode.Pointing;

            if (infoPanel)
            {
                infoPanel.SetText(string.Format(startPrompt, timeToCompleteActivity));

                if (introOnly)
                {
                    ControllerInput.Instance.PointerMode = ControllerInput.EnPointerMode.None;

                    if (!clickToContinue)
                    {
                        infoPanel.ShowFor(ActivitySettings.Asset.TextDisplayTime(startPrompt), () =>
                        {
                            PostExit(true);
                        });
                    }
                }
            }

            if (continueButton)
            {
                continueButton.Activate(continuePrompt, (continueButton) =>
                {
                    ActivityManager.Instance.FadeOutThen(() => { ActivityManager.Instance.Next(); });
                });
            }

            switch1.NotifyOnSwitch = Switched1;
            switch1.gameObject.SetActive(false);
            device1.OnConnectionChanged = OnConnectionChanged;
            device2.OnConnectionChanged = OnConnectionChanged;
            circuitState = Circuit.CircuitType.Open;
            circuit.CallOnTraceComplete = OnTraceComplete;
        }
Beispiel #3
0
        private void OnTraceComplete(Circuit.CircuitType ct, Circuit.TraceTrigger trigger)
        {
            Circuit.CircuitType previousState = circuitState;
            circuitState = ct;
            bool changedState = (previousState != circuitState) &&
                                (previousState != Circuit.CircuitType.Short) &&
                                (circuitState != Circuit.CircuitType.Short);

            switch (circuitState)
            {
            case Circuit.CircuitType.Closed:
                closedCount++;
                if (infoPanel)
                {
                    infoPanel.SetText("Light on");
                }
                break;

            case Circuit.CircuitType.Short:
                if (infoPanel)
                {
                    infoPanel.SetText("Short circuit!");
                }
                shortCount++;
                break;

            case Circuit.CircuitType.Open:
                if (infoPanel)
                {
                    infoPanel.SetText("Light off");
                }
                break;
            }

            if (trigger == Circuit.TraceTrigger.Rewire || circuitState == Circuit.CircuitType.Short)
            {
                Debug.Log("Reset after short or rewire");

                switch1Test.ResetTests();
                switch2Test.ResetTests();
            }
            else if (trigger == Circuit.TraceTrigger.Switch)
            {
                if (changedState)
                {
                    if (switch1Test.actionPending || switch2Test.actionPending)
                    {
                        if (switch1Test.actionPending && circuitState == Circuit.CircuitType.Closed)
                        {
                            switchedOn1 = true;
                        }
                        else if (switch2Test.actionPending && circuitState == Circuit.CircuitType.Closed)
                        {
                            switchedOn2 = true;
                        }

                        switch1Test.TestStatus(switch1.IsUp, circuitState == Circuit.CircuitType.Open);
                        switch2Test.TestStatus(switch2.IsUp, circuitState == Circuit.CircuitType.Open);
                    }
                }
                else // if we've flicked a switch and no change then it's wired incorrectly
                {
                    switch1Test.ResetTests();
                    switch2Test.ResetTests();
                }

                if (switch1Test.TestComplete && switch2Test.TestComplete || (switchedOn1 && switchedOn2))
                {
                    testComplete = true;
                    complete     = true;

                    Finish();

                    Debug.Log("Testing successfully completed");
                }
            }

            switch1Test.actionPending = switch2Test.actionPending = false;
        }
        private void OnTraceComplete(Circuit.CircuitType ct, Circuit.TraceTrigger trigger)
        {
            Circuit.CircuitType previousState = circuitState;
            circuitState = ct;
            bool changedState = (previousState != circuitState) &&
                                (previousState != Circuit.CircuitType.Short) &&
                                (circuitState != Circuit.CircuitType.Short);

            switch (circuitState)
            {
            case Circuit.CircuitType.Closed:
                closedCount++;
                infoPanel.SetText("Light on");
                if (!directWired)
                {
                    var ps = device1 as PowerSource;
                    ps.live.ClearOutgoingConnection();
                    ps.neutral.ClearOutgoingConnection();
                    directWired = true;
                    switch1.gameObject.SetActive(true);
                    PlayReward();
                    infoPanel.SetText("Great. Now let's try it with a switch. Run one of the cables through the switch and test it off and on.");
                }
                break;

            case Circuit.CircuitType.Short:
                infoPanel.SetText("Short circuit!");
                shortCount++;
                break;

            case Circuit.CircuitType.Open:
                infoPanel.SetText("Light off");
                break;
            }

            if (trigger == Circuit.TraceTrigger.Rewire || circuitState == Circuit.CircuitType.Short)
            {
                Debug.Log("Reset after short or rewire");

                switch1Test.ResetTests();
            }
            else if (trigger == Circuit.TraceTrigger.Switch)
            {
                if (changedState)
                {
                    if (switch1Test.actionPending)
                    {
                        switch1Test.TestStatus(switch1.IsUp, circuitState == Circuit.CircuitType.Open);
                    }
                }
                else // if we've flicked a switch and no change then it's wired incorrectly
                {
                    switch1Test.ResetTests();
                }

                if (switch1Test.SingleSwitchTestComplete)
                {
                    testComplete = true;

                    PlayReward();

                    Finish();

                    Debug.Log("Testing successfully completed");
                }
            }

            switch1Test.actionPending = false;
        }