Example #1
0
        public static IEnumerable <GameFileInfo> GetGameFilesInfo(bool isSteam)
        {
            var filesInfo = new GameFilesInfo();

            //Load default manifest
            foreach (var fileInfo in FilesInfoFromGameManifest("production", 6148, isSteam))
            {
                if (filesInfo.FileInfo.ContainsKey(fileInfo.FileName))
                {
                    filesInfo.FileInfo[fileInfo.FileName] = fileInfo;
                }
                else
                {
                    filesInfo.FileInfo.Add(fileInfo.FileName, fileInfo);
                }
            }

            //Override for celeste file
            foreach (var fileInfo in FilesInfoOverrideFromCelesteXml())
            {
                if (filesInfo.FileInfo.ContainsKey(fileInfo.FileName))
                {
                    filesInfo.FileInfo[fileInfo.FileName] = fileInfo;
                }
                else
                {
                    filesInfo.FileInfo.Add(fileInfo.FileName, fileInfo);
                }
            }

            return(filesInfo.FilesInfoArray);
        }
Example #2
0
        public static IEnumerable <GameFileInfo> GetGameFilesInfo(bool isSteam, bool isLegacyXLive)
        {
            var filesInfo = new GameFilesInfo();

            //Load default manifest
            foreach (var fileInfo in FilesInfoFromGameManifest("production", 6148, isSteam))
            {
                if (filesInfo.FileInfo.ContainsKey(fileInfo.FileName.ToLower()))
                {
                    filesInfo.FileInfo[fileInfo.FileName.ToLower()] = fileInfo;
                }
                else
                {
                    filesInfo.FileInfo.Add(fileInfo.FileName.ToLower(), fileInfo);
                }
            }

            //Override for celeste file
            foreach (var fileInfo in FilesInfoOverrideFromCelesteXml(false))
            {
                if (filesInfo.FileInfo.ContainsKey(fileInfo.FileName.ToLower()))
                {
                    filesInfo.FileInfo[fileInfo.FileName.ToLower()] = fileInfo;
                }
                else
                {
                    filesInfo.FileInfo.Add(fileInfo.FileName.ToLower(), fileInfo);
                }
            }

            if (isLegacyXLive)
            {
                return(filesInfo.FileInfo.Values);
            }

            //Override for celeste file (beta)
            try
            {
                foreach (var fileInfo in FilesInfoOverrideFromCelesteXml(true))
                {
                    if (filesInfo.FileInfo.ContainsKey(fileInfo.FileName.ToLower()))
                    {
                        filesInfo.FileInfo[fileInfo.FileName.ToLower()] = fileInfo;
                    }
                    else
                    {
                        filesInfo.FileInfo.Add(fileInfo.FileName.ToLower(), fileInfo);
                    }
                }
            }
            catch (Exception)
            {
                //Better to ignore any error for this one!
            }

            return(filesInfo.FileInfo.Values);
        }
Example #3
0
    /// <summary>
    /// Awake function of GameManager. Checks if another instance of this GameObject exists and
    /// if not, initializes all required atributes and values of the GameManager, creating a new
    /// one.
    ///
    /// If the GameManager already exists, destroy this gameObject.
    /// </summary>
    private void Awake()
    {
        // If GameManager is not created and initialized...
        if (_instance == null)
        {
            // Set this GameManager as instance
            _instance = this;

            // Set this gameObject to not Destroy when changing between scenes
            DontDestroyOnLoad(gameObject);

            _gc = LoadingFiles.ReadGameConfig();

            // Store canvas' scaling reference resolution
            _scalingReferenceResolution = _cnv.GetComponent <CanvasScaler>().referenceResolution;

            // Initialize Scaling with cam values and scalingreference values
            _scalator = new Scaling(new Vector2(Screen.width, Screen.height), _scalingReferenceResolution, (int)_cam.orthographicSize);

            // Search all panels for later calculation
            ReloadPanels();

            // Load all AssetBundles
            _lab = new LoadAssetBundle();

            // Depending on OS system, load from a different path and using different techniques
#if !UNITY_EDITOR && UNITY_ANDROID
            _lab.LoadBundlesAndroid(Application.streamingAssetsPath + "/AssetBundles/");
#else
            _lab.LoadBundlesWindows(Application.streamingAssetsPath + "/AssetBundles/");
#endif

            // Initialize random value
            _rnd = new Random();

            // Load gameInfo previously generated, data driven information
            _gi = LoadingFiles.ReadGameInfo();

            // Set all values of this information
            SetGameInfo();

            // Get Player information and store it
            _currentPlayerData = LoadingFiles.ReadPlayerData(_maxDifficulty);

            // Set the time waiting for challenge info
            SetTimeForChallenge();
        }
        else if (_instance != this)
        {
            Destroy(gameObject);
        }
    }
