Example #1
0
        public void LoadListView()
        {
            foreach (var p in _child)
            {
                GameObject.Destroy(p.gameObject);
            }
            _child.Clear();
            var list = MapEditorConfig.GetMapObjectD(UISelectTheme.CurrentSelectedTheme);

            //加载装饰物
            foreach (var p in list)
            {
                var obj = MapLoader.ins.LoadEditorV1("OneMapObject");

                //    PrefabsMgr.Load("Map/Prefabs/Editor/OneMapObject");
                if (obj == null)
                {
                    break;
                }
                obj = GameObject.Instantiate <GameObject>(obj);
                obj.transform.SetParent(_obj_content.transform, false);
                bool ok = obj.GetComponentFully <OneMapObjectBase>().InitData(p);
                if (!ok)
                {
                    GameObject.DestroyImmediate(obj);
                    break;
                }
                _child.Add(obj);
            }
            this.ResizeContent(_child.Count);
        }
Example #2
0
        private void LoadBackGround(int theme)
        {
            var back = this.GetComponentInChildren <SceneLevelBackwardsRenderer>();

            if (back != null)
            {
                var spp = back.GetComponent <SpriteRenderer>();
                if (spp == null)
                {
#if UNITY_EDITOR
                    Debug.LogError("can not find theme bg sprintrenderer");
#endif
                    return;
                }
                var tex = MapLoader.ins.LoadEdotorImageThemeBgV1(theme);; // (Texture2D)PrefabsMgr.Load<Object>("Map/Image/theme_bg/" + map.theme.ToString());
                if (tex == null)
                {
#if UNITY_EDITOR
                    Debug.LogError("can not find theme id=" + theme);
#endif
                    return;
                }
                var sp = Sprite.Create(tex, new Rect(new Vector2(0, 0), new Vector2(tex.width, tex.height)), new Vector2(0.5f, 0.5f));
                spp.sprite = sp;
                back.SetScale(true);
                //紧凑模式 不显示特效
                if (DevConfig.MemoryOrCpuUseageTypeIsTie == false)
                {
                    var bgEffectTransform = back.transform.Find("BgEffect");
                    if (bgEffectTransform != null)
                    {
                        GameObject.Destroy(bgEffectTransform.gameObject);
                    }
                    var needBgEffect = MapEditorConfig.GetNeedBgEffect(theme);
                    if (needBgEffect)
                    {
                        back.SetDefaultBgEffect(false);
                        var effectParent   = back.transform;
                        var bgEffectPrefab = MapLoader.ins.LoadBgEffectV1(theme);
                        if (bgEffectPrefab != null)
                        {
                            var bgEffect = GameObject.Instantiate <GameObject>(bgEffectPrefab, effectParent);
                            bgEffect.name = "BgEffect";
                            bgEffect.transform.localPosition = Vector3.zero;
                        }
                    }
                    else
                    {
                        back.SetDefaultBgEffect(true);
                    }
                }
            }
        }
Example #3
0
        public void ChangeBackGround(int theme)
        {
            var obj = GameObject.Find("Maps/BackGround");

            if (obj == null)
            {
                return;
            }
            var back = obj.GetComponent <SceneLevelBackwardsRenderer>();

            if (back == null)
            {
                return;
            }
            var spp = back.GetComponent <SpriteRenderer>();

            if (spp == null || MapLoader.ins == null)
            {
                return;
            }

            var tex = MapLoader.ins.LoadEdotorImageThemeBgV1(theme);   // (Texture2D)PrefabsMgr.Load<Object>("Map/Image/theme_bg/" + theme.ToString());

            if (tex == null)
            {
                //  Debug.Assert(false);
                return;
            }
            var sp = Sprite.Create(tex, new Rect(new Vector2(0, 0), new Vector2(tex.width, tex.height)), new Vector2(0.5f, 0.5f));

            spp.sprite = sp;
            back.SetScale(true);

            var bgEffectTransform = back.transform.Find("BgEffect");

            if (bgEffectTransform != null)
            {
                GameObject.Destroy(bgEffectTransform.gameObject);
            }
            var needBgEffect = MapEditorConfig.GetNeedBgEffect(theme);

            if (needBgEffect)
            {
                var effectParent   = back.transform;
                var bgEffectPrefab = MapLoader.ins.LoadBgEffectV1(theme);
                if (bgEffectPrefab != null)
                {
                    var bgEffect = GameObject.Instantiate <GameObject>(bgEffectPrefab, effectParent);
                    bgEffect.name = "BgEffect";
                    bgEffect.transform.localPosition = Vector3.zero;
                }
            }
        }
