void Start()
        {
            if (dialogView == null)
            {
                dialogView = FindObjectOfType <DialogViewer>();
            }
            if (dict == null)
            {
                dict = GetComponentInChildren <ScriptedDictionary>();
            }
            Dialog[] dialogs;
            //NonStandard.Show.Log(knownAssets.JoinToString(", ", ta => ta.name));
            //NonStandard.Show.Log(root.name+":" + root.text.Length);
            Tokenizer tokenizer = new Tokenizer();

            if (dict != null)
            {
                Global.GetComponent <ScriptedDictionaryManager>().SetMainDicionary(dict);
            }
            try {
                CodeConvert.TryParse(root.text, out dialogs, dict.Dictionary, tokenizer);
                tokenizer.ShowErrorTo(NonStandard.Show.Error);
                if (dialogs == null)
                {
                    return;
                }
                //NonStandard.Show.Log("dialogs: [" + d.Stringify(pretty:true)+"]");
                this.dialogs.AddRange(dialogs);
                ResolveTemplatedDialogs(this.dialogs);
            } catch (System.Exception e) {
                NonStandard.Show.Log("~~~#@Start " + e);
            }
            //NonStandard.Show.Log("finished initializing " + this);
            //NonStandard.Show.Log(this.dialogs.JoinToString(", ", dialog => dialog.name));
            // execute all "__init__" dialogs
            ScriptedDictionaryManager m = Global.Get <ScriptedDictionaryManager>();
            object standardScope        = m.Main;     //Commander.Instance.GetScope();

            for (int i = 0; i < this.dialogs.Count; ++i)
            {
                Dialog dialog = this.dialogs[i];
                if (!dialog.name.StartsWith("__init__"))
                {
                    continue;
                }

                //NonStandard.Show.Log("initializing "+dialog.name);
                Tokenizer tok = new Tokenizer();
                dialog.ExecuteCommands(tok, standardScope);
                if (tok.HasError())
                {
                    tok.ShowErrorTo(NonStandard.Show.Warning);
                }
            }
            //NonStandard.Show.Log(standardScope.Stringify(pretty: true));
        }
Example #2
0
 public void GenerateMore(int len)
 {
     for (int i = npcs.Count; i < len; ++i)
     {
         Material       mat = game.idolCreator.idolMaterials[i];
         GameObject     npc = Instantiate(prefab_npcPlayer.gameObject);
         ParticleSystem ps  = npc.GetComponentInChildren <ParticleSystem>();
         if (ps != null)
         {
             ps.name = mat.name;
             ParticleSystem.MainModule m = ps.main;
             m.startColor = mat.color;
         }
         npc.name = prefab_npcPlayer.name + i;
         ScriptedDictionary dict = npc.GetComponentInChildren <ScriptedDictionary>();
         if (dict != null)
         {
             dict["mycolor"] = mat.name;
         }
         string foundName;
         if (npcNames.TryGetValue(mat.name, out foundName))
         {
             npc.name = foundName;
         }
         Interact3dItem i3d = npc.GetComponentInChildren <Interact3dItem>();
         i3d.Text = npc.name;
         i3d.internalState.size            = 1.75f;
         i3d.internalState.fontCoefficient = .7f;
         i3d.OnInteract = () => {
             DialogManager.Instance.dialogWithWho = npc;
             DialogManager.Instance.Show();
             Tokenizer tok = new Tokenizer();
             DialogManager.Instance.StartDialog(npc, tok, "dialog" + mat.name);
             tok.ShowErrorTo(DialogManager.ActiveDialog.ShowError);
             ps.Stop();
         };
         npcs.Add(npc.GetComponent <CharacterRoot>());
     }
 }
Example #3
0
    public void ClaimPlayer(Command.Exec e)
    {
        GameObject npc = DialogManager.Instance.dialogWithWho;

        Global.GetComponent <Team>().AddMember(npc);
        MazeLevel      ml    = Global.GetComponent <MazeLevel>();
        Discovery      d     = EnsureExplorer(npc);
        ParticleSystem ps    = npc.GetComponentInChildren <ParticleSystem>();
        Color          color = ps.main.startColor.color;

        d.discoveredFloor = Color.Lerp(d.discoveredFloor, color, 0.25f);
        d.discoveredWall  = Color.Lerp(d.discoveredWall, color, 0.25f);
        d.discoveredRamp  = Color.Lerp(d.discoveredRamp, color, 0.25f);
        d.maze            = ml;
        Global.GetComponent <ConditionCheck>().DoActivateTest();
        InventoryCollector inv = npc.GetComponentInChildren <InventoryCollector>();

        inv.inventory  = InventoryManager.main;
        inv.autoPickup = true;
        ScriptedDictionary dict = npc.GetComponent <ScriptedDictionary>();

        dict["cooperative"] = true;
    }
        public void ExecuteScriptOnInventoryVariables(string script)
        {
            ScriptedDictionary variables = GetDictionaryOfInventory();

            Commander.Instance.EnqueueRun(new Commander.Instruction(script, variables));
        }