Esempio n. 1
0
    private void script2ui(int next)
    {
        if (0 <= next && next < cmdList.Count)
        {
            ScriptCmd scriptCmd = cmdList[next];
            switch (scriptCmd.GetName())
            {
            case "EnableScript":
                break;

            case "ShowDialog":
                break;

            case "PlaySound":
                break;

            case "Exit":
                break;

            case "ShowScript":
                break;

            case "SetMission":
                break;

            case "Sleep":
                floatTmp = ((Sleep)scriptCmd).Howlong.ToString("0.##");
                break;
            }
        }
    }
Esempio n. 2
0
    private bool ui2script(int prev)
    {
        bool result = true;

        if (0 <= prev && prev < cmdList.Count)
        {
            ScriptCmd scriptCmd = cmdList[prev];
            switch (scriptCmd.GetName())
            {
            case "Sleep":
                try
                {
                    if (floatTmp.Length <= 0)
                    {
                        floatTmp = "0";
                    }
                    ((Sleep)scriptCmd).Howlong = float.Parse(floatTmp);
                    return(result);
                }
                catch (Exception ex)
                {
                    MessageBoxMgr.Instance.AddMessage(StringMgr.Instance.Get("FLOAT_PARSE_FAIL"));
                    Debug.LogError(ex.Message.ToString());
                    return(false);
                }
            }
        }
        return(result);
    }
Esempio n. 3
0
    private void ExecuteCommand(ScriptCmd cmd)
    {
        if (cmd != null)
        {
            if (GlobalVars.Instance.tutorFirstScriptOn)
            {
                TutorHelpDialog tutorHelpDialog = (TutorHelpDialog)DialogManager.Instance.Popup(DialogManager.DIALOG_INDEX.TUTORHELP, exclusive: true);
                if (tutorHelpDialog != null)
                {
                    tutorHelpDialog.InitDialog();
                    GlobalVars.Instance.tutorFirstScriptOn = false;
                }
            }
            switch (cmd.GetName())
            {
            case "EnableScript":
                EnableScript(((EnableScript)cmd).Id, ((EnableScript)cmd).Enable);
                break;

            case "ShowDialog":
                ShowDialog(((ShowDialog)cmd).Speaker, ((ShowDialog)cmd).Dialog);
                break;

            case "PlaySound":
                PlaySound(((PlaySound)cmd).Index);
                break;

            case "Sleep":
                Sleep(((Sleep)cmd).Howlong);
                break;

            case "Exit":
                Exit();
                break;

            case "ShowScript":
                ShowScript(((ShowScript)cmd).Id, ((ShowScript)cmd).Visible);
                break;

            case "GiveWeapon":
                GiveWeapon(((GiveWeapon)cmd).WeaponCode);
                break;

            case "TakeAwayAll":
                TakeAwayAll();
                break;

            case "SetMission":
                SetMission(((SetMission)cmd).Progress, ((SetMission)cmd).Title, ((SetMission)cmd).SubTitle, ((SetMission)cmd).Tag);
                break;
            }
        }
    }
Esempio n. 4
0
 public BfScript(string _alias, bool _enableOnAwake, bool _visibleOnAwake, string _cmdList)
 {
     _alias         = _alias.Trim(default(char));
     alias          = _alias;
     enableOnAwake  = _enableOnAwake;
     visibleOnAwake = _visibleOnAwake;
     cmdList        = new List <ScriptCmd>();
     string[] array = _cmdList.Split(ScriptCmd.CmdDelimeters, StringSplitOptions.RemoveEmptyEntries);
     if (array != null)
     {
         for (int i = 0; i < array.Length; i++)
         {
             ScriptCmd item = ScriptCmdFactory.Create(array[i]);
             cmdList.Add(item);
         }
     }
 }
