Пример #1
0
    void RefreshLevelList()
    {
        //Rafraichir la list avec les nouveau Levels
        string[] foundGUIDAssets;

        foundGUIDAssets = AssetDatabase.FindAssets("t:LevelData");

        levelListData.leveldatas = new LevelData[foundGUIDAssets.Length];

        foreach (string zzz in foundGUIDAssets)
        {
            Debug.Log("LevelData" + AssetDatabase.GUIDToAssetPath(zzz));
        }

        for (int i = 0; i < foundGUIDAssets.Length; i++)
        {
            LevelData zzz = (LevelData)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(foundGUIDAssets[i]), typeof(LevelData));
            levelListData.leveldatas[i] = zzz;
            Debug.Log("Saved" + levelListData.leveldatas[i]);
        }

        LevelListData dataLevelList = (LevelListData)AssetDatabase.LoadAssetAtPath(UsefulPath.listLevelData, typeof(LevelListData));

        dataLevelList.leveldatas = levelListData.leveldatas;
        EditorUtility.SetDirty(dataLevelList);
    }
Пример #2
0
        public override void Start()
        {
            base.Start();

            //WorldData worldData = WorldList.Worlds[WorldToLoad.Value];
            WorldData worldData = DataMgr.Instance.CurrentWorldData;

            Levels = worldData.LevelList;

            _selectedLevel = Levels.Levels[LoadLevel.Value];

            WorldName.text = worldData.WorldName.ToUpper();
            LevelName.text = string.Format("Level {0}", LoadLevel.Value + 1);

            if (_selectedLevel != null)
            {
                if (_selectedLevel.Photo == null)
                {
                    if (!string.IsNullOrEmpty(_selectedLevel.PhotoUrl))
                    {
                        // Format photo string URL here.
                    }
                    else
                    {
                        Debug.LogErrorFormat("Cannot load photo at URL: {0}!", _selectedLevel.Photo);
                    }
                }

                LevelImage.sprite = Sprite.Create(_selectedLevel.Photo, new Rect(0, 0, _selectedLevel.Photo.width, _selectedLevel.Photo.height), Vector2.zero);

                LevelDescription.text = _selectedLevel.Description;
            }
        }
Пример #3
0
    void Awake()
    {
        //Charger la list de LevelDatas
        LevelListData dataLevelList = (LevelListData)AssetDatabase.LoadAssetAtPath(UsefulPath.listLevelData, typeof(LevelListData));

        levelList = dataLevelList.leveldatas;

        //Charger la list de GameModeDatas
        GameModeListData dataGameModeList = (GameModeListData)AssetDatabase.LoadAssetAtPath(UsefulPath.listGameModeData, typeof(GameModeListData));

        gameModeList = dataGameModeList.gameModeDatas;
    }
Пример #4
0
        public IEnumerator ChangeLevel(int index)
        {
            Debug.Log(string.Format("Loading level {0}", index));

            WorldData CurrentWorld = null;

            if (CNV_TOOL)
            {
                CurrentWorld = CNVWorldList.Worlds[WorldToLoad.Value];
            }
            else
            {
                if (ConnectionMgr.OFFLINE_DEBUG)
                {
                    CurrentWorld = WorldList.Worlds[WorldToLoad.Value];
                }
                else
                {
                    CurrentWorld = DataMgr.Instance.CurrentWorldData;
                }
            }

            Levels = CurrentWorld.LevelList;

            // Set current level based on selection.
            CurrentLevel = Levels.Levels[index];

            // Download texture for the game.
            if (!CNV_TOOL)
            {
                if (CurrentLevel.Photo == null)
                {
                    if (!string.IsNullOrEmpty(CurrentLevel.PhotoUrl))
                    {
                        // Format photo string URL here.
                    }
                    else
                    {
                        Debug.LogErrorFormat("Cannot load photo at URL: {0}!", CurrentLevel.Photo);
                    }
                }
            }

            ToolMgr.Instance.TurnOffAll();
            ImageMgr.Instance.FlagAsDirty();

            yield return(null);

            ToolMgr.Instance.TurnOn(CurrentLevel.Tool);
        }
Пример #5
0
    //LEVEL LIST DATA
    void InitLevelListData()
    {
        LevelListData tempLevelList = (LevelListData)AssetDatabase.LoadAssetAtPath(UsefulPath.listLevelData, typeof(LevelListData));

        if (tempLevelList == null)
        {
            listAlreadyExists = false;
            levelListData     = (LevelListData)ScriptableObject.CreateInstance(typeof(LevelListData));
        }
        else
        {
            listAlreadyExists = true;
            levelListData     = tempLevelList;
        }
    }
Пример #6
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Load level list
            Task.Run(async() =>
            {
                var sf = await Package.Current.InstalledLocation.TryGetItemAsync(@"Content\Levels\LevelList.xml") as StorageFile;

                // Parse xml, if it's malformed we can't do anything with the game anyway so we just crash
                using (var stream = await sf.OpenStreamForReadAsync())
                {
                    XmlSerializer xml = new XmlSerializer(typeof(LevelListData));
                    levelList         = xml.Deserialize(stream) as LevelListData;
                }
            }).Wait();

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // Load game over screen
            var gameOver = new GameOver();

            RegisterGlobalEntity(gameOver);

            // Create some global Entities
            player = new Player();
            RegisterGlobalEntity(player);
            var ui = new GameUI();

            RegisterGlobalEntity(ui);
            var pf = new Pathfinding();

            RegisterGlobalEntity(pf);

            // Load first level in the list
            LoadLevel(levelList.Start());
        }