Esempio n. 1
0
    public CopyConfig GetCopyConfigByIndex(int index)
    {
        CopyConfig config = null;

        for (int i = 0; i < copyConfig.Count; i++)
        {
            if (index == i)
            {
                JsonData copyJsonData = copyConfig[i] as JsonData;

                if (copyJsonData == null)
                {
                    return(null);
                }

                config = new CopyConfig();

                config.id   = (int)copyJsonData["copyid"];
                config.name = (string)copyJsonData["copyname"];
                config.exp  = (int)copyJsonData["exp"];
                config.gold = (int)copyJsonData["gold"];
                config.box  = (int)copyJsonData["box"];

                config.maps.Add((int)copyJsonData["map1"]);
                config.maps.Add((int)copyJsonData["map2"]);
                config.maps.Add((int)copyJsonData["map3"]);
                config.maps.Add((int)copyJsonData["map4"]);
                config.maps.Add((int)copyJsonData["map5"]);
                break;
            }
        }

        return(config);
    }
Esempio n. 2
0
    public CopyConfig GetCopyConfig(int copyId)
    {
        CopyConfig config = new CopyConfig();

        for (int i = 0; i < copyConfig.Count; i++)
        {
            JsonData copyJsonData = copyConfig[i] as JsonData;

            if ((int)copyJsonData["copyid"] == copyId)
            {
                config.id   = (int)copyJsonData["copyid"];
                config.name = (string)copyJsonData["copyname"];
                config.exp  = (int)copyJsonData["exp"];
                config.gold = (int)copyJsonData["gold"];
                config.box  = (int)copyJsonData["box"];

                config.maps.Add((int)copyJsonData["map1"]);
                config.maps.Add((int)copyJsonData["map2"]);
                config.maps.Add((int)copyJsonData["map3"]);
                config.maps.Add((int)copyJsonData["map4"]);
                config.maps.Add((int)copyJsonData["map5"]);
                break;
            }
        }

        return(config);
    }
Esempio n. 3
0
        public HttpResponseMessage GetConfig(CopyModel model)
        {
            CopyConfig config = new CopyConfig()
            {
                TemplateMetaDataSheet  = model.TemplateSheet.SheetName,
                ConstraintChangesSheet = model.ConstraintSheet != null ? model.ConstraintSheet.SheetName : string.Empty
            };

            foreach (var templateColumn in model.TemplateSheet.Columns)
            {
                CopyConfig.ColumnConfig columnConfig = new CopyConfig.ColumnConfig()
                {
                    Letter      = templateColumn.Letter,
                    MappedField = templateColumn.MappedField.ToString()
                };

                config.TemplateColumns.Add(columnConfig);
            }

            if (model.ConstraintSheet != null)
            {
                foreach (var templateColumn in model.ConstraintSheet.Columns)
                {
                    CopyConfig.ColumnConfig columnConfig = new CopyConfig.ColumnConfig()
                    {
                        Letter      = templateColumn.Letter,
                        MappedField = templateColumn.MappedField.ToString()
                    };

                    config.ConstraintColumns.Add(columnConfig);
                }
            }

            XmlSerializer serializer = new XmlSerializer(typeof(CopyConfig));

            using (MemoryStream ms = new MemoryStream())
            {
                serializer.Serialize(ms, config);

                HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.OK);
                message.Content = new StreamContent(new MemoryStream(ms.ToArray()));
                message.Content.Headers.ContentType                 = new MediaTypeHeaderValue("text/xml");
                message.Content.Headers.ContentLength               = ms.Length;
                message.Content.Headers.ContentDisposition          = new ContentDispositionHeaderValue("attachment");
                message.Content.Headers.ContentDisposition.FileName = "config.xml";

                return(message);
            }
        }
Esempio n. 4
0
    public static void Build()
    {
        Constance.RUNNING = true;
        state             = BattleState.STATE_START_ANIMATION;
        //battle.ground.Clear();

        objectPositionTable = new Dictionary <Charactor, ArrayList>();
        positionObjectTable = new Dictionary <Vector2, ArrayList>();


        //battle.ground.Clear();

        copyConfig = Config.GetInstance().GetCopyConfig(copyId);

        int      groundId     = (int)copyConfig.maps[groundIndex];
        JsonData groundConfig = Config.GetInstance().GetGroundConfig(groundId);

        groundMapConfig = groundConfig["map"];
        battle.ground.drawGround(groundMapConfig);

        h = battle.ground.h;
        v = battle.ground.v;

        countdownTime = (int)groundConfig["limitTime"];


        prepareMonsters  = new ArrayList();
        prepareFollowers = new ArrayList();

        JsonData monsterConfigs = groundConfig["monster"];

        for (int i = 0; i < monsterConfigs.Count; i++)
        {
            JsonData monsterConfig = monsterConfigs[i];
            prepareMonsters.Add(monsterConfig);
        }

        JsonData followerConfigs = groundConfig["follower"];

        for (int i = 0; i < followerConfigs.Count; i++)
        {
            JsonData followerConfig = followerConfigs[i];
            prepareFollowers.Add(followerConfig);
        }
    }
