Exemple #1
0
        private void OnUploadDone(bool ok, string error)
        {
            return;

            if (UICommonDialog.ins != null)
            {
                if (ok)
                {
                    MapEditorStroageData.Clear();
                    UICommonDialog.ins.ShowOK("恭喜您设计的地图已上传至服务器,请点击确定返回游戏主界面。", () =>
                    {
                        Application.LoadLevel("GameLogin");
                    });
                }
                else
                {
                    UICommonDialog.ins.ShowOK(error);
                }
            }
        }
Exemple #2
0
        //return to GameLogin
        public void OnClickReturn()
        {
            //打开设置界面
            if (Base.Events.ins != null)
            {
                Base.Events.ins.FireLua("map_editor", "open_settings");
            }
            return;

            if (UICommonDialog.ins != null)
            {
                UICommonDialog.ins.ShowYesNo("您编辑的关卡仍未上传至服务器,是否放弃本次编辑直接返回到主界面?", () =>
                {
                }, () =>
                {
                    // 初始化 共享数据
                    MapEditorStroageData.Clear();
                    Application.LoadLevel("GameLogin");
                }, "继续编辑", "放弃编辑");
            }
        }
Exemple #3
0
        //------------地图额外配置信息



        //---------------------------
        public void Reload(MapEditorStroageData data)
        {
            data.ReloadJson();

            {//reload  spawn point
                var list = this.GetComponentsInChildren <MapObjectSpawnPoint>(true);
                if (list.Length != data._spawn_points.Count)
                {
                    Debug.LogError("0check length is right  when reload MapEditor.Reload  " + list.Length + "      " + data._spawn_points.Count);
                }
                for (int i = 0; i < list.Length; i++)
                {
                    list[i].transform.position = data._spawn_points[i].position;
                }
            }
            {//reload weapon spawn point
                var list = this.GetComponentsInChildren <MapObjectWeaponSpawnPoint>(true);
                if (list.Length != data._weapon_spawn_points.Count)
                {
                    Debug.LogError("1check length is right  when reload MapEditor.Reload  " + list.Length + "      " + data._weapon_spawn_points.Count);
                }
                for (int i = 0; i < list.Length; i++)
                {
                    list[i].transform.position = data._weapon_spawn_points[i].position;
                    list[i]._weapon_ids        = new List <int>(data._weapon_spawn_points[i].ids);
                }
            }

            {//reload layer and map obect and map object decroate
                LayerMgr.ins.Clear();
                foreach (var l in data._layer_objs)
                {
                    LayerMgr.ins.CreateLayer(l);
                    //GameObject layer = new GameObject("layer" + l.layerIndex.ToString());
                    //layer.transform.parent = LayerMgr.ins.transform;
                    //layers[l.layerIndex-1] = layer.transform;
                }

                GameObject obj = null;
                foreach (var p in data._map_objs)
                {
                    if (p.layerIndex > 0)
                    {
                        obj = CreateObject(p.prefab, LayerMgr.ins.GetLayerByIndex(p.layerIndex));
                        if (obj != null)
                        {
                            obj.transform.position = p.position;

                            CustomerPropertyBase com = obj.GetComponent <CustomerPropertyBase>();
                            //自定义属性
                            if ((com != null) && (p.extPropJson != ""))
                            {
                                com.OnDeseriazlie(p.extPropJson);
                            }
                        }
                    }
                    else
                    {
                        obj = CreateObject(p.prefab, LayerMgr.ins.transform);
                        if (obj != null)
                        {
                            obj.transform.position = p.position;

                            CustomerPropertyBase com = obj.GetComponent <CustomerPropertyBase>();
                            //自定义属性
                            if ((com != null) && (p.extPropJson != ""))
                            {
                                com.OnDeseriazlie(p.extPropJson);
                            }
                        }
                    }
                }
            }
            //  this.map_brief = data.map_brief;
            // this.map_name = data.map_name;
            //加载了目标地图 需要恢复状态
            MapEditorStroageData.current_map_brief = data.map_brief;
            MapEditorStroageData.current_map_name  = data.map_name;
            //在编辑地图入口时会设置 MapEditor.MapObjectRoot.record_json ;
#if UNITY_EDITOR
            //修改 边缘 大小
            if (UIPanelMapInfoParkour.ins != null && MapEditor.MapEditorConfig.CurrentMapGameMode == MapGameMode.Parkour)
            {
                UIPanelMapInfoParkour.ins.Reset();
            }
#endif
        }
