Exemple #1
0
        private void _calcPosition()
        {
            this.position.width  = BTNode.EditWidth;
            this.position.height = BTNode.EditHeight;

            Vector2 ptStart = this.getEditPtStart();

            ptStart.y += 22;             //method ddl

            MethodDefine mf = MethodDefine.LstMethods[0];

            if (this._curMethod == null)
            {
                if (this._cfg != null && this._cfg.Keys.Contains("method"))
                {
                    this._curMethod = (string)this._cfg ["method"];
                }
            }

            if (this._curMethod != null)
            {
                mf = MethodDefine.LstMethods.Find(delegate(MethodDefine s) {
                    return(s.strName == this._curMethod);
                });
            }
            ptStart.y += mf.lstArgType.Count * 21;

            this.position.height = ptStart.y - this.position.y + 2;
            LogUtil.Debug(this.position.height);
        }
Exemple #2
0
 protected bool OnSelMethodChange(MethodDefine mf)
 {
     this.ClearEditCtrls();
     this._curMethod = mf.strName;
     this.FillEditCtrls();
     this.eWin.Repaint();
     return(false);
 }
Exemple #3
0
        public static void initMethodDefine()
        {
            MethodDefine.LstMethods = new List <MethodDefine>();

            string dirCfg = "";

            LogUtil.Debug("xxxxxCategory:" + MethodDefine.AgentCategory);
            if (MethodDefine.AgentCategory == "Player")
            {
                dirCfg = "Assets/Editor/BTEditor/Assets/methodcfg_player.json";
            }
            else
            {
                dirCfg = "Assets/Editor/BTEditor/Assets/methodcfg_enemy.json";
            }

            FileInfo fi = new FileInfo(dirCfg);

            if (!fi.Exists)
            {
                return;
            }

            StreamReader r      = File.OpenText(dirCfg);
            string       strCfg = r.ReadToEnd();

            r.Close();

            JsonData d = JsonMapper.ToObject(strCfg);

            for (int i = 0; i < d.Count; i++)
            {
                JsonData m = d[i];

                MethodDefine md = new MethodDefine();
                md.strName        = (string)m["name"];
                md.strDisplayName = (string)m["displayname"];

                for (int j = 1; j < 10; j++)
                {
                    string stra = "arg" + j.ToString();
                    string at   = "";
                    if (m.Keys.Contains(stra))
                    {
                        at = (string)m[stra];
                    }
                    if (at == "")
                    {
                        break;
                    }

                    md.lstArgType.Add(at);
                }
                MethodDefine.LstMethods.Add(md);
            }
        }
Exemple #4
0
        protected override void OnProcBtnSave(JsonWriter w)
        {
            base.OnProcBtnSave(w);

            w.WritePropertyName("revert");
            bool   bRevert = this._ckRevert.IsCheck;
            string str     = bRevert ? "y" : "n";

            w.Write(str);

            w.WritePropertyName("method");
            MethodDefine md = this.ddlMethod.selectItem;

            w.Write(md.strName);

            for (int i = 0; i < this.lstTextfieldArgs.Count; i++)
            {
                Textfield tf = this.lstTextfieldArgs[i];
                if (tf.text != "")
                {
                    w.WritePropertyName("arg" + (i + 1).ToString());
                    string strType = (string)md.lstArgType[i];
                    if (strType == "float")
                    {
                        w.Write(double.Parse(tf.text));
                    }
                    else if (strType == "bool")
                    {
                        if (tf.text == "true")
                        {
                            w.Write(true);
                        }
                        else
                        {
                            w.Write(false);
                        }
                    }
                    else if (strType == "int")
                    {
                        w.Write(int.Parse(tf.text));
                    }
                    else if (strType == "string")
                    {
                        w.Write(tf.text);
                    }
                }
            }
        }
Exemple #5
0
        public void SaveCommon(JsonWriter w)
        {
            this.Copy2Out(w, "method", "string");

            if (this._cfg != null && this._cfg.Keys.Contains("method"))
            {
                MethodDefine mf = MethodDefine.LstMethods.Find(delegate(MethodDefine s) {
                    return(s.strName == (string)this._cfg["method"]);
                });

                for (int i = 0; i < mf.lstArgType.Count; i++)
                {
                    string sa = "arg" + (i + 1).ToString();

                    string t = mf.lstArgType[i];
                    //LogUtil.Debug(t);
                    this.Copy2Out(w, sa, t);
                }
            }
        }
Exemple #6
0
        private void _FillMethod()
        {
            Vector2 ptStart = this.getEditPtStart();
            Rect    rcLM    = new Rect(ptStart.x, ptStart.y, 40, 20);
            Label   lmethod = new Label("方法:", this.eWin, rcLM, null);

            this._editCtrls.Add(lmethod);

            Rect rcDDL = new Rect(ptStart.x + 42, ptStart.y, this.position.width - 46 - this._rcBar.width, 22);

            ptStart.y += 22;

            int          nIndex = 0;
            MethodDefine mf     = MethodDefine.LstMethods[0];

            if (this._curMethod == null)
            {
                if (this._cfg != null && this._cfg.Keys.Contains("method"))
                {
                    this._curMethod = (string)this._cfg ["method"];
                }
            }

            if (this._curMethod != null)
            {
                nIndex = MethodDefine.LstMethods.FindIndex(delegate(MethodDefine s) {
                    return(s.strName == this._curMethod);
                });
                mf = MethodDefine.LstMethods.Find(delegate(MethodDefine s) {
                    return(s.strName == this._curMethod);
                });
            }

            ddlMethod = new DropdownList <MethodDefine>(this.eWin, rcDDL, null, MethodDefine.LstMethods, nIndex);
            ddlMethod.OnSelectChange = new DropdownList <MethodDefine> .DropDownListDelegate(OnSelMethodChange);

            this._editCtrls.Add(ddlMethod);

            for (int i = 0; i < mf.lstArgType.Count; i++)
            {
                string strArg = "";
                string ka     = "arg" + (i + 1).ToString();
                if (this._cfg != null && this._cfg.Keys.Contains(ka))
                {
                    string t = mf.lstArgType[i];
                    LogUtil.Debug(t);
                    if (t == "string")
                    {
                        strArg = (string)this._cfg[ka];
                    }
                    else if (t == "float")
                    {
                        try{
                            strArg = ((double)this._cfg[ka]).ToString();
                        }catch (Exception e) {
                            int tmp = (int)this._cfg[ka];
                            strArg = ((double)tmp).ToString();
                        }
                    }
                    else if (t == "int")
                    {
                        strArg = ((int)this._cfg[ka]).ToString();
                    }
                    else if (t == "bool")
                    {
                        strArg = (bool)this._cfg[ka] ? "true" : "false";
                    }
                    else
                    {
                        LogUtil.Debug("Error arguement type" + t.ToString());
                    }
                }

                Rect  rcLA  = new Rect(ptStart.x, ptStart.y + i * 22, 40, 20);
                Label label = new Label("参数" + (i + 1).ToString() + ":", this.eWin, rcLA, null);
                this._editCtrls.Add(label);

                Rect      rcTF = new Rect(ptStart.x + 42, ptStart.y + i * 21, this.position.width - 46 - this._rcBar.width, 20);
                Textfield tf   = new Textfield(strArg, this.eWin, rcTF, null);
                this.lstTextfieldArgs.Add(tf);
                this._editCtrls.Add(tf);
            }
            ptStart.y += mf.lstArgType.Count * 21;
        }