Esempio n. 5
0
    private void DoParameters()
    {
        if (0 <= selected && selected < cmdList.Count)
        {
            ScriptCmd scriptCmd = cmdList[selected];
            switch (scriptCmd.GetName())
            {
            case "EnableScript":
                DoEnableScript((EnableScript)scriptCmd);
                break;

            case "ShowDialog":
                DoShowDialog((ShowDialog)scriptCmd);
                break;

            case "PlaySound":
                DoPlaySound((PlaySound)scriptCmd);
                break;

            case "Sleep":
                DoSleep((Sleep)scriptCmd);
                break;

            case "Exit":
                DoExit((Exit)scriptCmd);
                break;

            case "ShowScript":
                DoShowScript((ShowScript)scriptCmd);
                break;

            case "GiveWeapon":
                DoGiveWeapon((GiveWeapon)scriptCmd);
                break;

            case "TakeAwayAll":
                DoTakeAwayAll((TakeAwayAll)scriptCmd);
                break;

            case "SetMission":
                DoSetMission((SetMission)scriptCmd);
                break;
            }
        }
    }
Esempio n. 6
0
    public override bool DoDialog()
    {
        if (null == prop || brick == null)
        {
            return(true);
        }
        string  text   = "ID: " + prop.Seq.ToString() + " (Scriptable)";
        bool    result = false;
        GUISkin skin   = GUI.skin;

        GUI.skin = GUISkinFinder.Instance.GetGUISkin();
        GUI.Box(new Rect(4f, 4f, 64f, 64f), brick.Icon);
        GUI.Label(new Rect(72f, 4f, size.x - 76f, 36f), text, "BigLabel");
        alias          = GUI.TextField(new Rect(72f, 40f, 256f, 26f), alias, maxAlias);
        enableOnAwake  = GUI.Toggle(new Rect(336f, 47f, 128f, 16f), enableOnAwake, StringMgr.Instance.Get("ENABLE_ON_AWAKE"));
        visibleOnAwake = GUI.Toggle(new Rect(336f, 64f, 128f, 16f), visibleOnAwake, StringMgr.Instance.Get("VISIBLE_ON_AWAKE"));
        int  count    = cmdList.Count;
        Rect rect     = new Rect(0f, 0f, 48f, (float)(count * 48));
        Rect position = new Rect(4f, 112f, size.x / 2f - 8f, 208f);

        Texture2D[] array = new Texture2D[cmdList.Count];
        for (int i = 0; i < cmdList.Count; i++)
        {
            array[i] = ScriptResManager.Instance.CmdIcon[cmdList[i].GetIconIndex()];
        }
        scrollPosition = GUI.BeginScrollView(position, scrollPosition, rect);
        int num = selected;

        selected = GUI.SelectionGrid(rect, selected, array, 1);
        if (selected != num)
        {
            if (ui2script(num))
            {
                script2ui(selected);
            }
            else
            {
                selected = num;
            }
        }
        Color   color  = GUI.color;
        Vector2 vector = new Vector2(52f, 0f);

        for (int j = 0; j < cmdList.Count; j++)
        {
            if (selected == j)
            {
                GUI.color = new Color(0.83f, 0.49f, 0.29f);
            }
            else
            {
                GUI.color = Color.white;
            }
            GUI.Label(new Rect(vector.x, vector.y, size.x / 2f - 60f, 48f), cmdList[j].GetName(), "Label");
            vector.y += 48f;
        }
        GUI.color = color;
        GUI.EndScrollView();
        if (GUI.Button(new Rect(4f, 72f, 24f, 24f), "+"))
        {
            ((ScriptCmdSelector)DialogManager.Instance.Popup(DialogManager.DIALOG_INDEX.SCRIPT_CMD_SELECTOR, exclusive: false))?.InitDialog(this);
        }
        if (GUI.Button(new Rect(32f, 72f, 24f, 24f), "x"))
        {
            cmdList.RemoveAt(selected);
            VerifySelected();
        }
        if (GUI.Button(new Rect(60f, 72f, 24f, 24f), "u") && 0 < selected)
        {
            ScriptCmd item = cmdList[selected];
            cmdList.RemoveAt(selected--);
            cmdList.Insert(selected, item);
            VerifySelectedVisible(208f);
        }
        if (GUI.Button(new Rect(88f, 72f, 24f, 24f), "d") && cmdList.Count > 1 && selected < cmdList.Count - 1)
        {
            ScriptCmd item2 = cmdList[selected];
            cmdList.RemoveAt(selected++);
            cmdList.Insert(selected, item2);
            VerifySelectedVisible(208f);
        }
        DoParameters();
        if (GUI.Button(new Rect(312f, 357f, 90f, 21f), StringMgr.Instance.Get("OK")) && CheckAlias() && ui2script(selected))
        {
            result = true;
            string text2 = string.Empty;
            for (int k = 0; k < cmdList.Count; k++)
            {
                text2 += cmdList[k].GetDescription();
                if (k < cmdList.Count - 1)
                {
                    text2 += ScriptCmd.CmdDelimeters[0];
                }
            }
            CSNetManager.Instance.Sock.SendCS_UPDATE_SCRIPT_REQ(prop.Seq, alias, enableOnAwake, visibleOnAwake, text2);
        }
        if (GUI.Button(new Rect(412f, 357f, 90f, 21f), StringMgr.Instance.Get("CANCEL")))
        {
            result = true;
        }
        if (!ContextMenuManager.Instance.IsPopup)
        {
            WindowUtil.EatEvent();
        }
        GUI.skin = skin;
        return(result);
    }
