Beispiel #1
0
        private void DoExecute()
        {
            if (currentInstruction != null)
            {
                // Reset current instruction
                currentInstruction.Renderer.BackgroundColor = currentInstruction.Renderer.DefaultBackgroundColor;
            }

            // Reached end of instructions
            if (instructionIndex > instructions.Count - 1)
            {
                currentInstruction = null;
                Stop();
                return;
            }

            currentInstruction = instructions[instructionIndex];

            currentInstruction.Renderer.BackgroundColor = InstructionRenderer.ExecutingBackgroundColor;
            draggableList.Highlight(currentInstruction.Draggable);

            try
            {
                currentInstruction.Instruction.Execute(target, this);
            }
            catch (InstructionException e)
            {
                FailExecution(e.Message);
            }

            instructionIndex++;
            executeNext = false;
        }
Beispiel #2
0
        /// <summary>
        /// To be called when an instruction has failed
        /// Will show some error text to the user with the given message
        /// </summary>
        public void FailExecution(string message)
        {
            if (currentInstruction != null)
            {
                currentInstruction.Renderer.BackgroundColor = InstructionRenderer.FailBackgroundColor;
                currentInstruction.Renderer.Render();
                currentInstruction = null;
            }

            ErrorText.text = "<b>" + message + "</b>";
            StartCoroutine(AnimateErrorText());

            Stop();
            Debug.Log("Instruction Exception: " + message);
            StatusText.text = "Failed";
        }
Beispiel #3
0
        /// <summary>
        /// Stops the execution at the end of the current instruction
        /// </summary>
        public void Stop()
        {
            if (!playing)
            {
                return;
            }

            playButton.GetComponent <Image>().sprite = GetSpriteByName(PLAY_RESET);
            stopButton.GetComponent <Image>().color  = new Color(.6f, .6f, .6f);
            playing = false;

            StatusText.text = "Stop";
            executeNext     = false;
            if (currentInstruction != null)
            {
                currentInstruction.Renderer.BackgroundColor = InstructionRenderer.ExecutingBackgroundColor;
            }

            currentInstruction = null;
            foreach (var instruction in instructions)
            {
                instruction.Instruction.Editable = true;
            }
        }