Esempio n. 1
0
 public void ResetSelectedObject()
 {
     if (selectedObject == -1)
     {
         DebugMessage.ErrorMessage(TranslationManager.GetMessage("SelectObjectFirst"));
         return;
     }
     Debug.Log("Resetting object " + selectedObjectName + ".");
     ResetObject(selectedObject);
 }
Esempio n. 2
0
 public void PrepareSelectedObjectToReceiveBehavior()
 {
     if (selectedObject == -1)
     {
         DebugMessage.ErrorMessage(TranslationManager.GetMessage("SelectObjectFirst"));
         PanelLoadBg.AbortLoadStatic();
         return;
     }
     Debug.Log("Preparing object " + selectedObjectName + " to receive behavior.");
     PanelLoadBg.SetProgrammableObjectStatic(GetIthObjectInSceneTransform(selectedObject).GetComponent <ProgrammableObject>());
 }
Esempio n. 3
0
    void OnEnable()
    {
        if (avoidNextTextUpdate)
        {
            avoidNextTextUpdate = false;
        }
        // Update Source Blocks!
        if (cmdCubes != null)
        {
            foreach (Transform cmdCube in cmdCubes)
            {
                GameObject.Destroy(cmdCube.gameObject);
            }
            cmdCubes.Clear();
        }
        if (linkCubes != null)
        {
            foreach (Transform linkCube in linkCubes)
            {
                GameObject.Destroy(linkCube.gameObject);
            }
            linkCubes.Clear();
        }
        cmdCount = 0;
        if (inputFieldComponent == null)
        {
            inputFieldComponent = sourceCode.gameObject.GetComponent <InputField>();
        }
        List <string> commands = new List <string>(inputFieldComponent.text.Split(';'));

        foreach (string splittedCommand in commands)
        {
            string cmd = splittedCommand.Trim();
            if (cmd.Length > 0)
            {
                if (cmdMaterials.ContainsKey(cmd))
                {
                    AddCommandBlock(cmd);
                }
                else
                {
                    DebugMessage.ErrorMessage("'" + cmd + "' " + TranslationManager.GetMessage("NotRecognizedCommand"));
                }
            }
        }
        SetSelectedBlock(-1);
    }
Esempio n. 4
0
    public void LoadCode(Dropdown sourceCode)
    {
        int result = -1;

        result = PanelLoadBg.TryToLoadCodeToProgrammableObjectStatic(sourceCode);
        if (result != 0 && sourceCodeComponent != null)
        {
            result = sourceCodeComponent.LoadCode(sourceCode);
        }
        if (result == 0)
        {
            DebugMessage.SuccessMessage(TranslationManager.GetMessage("LoadedSuccessfully"));
        }
        else
        {
            DebugMessage.ErrorMessage(TranslationManager.GetMessage("ErrorLoading"));
        }
        PanelLoadBg.ExitAnimation();
    }
Esempio n. 5
0
    public void SaveCode(Text nameTextComponent)
    {
        int    result = -1;
        string text   = "";

        if (nameTextComponent != null)
        {
            text = nameTextComponent.text;
        }
        if (sourceCodeComponent != null)
        {
            result = sourceCodeComponent.SaveCode(text);
        }
        if (result == 0)
        {
            DebugMessage.SuccessMessage(TranslationManager.GetMessage("SavedSuccessfully"));
            PanelSaveBg.ExitAnimation();
        }
        else
        {
            DebugMessage.ErrorMessage(TranslationManager.GetMessage("ErrorSaving"));
        }
    }
Esempio n. 6
0
    public void DeleteSelectedBlock()
    {
        Transform cmdCubeToDelete  = null;
        Transform linkCubeToDelete = null;
        int       index;

        if (selectedBlock == -1)
        {
            DebugMessage.ErrorMessage(TranslationManager.GetMessage("SelectObjectFirst"));
            return;
        }
        index = 0;
        foreach (Transform cmdCubeTransform in cmdCubes)
        {
            if (selectedBlock == index)
            {
                cmdCubeToDelete = cmdCubeTransform;
            }
            else if (selectedBlock < index)
            {
                cmdCubeTransform.localPosition = new Vector3(0, cmdCubeTransform.localPosition.y + 1.5f, 0);
                cmdCubeTransform.gameObject.GetComponent <EvoLangCmdCube>().SetIndex(index - 1);
            }
            index++;
        }
        cmdCubes.Remove(cmdCubeToDelete);
        GameObject.Destroy(cmdCubeToDelete.gameObject);
        cmdCount--;
        if (cmdCount == selectedBlock)
        {
            if (selectedBlock > 0)
            {
                index = 1;
                foreach (Transform linkCubeTransform in linkCubes)
                {
                    if (selectedBlock == index)
                    {
                        linkCubeToDelete = linkCubeTransform;
                    }
                    index++;
                }
                linkCubes.Remove(linkCubeToDelete);
                GameObject.Destroy(linkCubeToDelete.gameObject);
            }
        }
        else
        {
            index = 0;
            foreach (Transform linkCubeTransform in linkCubes)
            {
                if (selectedBlock == index)
                {
                    linkCubeToDelete = linkCubeTransform;
                }
                else if (selectedBlock < index)
                {
                    linkCubeTransform.localPosition = new Vector3(0, linkCubeTransform.localPosition.y + 1.5f, 0);
                }
                index++;
            }
            linkCubes.Remove(linkCubeToDelete);
            GameObject.Destroy(linkCubeToDelete.gameObject);
        }
        SetSelectedBlock(-1);
    }