Ejemplo n.º 1
0
        private void btn_SaveTemplate_Click(object sender, EventArgs e)
        {
            var currentId = (Guid)editorTabPageControl.SelectedTab.Tag;

            if (tabPageMapper.ContainsKey(currentId))
            {
                if (tabPageMapper[currentId].Item2 == Enums.TabPageType.Template && tabPageMapper[currentId].Item3 != null)
                {
                    SaveTemplate form = new SaveTemplate();
                    form.CreateTemplateEvent += HandleCreateTemplateEvent;
                    var parentId = ((Template)tabPageMapper[currentId].Item3).ParentNodeId;
                    var node     = GetTemplateNodeByParentId(parentId);
                    if (node != null)
                    {
                        form.PopulateSelectedTemplateInfo(parentId, node.Text, "", DateTime.Now.ToShortDateString());
                        form.ShowDialog();
                    }
                }
                else
                {
                    UIHelper.ShowInformationMessage("当前页没有父节点ID。");
                }
            }
            else
            {
                UIHelper.ShowInformationMessage("当前页没有父节点ID。");
            }
        }
Ejemplo n.º 2
0
    public void Save(string levelName)
    {
        SaveTemplate temp = new SaveTemplate();
        int size =Instances.gridManager.size;
        temp.gridSize = size;
        temp.levelName = levelName;
        temp.objects = new List<ObjectTemplate>();

        for (int i = 0; i < size; i++)
        {

            for (int j = 0; j < size; j++)
            {

                GameObject g = Instances.gridManager.getObject(new Vector2(i,j));
                if( g != null)
                {
                    ObjectTemplate t = new ObjectTemplate();
                    t.name = g.name;
                    t.x = i;
                    t.y = j;
                    t.rot = Mathf.RoundToInt(g.transform.rotation.eulerAngles.y);
                    temp.objects.Add(t);
                }
            }

        }
        SavedGameContainer s = new SavedGameContainer();
        s.savedTemplate=temp;
        s.Save("Assets/Resources/Saved Data/"+levelName+".xml");
    }