Exemple #4
0
        void Start()
        {
            //init spawn points
            for (int i = 0; i < 4; i++)
            {
                var obj = MapLoader.ins.LoadMapObjectV1("Common/OneSpawnPoint");

                obj = GameObject.Instantiate <GameObject>(obj);
                //PrefabsMgr.Load("Map/Prefabs/MapObject/Common/OneSpawnPoint");
                var pos = Vector3.zero;
                pos.z = -10f + 6f * i;
                pos.x = 0f;//just for show in the front of everything
                pos.y = 6f;
                obj.transform.position = pos;
                obj.transform.parent   = transform;
                //    obj.GetComponentFully<OneMapObjectBase>().Init(i);
                this.CheckAddObject(obj);
                var scale = obj.transform.localScale;
                scale.x = 50f;
                obj.transform.localScale = scale;
                obj.GetComponentInChildren <TextMesh>().text = (i + 1).ToString() + "P";
            }
            //init weapon spawn point
            int WEAPON_SPAWN_POINT = 4;

            if (MapEditor.MapEditorConfig.CurrentMapGameMode == MapGameMode.Parkour)
            {
                WEAPON_SPAWN_POINT = 20;
            }
            else
            {
#if UNITY_EDITOR
                WEAPON_SPAWN_POINT = 10;
#endif
            }
            EditorWeaponSpawnPointsRoot weapon_spawn_root = this.transform.root.GetComponentInChildren <EditorWeaponSpawnPointsRoot>();
            for (int i = 0; i < WEAPON_SPAWN_POINT; i++)
            {
                var obj =
                    MapLoader.ins.LoadMapObjectV1("Common/OneWeaponSpawnPoint");
                obj = GameObject.Instantiate <GameObject>(obj);
                // PrefabsMgr.Load("Map/Prefabs/MapObject/Common/OneWeaponSpawnPoint");
                var pos = Vector3.zero;
#if UNITY_EDITOR
                pos.z = -15f + 3f * i;
#else
                pos.z = -10f + 6f * i;
#endif
                pos.x = 0f;//just for show in the front of everything
                pos.y = 3f;

                obj.transform.position = pos;
                obj.transform.parent   = transform;
                //    obj.GetComponentFully<OneMapObjectBase>().Init(i);

                if (i >= weapon_spawn_root.transform.childCount)
                {
                    //实际武器点大于阈值 需要扩容  runtime 也要处理这个
                    GameObject x = GameObject.Instantiate <GameObject>(weapon_spawn_root.transform.GetChild(0).gameObject, weapon_spawn_root.transform, false);
                    x.transform.position = pos;
                    x.name = "p" + (i + 1);
                }

                this.CheckAddObject(obj);
                var scale = obj.transform.localScale;
                scale.x = 50f;
                obj.transform.localScale = scale;
                obj.GetComponentInChildren <TextMesh>().text = "武器" + (i + 1).ToString();
            }

            //表示是自动恢复的 或者 编辑的地图
            if (data != null)
            {
                this.Reload(data);
                data = null;
            }
            else
            {
                //新建的地图  需要初始化一下数据  方便 预览图预览什么的
                this.SerializeToJson();
            }
            this.SetSpawnPointVisible(false);
            this.SetWeaponSpawnPointVisible(false);
        }