Example #4
0
        private void LoadBackGround(int theme)
        {
            var back = this.GetComponentInChildren <BackGround>();

            if (back != null)
            {
                var spp = back.GetComponent <SpriteRenderer>();

                var tex = MapLoader.ins.LoadEdotorImageThemeBgV1(theme);; // (Texture2D)PrefabsMgr.Load<Object>("Map/Image/theme_bg/" + map.theme.ToString());
                if (tex == null)
                {
                    Debug.Assert(false);
                }
                var sp = Sprite.Create(tex, new Rect(new Vector2(0, 0), new Vector2(tex.width, tex.height)), new Vector2(0.5f, 0.5f));
                spp.sprite = sp;

                var bgEffectTransform = back.transform.Find("BgEffect");
                if (bgEffectTransform != null)
                {
                    GameObject.Destroy(bgEffectTransform.gameObject);
                }
                var needBgEffect = MapEditorConfig.GetNeedBgEffect(theme);
                if (needBgEffect)
                {
                    back.SetDefaultBgEffect(false);
                    var effectParent   = back.transform;
                    var bgEffectPrefab = MapLoader.ins.LoadBgEffectV1(theme);
                    if (bgEffectPrefab != null)
                    {
                        var bgEffect = GameObject.Instantiate <GameObject>(bgEffectPrefab, effectParent);
                        bgEffect.name = "BgEffect";
                        bgEffect.transform.localPosition = Vector3.zero;
                    }
                }
                else
                {
                    back.SetDefaultBgEffect(true);
                }
            }
        }