Esempio n. 5
0
        public bool OnGUI()
        {
            StartConfig startConfig = this.GetParent <StartConfig>();

            GUILayout.BeginHorizontal(GUILayout.Height(16));

            if (this.level > 0)
            {
                string s = "";
                for (int i = 1; i < this.level; ++i)
                {
                    s += $"    ";
                }
                GUILayout.Label(s, GUILayout.Width(20 * this.level));
            }

            {
                GUILayout.BeginHorizontal(GUILayout.Width(240), GUILayout.Height(16));
                this.isFold = EditorGUILayout.Foldout(isFold, $"子配置数量:{startConfig.List.Count}");

                if (GUILayout.Button("添加子配置", GUILayout.Height(16), GUILayout.Width(75)))
                {
                    StartConfig s = new StartConfig();
                    startConfig.Add(s);
                    s.AddComponentNoPool <StartConfigDrawer, int>(this.level + 1);

                    for (int i = 0; i < startConfig.List.Count; ++i)
                    {
                        startConfig.List[i].Id = i + 1;
                    }

                    this.isFold = true;
                    return(false);
                }
                if (GUILayout.Button("上", GUILayout.Height(16), GUILayout.Width(30)))
                {
                    StartConfig parentStartConfig = startConfig.GetParent <StartConfig>();
                    int         index             = parentStartConfig.List.IndexOf(startConfig);
                    if (index == 0)
                    {
                        return(true);
                    }

                    parentStartConfig.List.Remove(startConfig);
                    parentStartConfig.List.Insert(index - 1, startConfig);
                    for (int i = 0; i < parentStartConfig.List.Count; ++i)
                    {
                        parentStartConfig.List[i].Id = i + 1;
                    }

                    return(false);
                }
                if (GUILayout.Button("下", GUILayout.Height(16), GUILayout.Width(30)))
                {
                    StartConfig parentStartConfig = startConfig.GetParent <StartConfig>();
                    int         index             = parentStartConfig.List.IndexOf(startConfig);
                    if (index == parentStartConfig.List.Count - 1)
                    {
                        return(true);
                    }
                    parentStartConfig.List.Remove(startConfig);
                    parentStartConfig.List.Insert(index + 1, startConfig);
                    for (int i = 0; i < parentStartConfig.List.Count; ++i)
                    {
                        parentStartConfig.List[i].Id = i + 1;
                    }
                    return(false);
                }
                GUILayout.EndHorizontal();
            }

            {
                GUILayout.BeginHorizontal(GUILayout.Width(50));
                GUILayout.Label($"Id: ");
                startConfig.Id = EditorGUILayout.LongField(startConfig.Id, GUILayout.Width(30));
                GUILayout.EndHorizontal();
            }

            {
                GUILayout.BeginHorizontal(GUILayout.Width(200));
                ProcessConfig processConfig = startConfig.GetComponent <ProcessConfig>();
                if (processConfig != null)
                {
                    GUILayout.Label($"  ProcessConfig(", this.style);
                    GUILayout.Label($"服务器IP: ");
                    processConfig.ServerIP = EditorGUILayout.TextField(processConfig.ServerIP, GUILayout.Width(100));
                    GUILayout.Label($"),", this.style);
                }
                GUILayout.EndHorizontal();
            }

            {
                GUILayout.BeginHorizontal(GUILayout.Width(200));
                SceneConfig sceneConfig = startConfig.GetComponent <SceneConfig>();
                if (sceneConfig != null)
                {
                    GUILayout.Label($"  SceneConfig(", this.style);
                    GUILayout.Label($"SceneType: ");
                    sceneConfig.SceneType = (SceneType)EditorGUILayout.EnumPopup(sceneConfig.SceneType, GUILayout.Width(100));
                    GUILayout.Label($"Name: ");
                    sceneConfig.Name = EditorGUILayout.TextField(sceneConfig.Name, GUILayout.Width(100));
                    GUILayout.Label($"),", this.style);
                }
                GUILayout.EndHorizontal();
            }

            {
                GUILayout.BeginHorizontal(GUILayout.Width(150));
                InnerConfig innerConfig = startConfig.GetComponent <InnerConfig>();
                if (innerConfig != null)
                {
                    GUILayout.Label($"  InnerConfig(", this.style);
                    GUILayout.Label($"内网地址:");
                    innerConfig.Address = EditorGUILayout.TextField(innerConfig.Address, GUILayout.Width(120));
                    GUILayout.Label($"),", this.style);
                }

                GUILayout.EndHorizontal();
            }
            {
                GUILayout.BeginHorizontal(GUILayout.Width(350));
                OuterConfig outerConfig = startConfig.GetComponent <OuterConfig>();
                if (outerConfig != null)
                {
                    GUILayout.Label($"  OuterConfig(", this.style);
                    GUILayout.Label($"外网地址:");
                    outerConfig.Address = EditorGUILayout.TextField(outerConfig.Address, GUILayout.Width(120));
                    GUILayout.Label($"外网地址2:");
                    outerConfig.Address2 = EditorGUILayout.TextField(outerConfig.Address2, GUILayout.Width(120));
                    GUILayout.Label($"),", this.style);
                }

                GUILayout.EndHorizontal();
            }

            {
                GUILayout.BeginHorizontal(GUILayout.Width(50));
                CopyConfig copyConfig = startConfig.GetComponent <CopyConfig>();
                if (copyConfig != null)
                {
                    GUILayout.Label($"  CopyConfig(", this.style);
                    GUILayout.Label($"),", this.style);
                }

                GUILayout.EndHorizontal();
            }

            {
                GUILayout.BeginHorizontal(GUILayout.Width(50));
                MapConfig mapConfig = startConfig.GetComponent <MapConfig>();
                if (mapConfig != null)
                {
                    GUILayout.Label($"  MapConfig(", this.style);
                    GUILayout.Label($"MapType: ");
                    mapConfig.MapType = (MapType)EditorGUILayout.EnumPopup(mapConfig.MapType, GUILayout.Width(100));
                    GUILayout.Label($"),", this.style);
                }

                GUILayout.EndHorizontal();
            }

            {
                GUILayout.BeginHorizontal(GUILayout.Width(350));
                ClientConfig clientConfig = startConfig.GetComponent <ClientConfig>();
                if (clientConfig != null)
                {
                    GUILayout.Label($"  ClientConfig(", this.style);
                    GUILayout.Label($"连接地址:");
                    clientConfig.Address = EditorGUILayout.TextField(clientConfig.Address, GUILayout.Width(120));
                    GUILayout.Label($"),", this.style);
                }

                DBConfig dbConfig = startConfig.GetComponent <DBConfig>();
                if (dbConfig != null)
                {
                    GUILayout.Label($"  DBConfig(", this.style);
                    GUILayout.Label($"连接串:");
                    dbConfig.ConnectionString = EditorGUILayout.TextField(dbConfig.ConnectionString);

                    GUILayout.Label($"DBName:");
                    dbConfig.DBName = EditorGUILayout.TextField(dbConfig.DBName);
                    GUILayout.Label($"),", this.style);
                }
                GUILayout.EndHorizontal();
            }

            {
                GUILayout.BeginHorizontal(GUILayout.Width(200), GUILayout.Height(16));
                this.st = (StartConfigComponentType)EditorGUILayout.EnumPopup(this.st, GUILayout.Width(100));

                if (GUILayout.Button("添加组件", GUILayout.Height(16)))
                {
                    Assembly assembly = Assembly.GetAssembly(typeof(Game));
                    Type     type     = assembly.GetType($"ETModel.{this.st.ToString()}");
                    startConfig.AddComponent(type);
                }

                if (GUILayout.Button("删除组件", GUILayout.Height(16)))
                {
                    Assembly assembly = Assembly.GetAssembly(typeof(Game));
                    Type     type     = assembly.GetType($"ETModel.{this.st.ToString()}");
                    startConfig.RemoveComponent(type);
                }

                if (GUILayout.Button("删除该行配置", GUILayout.Height(16)))
                {
                    startConfig.GetParent <StartConfig>().Remove(startConfig);
                    return(false);
                }

                GUILayout.EndHorizontal();
            }

            GUILayout.EndHorizontal();

            if (this.isFold)
            {
                foreach (StartConfig child in startConfig.List)
                {
                    if (child.GetComponent <StartConfigDrawer>()?.OnGUI() == false)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
 public Task CopyConfigAsync(string id, CopyConfig copy)
 {
     throw new NotImplementedException();
 }