コード例 #1
0
    public void SelectPreviousObject()
    {
        if (cameraPivot == null)
        {
            Debug.LogError("PlaySpace.SelectNextObject() - Cannot select object because cameraPivot is null!");
            return;
        }
        if (objectsInScene == null || objectsInScene.Keys.Count == 0)
        {
            if (selectedObjectNameText != null)
            {
                selectedObjectNameText.text = TranslationManager.GetMessage("CodeWayDictionary", "CodeWayProject");
            }
            return;
        }
        int index = selectedObject - 1;

        if (index <= -1)
        {
            index = objectsInScene.Keys.Count - 1;
        }
        selectedObject = index;
        Transform          targetTransform    = GetIthObjectInSceneTransform(selectedObject);
        ProgrammableObject programmableObject = targetTransform.GetComponent <ProgrammableObject>();

        selectedObjectName = targetTransform.gameObject.name;
        if (programmableObject.cameraTarget != null)
        {
            cameraPivot.SetTarget(programmableObject.cameraTarget);
        }
        else
        {
            cameraPivot.SetTarget(targetTransform);
        }
    }
コード例 #2
0
 public void ResetSelectedObject()
 {
     if (selectedObject == -1)
     {
         DebugMessage.ErrorMessage(TranslationManager.GetMessage("SelectObjectFirst"));
         return;
     }
     Debug.Log("Resetting object " + selectedObjectName + ".");
     ResetObject(selectedObject);
 }
コード例 #3
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>());
 }
コード例 #4
0
ファイル: SourceBlocks.cs プロジェクト: leeohaddad/CodeWay
    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);
    }
コード例 #5
0
    private IEnumerator CreateTokens()
    {
        ContextMenuOnClick cm = this.gameObject.GetComponent <ContextMenuOnClick>();

        if (cm == null)
        {
            Debug.LogError("ContextMenuTranslationTokenizer must be attached to element with ContextMenuOnClick component.");
        }
        while (cm.isInitialized() == false)
        {
            yield return(new WaitForSeconds(0.1f));
        }
        List <RectTransform> buttonsRTs = cm.GetContextMenuButtonsRTs();
        Transform            parent     = buttonsRTs[0].parent;
        bool shouldDeactivateParent     = false;

        if (!parent.gameObject.activeSelf)
        {
            parent.gameObject.SetActive(true);
            shouldDeactivateParent = true;
        }
        foreach (RectTransform buttonRT in buttonsRTs)
        {
            bool shouldDeactivateButton = false;
            if (!buttonRT.gameObject.activeSelf)
            {
                buttonRT.gameObject.SetActive(true);
                shouldDeactivateButton = true;
            }
            Text             txt   = buttonRT.gameObject.GetComponentInChildren <Text>();
            string           text  = txt.text;
            TranslationToken token = txt.gameObject.AddComponent <TranslationToken>();
            token.targetText  = txt;
            token.token       = text;
            token.tagFileName = tagFileName;
            txt.text          = TranslationManager.GetMessage(tagFileName, text);
            if (shouldDeactivateButton == true)
            {
                buttonRT.gameObject.SetActive(false);
            }
        }
        if (shouldDeactivateParent == true)
        {
            parent.gameObject.SetActive(false);
        }
    }
コード例 #6
0
 void Update()
 {
     if (selectedObjectNameText != null)
     {
         if (selectedObject == -1)
         {
             selectedObjectNameText.text = TranslationManager.GetMessage("CodeWayDictionary", selectedObjectName);
         }
         else
         {
             selectedObjectNameText.text = TranslationManager.GetMessage("ProgrammableObjectsDictionary", selectedObjectName);
         }
         if (selectedObjectNameText.text == null || selectedObjectNameText.text.Length == 0)
         {
             selectedObjectNameText.text = selectedObjectName;
         }
     }
 }
コード例 #7
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();
    }
コード例 #8
0
    protected virtual string GetText()
    {
        string tag;

        if (token == "")
        {
            tag = "";
        }
        else
        {
            if (tagFileName == "")
            {
                tag = TranslationManager.GetMessage(token);
            }
            else
            {
                tag = TranslationManager.GetMessage(tagFileName, token);
            }
        }

        return(tag);
    }
コード例 #9
0
    private void SelectLibPage(int index)
    {
        string name, title;

        selectedLib = index;
        name        = GetIthLibName(index);
        title       = name.Replace("Lib", "");
        libTitleTranslationToken.token = title;
        string titleText = TranslationManager.GetMessage(title);

        if (titleText == null || titleText.Length == 0)
        {
            Text textComponent = libTitleTranslationToken.gameObject.GetComponent <Text>();
            if (textComponent != null)
            {
                textComponent.text = title;
            }
        }
        EraseLibPageCmds();
        List <string> libsCmdNames = libsCommandsNames[name];

        foreach (string cmdName in libsCmdNames)
        {
            GameObject cmdInstance = GameObject.Instantiate(model.gameObject);
            EvoLangCmd cmd         = commands[cmdName];
            cmdInstance.name = cmd.command;
            Transform cmdInstanceTransform = cmdInstance.GetComponent <Transform>();
            cmdInstanceTransform.parent           = model.parent;
            cmdInstanceTransform.localPosition    = Vector3.zero;
            cmdInstanceTransform.localEulerAngles = Vector3.zero;
            cmdInstanceTransform.localScale       = Vector3.one;
            Image img = cmdInstance.GetComponent <Image>();
            img.sprite = cmd.sprite;
            img.color  = cmd.color;
            cmdInstance.SetActive(true);
            activeInstances.Add(cmdInstanceTransform);
        }
    }
コード例 #10
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"));
        }
    }
コード例 #11
0
ファイル: SourceBlocks.cs プロジェクト: leeohaddad/CodeWay
    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);
    }