Example #5
0
        public void LoadListView(LoadType type = LoadType.MapObject)
        {
            img_selected.transform.SetParent(transform, true);

            img_selected.transform.position = Vector3.one * 100000f;
            foreach (var p in _child)
            {
                GameObject.Destroy(p.gameObject);
            }
            _child.Clear();

            if (type == LoadType.Weapon)
            {
                var list = MapEditorConfig.GetWeapons();
                foreach (var id in list)
                {
                    var obj =
                        MapLoader.ins.LoadEditorV1("OneMapObjectWeapon");

                    //PrefabsMgr.Load("Map/Prefabs/Editor/OneMapObjectWeapon");
                    if (obj == null)
                    {
                        break;
                    }
                    obj = GameObject.Instantiate <GameObject>(obj);
                    //   Debug.LogError("load id111111111111111111111111111111111111 = " + id);
                    obj.transform.SetParent(_obj_content.transform, false);
                    bool ok = obj.GetComponentFully <OneMapObjectWeapon>().InitData(id);
                    if (!ok)
                    {
                        GameObject.DestroyImmediate(obj);
                        break;
                    }
                    _child.Add(obj);
                }
            }
            else if (type == LoadType.MapObject)
            {
                var list = MapEditorConfig.GetMapObject(MapEditorConfig.CurrentSelectTheme);
                //加载物件
                foreach (var p in list)
                {
                    var obj = MapLoader.ins.LoadEditorV1("OneMapObject");

                    //PrefabsMgr.Load("Map/Prefabs/Editor/OneMapObject");
                    if (obj == null)
                    {
                        break;
                    }
                    obj = GameObject.Instantiate <GameObject>(obj);
                    obj.transform.SetParent(_obj_content.transform, false);
                    bool ok = obj.GetComponentFully <OneMapObjectBase>().InitData(p);
                    if (!ok)
                    {
                        GameObject.DestroyImmediate(obj);
                        break;
                    }
                    _child.Add(obj);
                }
            }

            this.ResizeContent(_child.Count);
        }
        public void LoadListView(int group_id = 1, LoadType type = LoadType.MapObject)
        {
            _group_id = group_id;

            if (img_selected != null)
            {
                img_selected.transform.SetParent(transform, true);
                img_selected.transform.position = Vector3.one * 100000f;
            }

            foreach (var p in _child)
            {
                GameObject.Destroy(p.gameObject);
            }
            _child.Clear();

            if (type == LoadType.Weapon)
            {
                var list = MapEditorConfig.GetWeapons();
                foreach (var id in list)
                {
                    var obj = MapLoader.ins.LoadEditorV1("OneMapObjectWeapon");

                    if (obj == null)
                    {
                        break;
                    }
                    obj = GameObject.Instantiate <GameObject>(obj);
                    obj.transform.SetParent(_obj_content.transform, false);
                    bool ok = obj.GetComponentFully <OneMapObjectWeapon>().InitData(id);
                    if (!ok)
                    {
                        GameObject.DestroyImmediate(obj);
                        break;
                    }
                    _child.Add(obj);
                }
            }
            else if (type == LoadType.MapObject)
            {
                var list = GameConfig.instance.GetComponentsByGroup(group_id);
                foreach (var value in list)
                {
                    var obj = MapLoader.ins.LoadEditorV1("OneMapObject");

                    if (obj == null)
                    {
                        break;
                    }
                    obj = GameObject.Instantiate <GameObject>(obj);
                    obj.transform.SetParent(_obj_content.transform, false);
                    bool ok = obj.GetComponentFully <OneMapObjectBase>().InitData(value.id);
                    if (!ok)
                    {
                        GameObject.DestroyImmediate(obj);
                        break;
                    }

                    //切换分组重新设置之前已经选中的组件
                    if ((value.id == MapEditorInputMgr.ins.currentSelectId) &&
                        (MapEditorInputMgr.ins.currentSelectId > 0))
                    {
                        if (img_selected != null)
                        {
                            img_selected.transform.SetParent(obj.transform, true);
                            img_selected.transform.localPosition = Vector3.zero;
                        }
                    }
                    _child.Add(obj);
                }


                //重新加载正常组件,进入正常组件编辑模式
                if (list.Length > 0)
                {
                    MapEditorUIMgr.ins.GetPanel <UIPanelMapEditor>().ChangeToEditObjectMode();
                }
            }
            else if (type == LoadType.SpawPoint)
            {
                var list = GameConfig.instance.GetComponentsByGroup(group_id);
                foreach (var value in list)
                {
                    var obj = MapLoader.ins.LoadEditorV1("OneMapObject");

                    if (obj == null)
                    {
                        break;
                    }
                    obj = GameObject.Instantiate <GameObject>(obj);
                    obj.transform.SetParent(_obj_content.transform, false);
                    bool ok = obj.GetComponentFully <OneMapObjectBase>().InitData(value.id);
                    if (!ok)
                    {
                        GameObject.DestroyImmediate(obj);
                        break;
                    }
                    //切换分组重新设置之前已经选中的组件
                    if ((value.id == MapEditorInputMgr.ins.currentSelectId) &&
                        (MapEditorInputMgr.ins.currentSelectId > 0))
                    {
                        if (img_selected != null)
                        {
                            img_selected.transform.SetParent(obj.transform, true);
                            img_selected.transform.localPosition = Vector3.zero;
                        }
                    }
                    _child.Add(obj);
                }
            }

            this.ResizeContent(_child.Count);

            if (_child.Count > 0)
            {
                this.Text_none.gameObject.SetActive(false);
            }
            else
            {
                this.Text_none.gameObject.SetActive(true);
            }
        }