getIDEInput() public méthode

public getIDEInput ( ) : IDEInput,
Résultat IDEInput,
Exemple #1
0
    string givePlayerAScroll()
    {
        CodeScrollItem item;

        GameObject initial_scroll = new GameObject();

        initial_scroll.name = "InitialScroll";
        initial_scroll.AddComponent <CodeScrollItem>();
        item                  = initial_scroll.GetComponent <CodeScrollItem>();
        item.item_name        = "Blank";
        item.inventoryTexture = Resources.Load("Textures/Scroll") as Texture2D;

        if (!copied_spells.ContainsKey(currentPage().getName()))
        {
            copied_spells.Add(currentPage().name, 0);
        }


        int number_so_far = copied_spells[currentPage().getName()];
        int number        = number_so_far + 1;

        copied_spells[currentPage().name]++;

        CodeScrollItem code_scroll_item_component = initial_scroll.GetComponent <CodeScrollItem>();

        code_scroll_item_component.setCurrentFile(currentPage().getName() + number + ".java");

        code_scroll_item_component.getIDEInput().SetCode(currentPage().code.Replace(currentPage().getName(), currentPage().getName() + number));

        ProgramLogger.LogCode(currentPage().getName() + number, code_scroll_item_component.getIDEInput().GetCode());
        SpellLogger.LogCode(currentPage().getName() + number, code_scroll_item_component.getIDEInput().GetCode());

        GameObject.Find("Inventory").GetComponent <Inventory>().addItem(initial_scroll);
        return(currentPage().getName() + number + ".java");
    }
Exemple #2
0
    void givePlayerASolutionScroll()
    {
        Debug.Log("Trying to give player a scroll, creating a scroll gameobject");
        //Creates the actual scroll
        GameObject solution_scroll = new GameObject();

        solution_scroll.name = "Solution";

        Debug.Log("Adding a codescrollitem");
        //Give the gameobject a CodeScrollItem
        solution_scroll.AddComponent <CodeScrollItem>();

        Debug.Log("Setting fields of code scroll item");
        //Getting the CodeScrollItem so that we can set the file and texture
        CodeScrollItem item = solution_scroll.GetComponent <CodeScrollItem>();

        item.inventoryTexture = Resources.Load("Textures/Scroll") as Texture2D;
        item.setCurrentFile("PracticeRoomSolution.java");
        item.getIDEInput().SetCode("import june.*;\n\npublic class PracticeRoomSolution extends Spell{\n\n    public void cast(){\n\n\n    }\n}");

        Debug.Log("Adding item to inventory");
        //Add the CodeScrollItem to the inventory
        GameObject.Find("Inventory").GetComponent <Inventory>().addItem(solution_scroll);

        Debug.Log("Done!");
    }
Exemple #3
0
    public void addExistingSpell(string name, string code)
    {
        CodeScrollItem item = GameObject.Find("Inventory").GetComponent <Inventory>().getCodeScrollItem(name);

        if (item == null)
        {
            GameObject initial_scroll = new GameObject();
            initial_scroll.name = "InitialScroll";
            initial_scroll.AddComponent <CodeScrollItem>();
            item                  = initial_scroll.GetComponent <CodeScrollItem>();
            item.item_name        = "Blank";
            item.inventoryTexture = Resources.Load("Textures/Scroll") as Texture2D;

            setNameCounter(name);

            CodeScrollItem code_scroll_item_component = initial_scroll.GetComponent <CodeScrollItem>();
            code_scroll_item_component.setCurrentFile(name + ".java");
            //code_scroll_item_component.getIDEInput().SetCode(currentPage().code.Replace(currentPage().getName(), currentPage().getName() + number));
            if (code != "")
            {
                code_scroll_item_component.getIDEInput().SetCode(code);
            }

            ProgramLogger.LogCode(name, code_scroll_item_component.getIDEInput().GetCode());
            GameObject.Find("Inventory").GetComponent <Inventory>().addItem(initial_scroll);

            //string fname = givePlayerAScroll();
            //SpellCopied(currentPage());
        }
        else
        {
            if (code != "")
            {
                item.getIDEInput().SetCode(code);
            }

            ProgramLogger.LogCode(name, item.getIDEInput().GetCode());
        }
    }
