コード例 #1
0
    IEnumerator CompositeRun(string name)
    {
        BotOperation operation;

        compositeOps.TryGetValue(name, out operation);
        CompositeOperation  compOp    = operation as CompositeOperation;
        List <BotOperation> botOpList = compOp.opList;

        if (botOpList != null)
        {
            for (int i = 0; i < botOpList.Count; i++)
            {
                BotOperation       op   = botOpList [i];
                CompositeOperation comp = op as CompositeOperation;

                if (comp != null)
                {
                    // If this operation is a composite one we need to execute it first accordingly
                    yield return(StartCoroutine(CompositeRun(comp.name)));
                }

                if (op != null && op.ValidateOperation(gameObject, levelDef))
                {
                    op.RunOperation(gameObject, levelDef);

                    if (CheckGameOver())
                    {
                        //If all the lights are on then there's no need to continue running the processes, it's game over
                        StopAllCoroutines();
                        // TextAsset load = Resources.Load<TextAsset> (listManager.chosenLevelUrl);
                        // var level = JSON.Parse (load.text);
                        // var namalvl = level["name"].Value;
                        //  if(namalvl == "1"){
                        //      SceneManager.LoadScene("Quiz1");
                        //  } else if(namalvl == "2"){
                        //      SceneManager.LoadScene("Quiz2");
                        //  }
                    }
                }

                yield return(new WaitForSeconds(operationDelay));
            }
        }

        yield return(null);
    }
コード例 #2
0
    IEnumerator CompositeRun(string name)
    {
        BotOperation operation;

        compositeOps.TryGetValue(name, out operation);
        CompositeOperation  compOp    = operation as CompositeOperation;
        List <BotOperation> botOpList = compOp.opList;

        if (botOpList != null)
        {
            for (int i = 0; i < botOpList.Count; i++)
            {
                BotOperation       op   = botOpList [i];
                CompositeOperation comp = op as CompositeOperation;

                if (comp != null)
                {
                    // If this operation is a composite one we need to execute it first accordingly
                    yield return(StartCoroutine(CompositeRun(comp.name)));
                }

                if (op != null && op.ValidateOperation(gameObject, levelDef))
                {
                    op.RunOperation(gameObject, levelDef);

                    if (CheckGameOver())
                    {
                        // If all the lights are on then there's no need to continue running the processes, it's game over
                        StopAllCoroutines();
                    }
                }

                yield return(new WaitForSeconds(operationDelay));
            }
        }

        yield return(null);
    }