示例#1
0
    /// <summary>
    /// 读取数据
    /// </summary>
    /// <param name="data"></param>
    public void ReadData(string data)
    {
        synthesisDataStructList.Clear();
        byte[]       dataBytes = Encoding.UTF8.GetBytes(data);
        MemoryStream ms        = new MemoryStream(dataBytes);

        using (StreamReader sr = new StreamReader(ms))
        {
            string readLine = null;
            string tempData = null;
            SynthesisDataStruct tempSynthesisDataStruct = null;
            while ((readLine = sr.ReadLine()) != null)
            {
                switch (readLine.Trim())
                {
                case StartFlag:
                    tempData = "";
                    tempSynthesisDataStruct = new SynthesisDataStruct();
                    break;

                case EndFlag:
                    tempSynthesisDataStruct.SetData(tempData);
                    synthesisDataStructList.Add(tempSynthesisDataStruct);
                    break;

                default:
                    tempData += readLine + "\r\n";
                    break;
                }
            }
        }
    }
示例#2
0
    /// <summary>
    /// 添加一个合成结构对象
    /// </summary>
    /// <param name="synthesisDataStruct"></param>
    public void AddSynthesisDataStruct(SynthesisDataStruct synthesisDataStruct)
    {
        int index = synthesisDataStructList.FindIndex(temp => temp.id == synthesisDataStruct.id);

        if (index < 0)
        {
            synthesisDataStructList.Add(synthesisDataStruct);
        }
        else
        {
            synthesisDataStructList[index] = synthesisDataStruct;
        }
    }
        public DataEditorForm(TreeNode treeNode)
        {
            InitializeComponent();
            this.treeNode            = treeNode;
            this.synthesisDataStruct = treeNode.Tag as SynthesisDataStruct;
            if (itemTreeNodeArray == null)
            {
                itemTreeNodeArray = GetItemTypeTreeNodes();
            }
            TreeView_ItemType.Nodes.AddRange(itemTreeNodeArray);
            Init();

            GroupBox_From.AllowDrop = true;
            GroupBox_To.AllowDrop   = true;
        }
    /// <summary>
    /// 显示当前选择节点的说明
    /// </summary>
    private void ShowNowSelectTreeNodeExplan()
    {
        //清理之前的数据
        int count = detailedInformationTrans.childCount;

        Transform[] childsTrans = Enumerable.Range(0, count).Select(temp => detailedInformationTrans.GetChild(temp)).ToArray();
        foreach (Transform childTrans in childsTrans)
        {
            if (Transform.Equals(detailedInformationTestObj, childTrans))//不删除例子
            {
                continue;
            }
            GameObject.DestroyImmediate(childTrans.gameObject);
        }
        //通过节点的数据判断该节点是什么节点
        UITreeNode selectNode = synthesisItemTree.SelectNode;

        //如果是SynthesisDataStruct数据的节点则显示SynthesisDataStruct数据的内容
        if (selectNode.value != null && selectNode.value.GetType().Equals(typeof(SynthesisDataStruct)))
        {
            SynthesisDataStruct synthesisDataStruct = selectNode.value as SynthesisDataStruct;
            //添加条目
            Action <string> AddExplanTitleAction = (title) =>
            {
                GameObject createTitle = GameObject.Instantiate <GameObject>(detailedInformationTestObj);
                createTitle.transform.SetParent(detailedInformationTrans);
                createTitle.GetComponent <Text>().text = title;
                createTitle.SetActive(true);
            };
            //输入结构
            AddExplanTitleAction("合成条件:");
            foreach (SynthesisDataStruct.SynthesisItemStruct synthesisItemStruct in synthesisDataStruct.inputStruct)
            {
                int nowCount = playerState.PlayerAllGoods.Count(temp => temp.GoodsInfo.EnumGoodsType == synthesisItemStruct.itemType);
                //这里需要转换成对应的名字,这里暂时用枚举名
                AddExplanTitleAction(synthesisItemStruct.itemType + ":" + nowCount + "/" + synthesisItemStruct.num);
            }
            //输出结构
            AddExplanTitleAction("合成物品:");
            //这里需要转换成对应的名字,这里暂时用枚举名
            AddExplanTitleAction(synthesisDataStruct.outputStruct.itemType.ToString());
            //自动对齐
            VerticalLayoutGroup verticalLayoutGroup = detailedInformationTrans.GetComponent <VerticalLayoutGroup>();
            verticalLayoutGroup.SetLayoutHorizontal();
            verticalLayoutGroup.SetLayoutVertical();
        }
    }
        private void Init()
        {
            TextBox_SynthesisItem.Text = SynthesisDataStruct.GetEnumExplan(synthesisItemStruct.itemType); //材料或成品类型
            if (synthesisItemStruct.num <= 0)
            {
                synthesisItemStruct.num = 1;
            }
            else if (synthesisItemStruct.num > 100)
            {
                synthesisItemStruct.num = 100;
            }
            NumericUpDown_Num.Value         = synthesisItemStruct.num;
            NumericUpDown_Num.ValueChanged += (sender, e) => { synthesisItemStruct.num = (int)NumericUpDown_Num.Value; };
            Action <ComboBox, Type> InitComboBoxAction = (cbo, type) =>
            {
                FieldInfo[] fieldInfo = type.GetFields().Where(temp => !temp.Name.Equals("value__")).ToArray();
                var         tempDic   = fieldInfo.Select(temp => new { name = temp.Name, attr = temp.GetCustomAttributes(typeof(FieldExplanAttribute), false).Select(_temp => _temp as FieldExplanAttribute).FirstOrDefault() });
                DataTable   dt        = new DataTable();
                dt.Columns.Add("Value");
                dt.Columns.Add("Display");
                foreach (var tempKeyValue in tempDic)
                {
                    DataRow dr = dt.NewRow();
                    dr[0] = tempKeyValue.name;
                    dr[1] = tempKeyValue.attr != null?tempKeyValue.attr.GetExplan() : tempKeyValue.name;

                    dt.Rows.Add(dr);
                }
                cbo.DataSource    = dt;
                cbo.ValueMember   = "Value";
                cbo.DisplayMember = "Display";
            };

            InitComboBoxAction(ComboBox_MinQuality, typeof(EnumQualityType));
            InitComboBoxAction(ComboBox_MaxQuality, typeof(EnumQualityType));
            ComboBox_MinQuality.SelectedValue         = synthesisItemStruct.minQuality.ToString();
            ComboBox_MaxQuality.SelectedValue         = synthesisItemStruct.maxQuality.ToString();
            ComboBox_MinQuality.SelectedIndexChanged += (sender, e) =>
            {
                try { synthesisItemStruct.minQuality = (EnumQualityType)Enum.Parse(typeof(EnumQualityType), ComboBox_MinQuality.SelectedValue.ToString()); } catch { }
            };
            ComboBox_MaxQuality.SelectedIndexChanged += (sender, e) =>
            {
                try { synthesisItemStruct.maxQuality = (EnumQualityType)Enum.Parse(typeof(EnumQualityType), ComboBox_MaxQuality.SelectedValue.ToString()); } catch { }
            };
        }
