コード例 #1
0
    private IEnumerator puzzlePlayIEnum()
    {
        addActualToReal();                          //Adds from previous reading

        for (int i = 0; i < actualInput.Count; i++) //Reset all inputs
        {
            actualInput[i] = 0;
            //print(this.GetType().Name + ":puzzlePlay():i/actualInput: " + i + "/"+ actualInput[i]);
            //print(Time.time + ": acutalInput=0");
        }
        //bool on = false;
        for (int i = 0; i < outputs.Count; i++)
        {
            POutputController curOutObj = outputObjs[i].GetComponent <POutputController>();
            if (outputs[i].signal[EOTPPlayTurn] > 0)
            {
                curOutObj.beingPowered = true;
                curOutObj.tryPower(true);
                curOutObj.sendPower(-1);
                //on = true;
            }
            else
            {
                curOutObj.beingPowered = false;
                curOutObj.tryPower(false);
                curOutObj.sendPower(-1);
            }
            //print(this.GetType().Name + ":puzzlePlay():" + outputs[i].getSignal()[EOTPPlayTurn]);
        }

        print("Waiting for middle: " + EOTP_MIDDLE_WAIT_TIME_MS + "sec!");
        yield return(new WaitForSeconds(EOTP_MIDDLE_WAIT_TIME_MS));

        EOTP_waitforinput = true;
        EOTPPlayTurn++;
        print(this.GetType().Name + ": puzzlePlay(): PlayTurn: " + EOTPPlayTurn);

        stepText.text = EOTPPlayTurn + "/" + (outputs[0].signal.Length + 1);

        if (EOTPPlayTurn < outputs[0].signal.Length)
        {
            StartCoroutine(EOTPwait());
        }
        else
        {
            StartCoroutine(EOTPwaitFinish());
            //print(this.GetType().Name + ":puzzlePlay(): finished");
        }
    }
コード例 #2
0
    public bool resetPuzzle()
    {
        print(this.GetType().Name + ": reseting puzzle");
        UtilBools.puzzleInteractLock(false);
        EOTPPlayTurn = 0; //reset
        bool ok = true;

        for (int li = 0; li < realInput.Count; li++)
        {
            for (int i = 0; i < realInput[li].Count; i++)
            {
                print(this.GetType().Name + ":EOTPwaitFinish():li/i: " + li + "/" + i);
                print(this.GetType().Name + ":EOTPwaitFinish():Input Gotten:" + realInput[li][i]);
                print(this.GetType().Name + ":EOTPwaitFinish():Input Wanted:" + inputs[li].signal[i]);
                if (realInput[li][i] != inputs[li].signal[i])
                {
                    ok = false;
                }
            }
            //reset each list for next check logic
            realInput[li] = new List <int>();
        }
        stepping = false;
        stepText.gameObject.SetActive(false);
        stopStepButton.SetActive(false);
        //reset powered
        for (int i = 0; i < outputs.Count; i++)
        {
            POutputController curOutObj = outputObjs[i].GetComponent <POutputController>();
            curOutObj.beingPowered = false;
            curOutObj.tryPower(false);
            curOutObj.sendPower(-1);
        }
        return(ok);
    }