Пример #1
0
        private void LoadTreeFromBattleObject(Game game, BattleObject activeBattleObject)
        {
            Tree<string> optionTree = new Tree<string>("root");
            optionTree.AddChild("Attack");
            foreach(var attack in activeBattleObject.AttackList) {
                optionTree.GetFirstChild("Attack").AddChild(attack);
            }

            optionTree.AddChild("Magic");
            foreach(var magic in activeBattleObject.MagicList) {
                optionTree.GetFirstChild("Magic").AddChild(magic);
            }

            optionTree.AddChild("Item");
            foreach(var item in activeBattleObject.ItemList) {
                optionTree.GetFirstChild("Item").AddChild(item);
            }

            _menuItemView.SetTree(optionTree);
            _menuItemView.SetFirstSelected();
        }
Пример #2
0
    /// <summary>
    /// Устанавливает новый код и автоматически распознаёт его содержимое
    /// </summary>
    /// <param name="_code"></param>
    public void SetCode(string _code)
    {
        env = new Environs();
        program = new ProgramStruct();
        program.program_tree = GetProgramTree(_code.ToLower());
        program.program_tree.Dump();
        program.consts = GetTypesStruct(program.program_tree, "const");
        program.types = GetTypesStruct(program.program_tree, "type");
        program.vars = GetTypesStruct(program.program_tree, "var");

        CheckConflictNames();

        cursor = GetElementCursor(program.program_tree, "begin");
        if (cursor.HasChild())
            cursor = cursor.GetFirstChild();
        else
            cursor = null;

        InitConstant();
        InitVariable();
    }