void LoadWorlds()
    {
        worldsManager       = GameObject.Find("/Managers/WorldsManager").GetComponent <WorldsManager>();
        mapInfos            = worldsManager.GetWorldList().ToArray();
        mapSelectionButtons = new MapSelectionButton[mapInfos.Length];

        foreach (Transform child in mapsHolder)
        {
            Destroy(child.gameObject);
        }

        int i = 0;

        foreach (var mapInfo in mapInfos)
        {
            GameObject         newMap             = Instantiate(mapPrefab, mapsHolder);
            MapSelectionButton mapSelectionButton = newMap.GetComponent <MapSelectionButton>();

            mapSelectionButtons[i] = mapSelectionButton;
            mapSelectionButton.Init(mapInfo.name, mapInfo.folderName, mapInfo.date);

            Func <int, Action> CreateClickAction = (index) => () => SelectMap(index);

            mapSelectionButton.OnClicked += CreateClickAction(i);

            i++;
        }
    }
示例#2
0
 void Start()
 {
     _mainMapCanvas = FindObjectOfType <MainMapCanvasManager>();
     _worldsManager = new WorldsManager(GetGameManager().User);
     CreateLevelNodes();
     _mainMapCanvas.ShowWorldAtSceneInit(_gameManager.CurrentViewingWorld);
 }
        public WorldController GetWorld()
        {
            if (WorldID == -1)
            {
                WorldID = WorldsManager.ActualWorldID;
            }

            return(WorldsManager.GetWorldController(WorldID));
        }
示例#4
0
    void Start()
    {
        _mainMapCanvas = FindObjectOfType <MainMapCanvasManager>();
        _gameManagers  = FindObjectsOfType <GameManager>();

        _worldsManager = new WorldsManager(GetRealGameManager().User);


        CreateLevelNodes();
    }
        public static void save_colors()
        {
            if (p_c__ == null)
            {
                return;
            }



            WorldInfo i = WorldsManager.GetWorldInfo(API_WE_Mod.API_WE.n_w);


            var path = Storage.CombinePaths(n_w, "Project.xml");

            if (!Storage.FileExists(path))
            {
                return;
            }
            var xelement = (XElement)null;

            using (var stream = Storage.OpenFile(path, OpenFileMode.Read))
            {
                xelement = XmlUtils.LoadXmlFromStream(stream, null, true);
            }

            var gameInfoNode     = GetGameInfoNode(xelement);
            var valuesDictionary = new ValuesDictionary();

            valuesDictionary.ApplyOverrides(gameInfoNode);


            i.WorldSettings.Save(valuesDictionary, true);
            Log.Warning("cur palette " + valuesDictionary.GetValue <ValuesDictionary>("Palette").GetValue <string>("Colors"));



            valuesDictionary.SetValue("Palette", Save());


            gameInfoNode.RemoveNodes();
            valuesDictionary.Save(gameInfoNode);

            Log.Warning("cur palette 2 " + valuesDictionary.GetValue <ValuesDictionary>("Palette").GetValue <string>("Colors"));
            using (var stream = Storage.OpenFile(path, OpenFileMode.Create))
            {
                XmlUtils.SaveXmlToStream(xelement, stream, null, true);
            }
            Log.Warning("Color saves");
            p_c__ = null;
        }
示例#6
0
 public WorldController GetWorld()
 {
     return(WorldsManager.GetWorldController(WorldID));
 }
 void Start()
 {
     worldsManager = GameObject.Find("/Managers/WorldsManager").GetComponent <WorldsManager>();
 }
    private void UpdateList()
    {
        WorldsManager.UpdateWorldsList();
        List <ListItem> list = new List <ListItem>();

        if (m_filter == ExternalContentType.BlocksTexture || m_filter == ExternalContentType.Unknown)
        {
            BlocksTexturesManager.UpdateBlocksTexturesList();
            foreach (string name2 in BlocksTexturesManager.BlockTexturesNames)
            {
                list.Add(new ListItem
                {
                    Name         = name2,
                    IsBuiltIn    = BlocksTexturesManager.IsBuiltIn(name2),
                    Type         = ExternalContentType.BlocksTexture,
                    DisplayName  = BlocksTexturesManager.GetDisplayName(name2),
                    CreationTime = BlocksTexturesManager.GetCreationDate(name2),
                    UseCount     = WorldsManager.WorldInfos.Count((WorldInfo wi) => wi.WorldSettings.BlocksTextureName == name2)
                });
            }
        }
        if (m_filter == ExternalContentType.CharacterSkin || m_filter == ExternalContentType.Unknown)
        {
            CharacterSkinsManager.UpdateCharacterSkinsList();
            foreach (string name in CharacterSkinsManager.CharacterSkinsNames)
            {
                list.Add(new ListItem
                {
                    Name         = name,
                    IsBuiltIn    = CharacterSkinsManager.IsBuiltIn(name),
                    Type         = ExternalContentType.CharacterSkin,
                    DisplayName  = CharacterSkinsManager.GetDisplayName(name),
                    CreationTime = CharacterSkinsManager.GetCreationDate(name),
                    UseCount     = WorldsManager.WorldInfos.Count((WorldInfo wi) => wi.PlayerInfos.Any((PlayerInfo pi) => pi.CharacterSkinName == name))
                });
            }
        }
        if (m_filter == ExternalContentType.FurniturePack || m_filter == ExternalContentType.Unknown)
        {
            FurniturePacksManager.UpdateFurniturePacksList();
            foreach (string furniturePackName in FurniturePacksManager.FurniturePackNames)
            {
                list.Add(new ListItem
                {
                    Name         = furniturePackName,
                    IsBuiltIn    = false,
                    Type         = ExternalContentType.FurniturePack,
                    DisplayName  = FurniturePacksManager.GetDisplayName(furniturePackName),
                    CreationTime = FurniturePacksManager.GetCreationDate(furniturePackName)
                });
            }
        }
        list.Sort(delegate(ListItem o1, ListItem o2)
        {
            if (o1.IsBuiltIn && !o2.IsBuiltIn)
            {
                return(-1);
            }
            if (o2.IsBuiltIn && !o1.IsBuiltIn)
            {
                return(1);
            }
            if (string.IsNullOrEmpty(o1.Name) && !string.IsNullOrEmpty(o2.Name))
            {
                return(-1);
            }
            return((!string.IsNullOrEmpty(o1.Name) && string.IsNullOrEmpty(o2.Name)) ? 1 : string.Compare(o1.DisplayName, o2.DisplayName));
        });
        m_contentList.ClearItems();
        foreach (ListItem item in list)
        {
            m_contentList.AddItem(item);
        }
    }