Exemple #4
0
    void givePlayerAScroll()
    {
        CodeScrollItem item;

        GameObject initial_scroll = new GameObject();

        initial_scroll.name = "InitialScroll";
        initial_scroll.AddComponent <CodeScrollItem>();
        item                  = initial_scroll.GetComponent <CodeScrollItem>();
        item.item_name        = "Blank";
        item.inventoryTexture = Resources.Load("Textures/Scroll") as Texture2D;

        CodeScrollItem code_scroll_item_component = initial_scroll.GetComponent <CodeScrollItem>();

        code_scroll_item_component.setCurrentFile("Test.java");

        code_scroll_item_component.getIDEInput().SetCode("import june.*;public class Test extends Spell{public void cast(){Enchanted target = getTarget();target.onFire(true);}}");

        GameObject.Find("Inventory").GetComponent <Inventory>().addItem(initial_scroll);
    }
Exemple #5
0
    void givePlayerExistingSpells()
    {
//             System.Diagnostics.Process reader = Shell.shell_no_start("./buildSpellsLog.py", "CodeSpellsProgram.log CodeSpellsSpells.log");
//             reader.Start();
//             reader.WaitForExit();
//             reader.Close();
        Spellbook spellbook = GameObject.Find("Spellbook").GetComponent <Spellbook>();
        Inventory inventory = GameObject.Find("Inventory").GetComponent <Inventory>();

        if (SpellLogger.loggedSpells.Length > 0)
        {
            string[] parts, keyed;
            foreach (string line in SpellLogger.loggedSpells)
            {
                keyed = line.Split(new char[] { ':' });
                if (keyed.Length == 1)      //support for old spell log formats
                {
                    parts = line.Split(new char[] { ',' });
                    if (parts.Length == 1)
                    {
                        spellbook.addExistingSpell(line, "");
                    }
                    else
                    {
                        byte[] bs   = System.Convert.FromBase64String(parts[1].Trim());
                        string code = System.Text.Encoding.UTF8.GetString(bs, 0, bs.Length);
                        spellbook.addExistingSpell(parts[0].Trim(), code);
                    }
                }
                else
                {
                    parts = keyed[1].Split(new char[] { ',' });
                    if (keyed[0] == "code")
                    {
                        byte[] bs   = System.Convert.FromBase64String(parts[1].Trim());
                        string code = System.Text.Encoding.UTF8.GetString(bs, 0, bs.Length);
                        spellbook.addExistingSpell(parts[0].Trim(), code);
                    }
                    else if (keyed[0] == "rename")
                    {
                        string old  = parts[0].Trim();
                        string newn = parts[1].Trim();
                        //this could perhaps instead be accomplished with File.Move(...)
//                         List<GameObject> matching_items = inventory.getMatching(old);
//                         if (matching_items.Count != 1) {
//                             Debug.Log("matching_items length "+matching_items.Count);
//                             continue;
//                         }
                        CodeScrollItem item = inventory.getCodeScrollItem(old).GetComponent <CodeScrollItem>();
                        //CodeScrollItem item = matching_items[0].GetComponent<CodeScrollItem>();
//                         if (item == null) {
//                             Debug.Log("Renaming CodeScrollItem null");
//                             continue;
//                         } else
//                             Debug.Log("Renaming CodeScrollItem "+item.getName());
                        string code = item.getIDEInput().GetCode();
                        item.setCurrentFile(newn + ".java");
                        item.getIDEInput().SetCode(code);
                        spellbook.setNameCounter(newn);
                    }
                    else if (keyed[0] == "delete")
                    {
                        List <GameObject> matching_items = inventory.getMatching(parts[0].Trim());
                        if (matching_items.Count > 0)
                        {
                            Debug.Log("matching items: " + matching_items.Count);
                            inventory.removeItem(matching_items[0]);
                        }
                    }
                }
            }
            inventory.clearRemovedItems();
            foreach (CodeScrollItem item in inventory.getAllCodeScrollItems())
            {
                string code = item.getIDEInput().GetCode();
                SpellLogger.LogCode(item.getName(), code);
            }
        }
//             if (File.Exists("./CodeSpellsSpells.log")) {
//             string[] lines = File.ReadAllLines("./CodeSpellsSpells.log");
//             Spellbook spellbook = GameObject.Find("Spellbook").GetComponent<Spellbook>();
//             string[] parts;
//             foreach (string line in lines) {
//                 parts = line.Split(new char[] {','});
//                 if (parts.Length == 1)
//                         spellbook.addExistingSpell(line, "");
//                     else {
//                         byte[] bs = System.Convert.FromBase64String(parts[1].Trim());
//                         string code = System.Text.Encoding.UTF8.GetString(bs, 0, bs.Length);
//                         spellbook.addExistingSpell(parts[0].Trim(), code);
//                     }
//                 }
//             }
    }