예제 #1
0
    /// <summary>
    /// Adds the operation to the active composite operation
    /// </summary>
    /// <param name="op">Op.</param>
    public void RunOperation(string op)
    {
        BotOperation operation = null;
        bool         exists    = availableOps.TryGetValue(op, out operation);

        if (exists)
        {
            if (AddToCurrentComp(operation, 0))
            {
                uiManager.AddOperationToBlock(currentComposite.name, op);
            }
        }
        else
        {
            // Maybe its a composite
            BotOperation compOp     = null;
            bool         existsComp = compositeOps.TryGetValue(op, out compOp);

            if (existsComp)
            {
                CompositeOperation comp = compOp as CompositeOperation;
                if (AddToCurrentComp(comp, 0))
                {
                    uiManager.AddOperationToBlock(currentComposite.name, op);
                }
            }
        }
    }
예제 #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();
                        // 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);
    }
예제 #3
0
 /// <summary>
 /// Adds the operation to the available operations list
 /// </summary>
 /// <param name="operation">Operation.</param>
 /// <param name="main">If set to <c>true</c> main.</param>
 /// <param name="composite">If set to <c>true</c> composite.</param>
 /// <param name="name">Name.</param>
 public void AddOperation(BotOperation operation, bool main, bool composite, string name)
 {
     if (main)
     {
         CompositeOperation compOp = operation as CompositeOperation;
         mainOp           = compOp;
         currentComposite = compOp;
         compositeOps.Add(name, mainOp);
     }
     else if (!composite)
     {
         availableOps.Add(name, operation);
     }
     else
     {
         compositeOps.Add(name, operation);
     }
 }
예제 #4
0
 /// <summary>
 /// Adds the selected operation to the main function
 /// </summary>
 /// <param name="operation">Operation.</param>
 /// <param name="index">Index.</param>
 public bool AddToCurrentComp(BotOperation operation, int index)
 {
     return(currentComposite.AddOperation(operation));
 }