Esempio n. 7
0
 public void AddCmd(ScriptCmd cmd)
 {
     cmdList.Add(cmd);
 }
Esempio n. 8
0
    public static ScriptCmd Create(string description)
    {
        ScriptCmd result = null;

        string[] array = description.Split(ScriptCmd.ArgDelimeters, StringSplitOptions.RemoveEmptyEntries);
        if (array != null && array.Length > 0)
        {
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = array[i].Trim();
            }
            string text = array[0].ToLower();
            switch (text)
            {
            case "enablescript":
                if (array.Length >= 3)
                {
                    EnableScript enableScript = new EnableScript();
                    enableScript.Id     = int.Parse(array[1]);
                    enableScript.Enable = bool.Parse(array[2]);
                    result = enableScript;
                }
                break;

            case "showdialog":
                if (array.Length >= 2)
                {
                    ShowDialog showDialog = new ShowDialog();
                    showDialog.Speaker = int.Parse(array[1]);
                    showDialog.Dialog  = ((array.Length < 3) ? string.Empty : array[2]);
                    result             = showDialog;
                }
                break;

            case "playsound":
                if (array.Length >= 2)
                {
                    PlaySound playSound = new PlaySound();
                    playSound.Index = int.Parse(array[1]);
                    result          = playSound;
                }
                break;

            case "sleep":
                if (array.Length >= 2)
                {
                    Sleep sleep = new Sleep();
                    sleep.Howlong = float.Parse(array[1]);
                    result        = sleep;
                }
                break;

            case "exit":
            {
                Exit exit = new Exit();
                result = exit;
                break;
            }

            case "showscript":
                if (array.Length >= 3)
                {
                    ShowScript showScript = new ShowScript();
                    showScript.Id      = int.Parse(array[1]);
                    showScript.Visible = bool.Parse(array[2]);
                    result             = showScript;
                }
                break;

            case "giveweapon":
            {
                GiveWeapon giveWeapon = new GiveWeapon();
                giveWeapon.WeaponCode = ((array.Length < 2) ? string.Empty : array[1]);
                result = giveWeapon;
                break;
            }

            case "takeawayall":
            {
                TakeAwayAll takeAwayAll = new TakeAwayAll();
                result = takeAwayAll;
                break;
            }

            case "setmission":
            {
                SetMission setMission = new SetMission();
                if (array.Length >= 2)
                {
                    setMission.Progress = array[1];
                    setMission.Title    = array[2];
                    setMission.SubTitle = array[3];
                    if (array.Length > 4 && array[4].Length > 0)
                    {
                        setMission.Tag = array[4];
                    }
                }
                else
                {
                    setMission.Progress = string.Empty;
                    setMission.Title    = string.Empty;
                    setMission.SubTitle = string.Empty;
                    setMission.Tag      = string.Empty;
                }
                result = setMission;
                break;
            }
            }
        }
        return(result);
    }