示例#6
0
        /// <summary>
        /// 添加节点
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void 添加节点ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode selectNode = TreeView_Main.SelectedNode;

            if (selectNode != null)
            {
                Stack <TreeNode>  treeNodeStack      = new Stack <TreeNode>();
                Action <TreeNode> selectParentAction = null;
                selectParentAction = (thisNode) =>
                {
                    treeNodeStack.Push(thisNode);
                    if (thisNode.Parent != null)
                    {
                        selectParentAction(thisNode.Parent);
                    }
                };
                selectParentAction(selectNode);
                if (treeNodeStack.Count >= 2)
                {
                    TreeNode          synthesisTypeNode = treeNodeStack.Pop();
                    TreeNode          synthesisItemNode = treeNodeStack.Pop();
                    EnumSynthesisType synthesisType     = (EnumSynthesisType)Enum.Parse(typeof(EnumSynthesisType), synthesisTypeNode.Tag.ToString());
                    EnumSynthesisItem synthesisItem     = (EnumSynthesisItem)Enum.Parse(typeof(EnumSynthesisItem), synthesisItemNode.Tag.ToString());
                    int id = startID++;
                    SynthesisDataStruct synthesisDataStruct = new SynthesisDataStruct();
                    synthesisDataStruct.id            = id;
                    synthesisDataStruct.name          = "";
                    synthesisDataStruct.time          = 1;
                    synthesisDataStruct.synthesisType = synthesisType;
                    synthesisDataStruct.synthesisItem = synthesisItem;
                    synthesisDataStruct.inputStruct   = new SynthesisDataStruct.SynthesisItemStruct[0];
                    synthesisDataAnalysis.AddSynthesisDataStruct(synthesisDataStruct);
                    TreeNode treeNode = new TreeNode();
                    treeNode.Name = id.ToString();
                    treeNode.Tag  = synthesisDataStruct;
                    treeNode.Text = synthesisDataStruct.ToStringSimple();
                    synthesisItemNode.Nodes.Add(treeNode);
                }
            }
        }
示例#7
0
 /// <summary>
 /// 移除一个合成结构对象
 /// </summary>
 /// <param name="synthesisDataStruct"></param>
 public void RemoveSynthesisDataStruct(SynthesisDataStruct synthesisDataStruct)
 {
     synthesisDataStructList.Remove(synthesisDataStruct);
 }
 public int SynthesisGoods(SynthesisDataStruct synthesisDataStruct)
 {
     throw new Exception("未实现合成");
 }