Example #4
0
    public static void CreateInfo()
    {
        // GameInfo class for Serialization
        GameFilesInfo inf = new GameFilesInfo();
        // Directory info for retrieving number of files
        DirectoryInfo dir;

        // Check how many Difficulty files are in Levels folder
        dir = new DirectoryInfo("Assets/StreamingAssets/Levels/Difficulties/");
        FileInfo[] infoDifficulties = dir.GetFiles("*.json");

        // Retrieve the number of pathSkins there are for later calculations
        dir = new DirectoryInfo("Assets/Prefabs/Game/Paths/PathSkin/");
        FileInfo[] infoPathSkins = dir.GetFiles("*.prefab");

        // Number of skins for the touching screen feedback
        dir = new DirectoryInfo("Assets/Prefabs/Game/Touch/");
        FileInfo[] infoTouchSkins = dir.GetFiles("*.prefab");

        // Tile skins defined in the Prefab folder
        dir = new DirectoryInfo("Assets/Prefabs/Game/Tiles/TileSkin/");
        FileInfo[] infoTileSkins = dir.GetFiles("*.prefab");

        // Save that info in the class
        inf._numDifficulties = infoDifficulties.Length;
        inf._numPathSkins    = infoPathSkins.Length;
        inf._numTouchSkins   = infoTouchSkins.Length;
        inf._numTileSkins    = infoTileSkins.Length;

        // Create JSON object
        string gameInfo = JsonUtility.ToJson(inf);

        // Write everything in the file
        FileStream   file = File.Create("Assets/StreamingAssets/game_data.json");
        StreamWriter sw   = new StreamWriter(file);

        sw.Write(gameInfo);

        // Close everything
        sw.Close();
        sw.Dispose();
        file.Close();
        file.Dispose();
    }
Example #5
0
    /// <summary>
    /// Reads the information estracted from the directories and files of
    /// the game. Used to control values.
    /// </summary>
    /// <returns>GameFilesInfo info of the files in the directories</returns>
    public static GameFilesInfo ReadGameInfo()
    {
        // Value that will be returned
        GameFilesInfo info = new GameFilesInfo();

        // Path to the file and string to store the text for later conversion
        string path     = Application.streamingAssetsPath + "/game_data.json";
        string gameData = null;

#if !UNITY_EDITOR && UNITY_ANDROID
        // Extract form .jar file as an url
        WWW loadingAssets = new WWW(path);
        while (!loadingAssets.isDone)
        {
        }

        // Save that text
        gameData = loadingAssets.text;
#else
        // Check if the file in the path exists
        if (File.Exists(path))
        {
            gameData = File.ReadAllText(path);
        }
        else
        {
            Debug.LogError("game_data.json Not Found, File not Created");
        }
#endif
        // Check if the value in the text is not null
        if (gameData != null)
        {
            info = JsonUtility.FromJson <GameFilesInfo>(gameData);
        }
        else
        {
            Debug.LogError("File not read correctly");
        }

        // Return that info
        return(info);
    }
Example #6
0
        public static GameScannnerApi InstallGameEditor(bool isSteam, string filesRootPath)
        {
            var filesInfo = new GameFilesInfo();

            foreach (var fileInfo in GetGameFilesInfo(isSteam))
            {
                filesInfo.FileInfo.Add(fileInfo.FileName, fileInfo);
            }

            //Load editor manifest
            foreach (var fileInfo in FilesInfoFromGameManifest("precert", 2296, false))
            {
                // ReSharper disable once SwitchStatementMissingSomeCases
                switch (fileInfo.FileName.ToLower())
                {
                case "spartan.exe":
                {
                    fileInfo.FileName = "Editor.exe";
                    if (filesInfo.FileInfo.ContainsKey(fileInfo.FileName))
                    {
                        filesInfo.FileInfo[fileInfo.FileName] = fileInfo;
                    }
                    else
                    {
                        filesInfo.FileInfo.Add(fileInfo.FileName, fileInfo);
                    }
                    break;
                }

                case "spartan.exe.cfg":
                {
                    fileInfo.FileName = "Editor.exe.cfg";
                    if (filesInfo.FileInfo.ContainsKey(fileInfo.FileName))
                    {
                        filesInfo.FileInfo[fileInfo.FileName] = fileInfo;
                    }
                    else
                    {
                        filesInfo.FileInfo.Add(fileInfo.FileName, fileInfo);
                    }
                    break;
                }

                case "xlivedlc.dll":
                {
                    fileInfo.FileName = "xEditDLC.dll";
                    if (filesInfo.FileInfo.ContainsKey(fileInfo.FileName))
                    {
                        filesInfo.FileInfo[fileInfo.FileName] = fileInfo;
                    }
                    else
                    {
                        filesInfo.FileInfo.Add(fileInfo.FileName, fileInfo);
                    }
                    break;
                }

                case "startup\\hotkeys.con":
                case "startup\\developer.con":
                case "startup\\editor.con":
                {
                    if (filesInfo.FileInfo.ContainsKey(fileInfo.FileName))
                    {
                        filesInfo.FileInfo[fileInfo.FileName] = fileInfo;
                    }
                    else
                    {
                        filesInfo.FileInfo.Add(fileInfo.FileName, fileInfo);
                    }
                    break;
                }
                }
            }

            //Override for editor celeste file
            foreach (var fileInfo in FilesInfoOverrideFromCelesteXml("e"))
            {
                if (filesInfo.FileInfo.ContainsKey(fileInfo.FileName))
                {
                    filesInfo.FileInfo[fileInfo.FileName] = fileInfo;
                }
                else
                {
                    filesInfo.FileInfo.Add(fileInfo.FileName, fileInfo);
                }
            }

            return(new GameScannnerApi(filesInfo.FileInfo.Values, filesRootPath));
        }