Beispiel #1
0
    /// <summary>
    /// 读取服务器资源和程序版本号
    /// </summary>
    /// <param name="path"></param>
    /// <returns></returns>
    private void LoadServerResVersionConfig()
    {
        UnityWebRequest www = UnityWebRequest.Get(GameDefine.LuancherURL + GameDefine.ServerResVersionFile);

        www.Send();

        while (!www.isDone)
        {
        }

        // Show results as text
        string verstr = www.downloadHandler.text;

        www.Dispose();

        INIParser ini = new INIParser();

        ini.OpenFromString(verstr);
        string IosReviewAppVer = ini.ReadValue("SvrResVer", "ReviewAppVer", "");
        string luancherurl     = ini.ReadValue("SvrResVer", "FormalLuancher", "");

        //当前是否审核版本
        if (!string.IsNullOrEmpty(IosReviewAppVer) && IosReviewAppVer.CompareTo(Application.version) == 0)
        {
            IsReviewVersion = true;
        }
        //如果不是审核版本且有指向则需连接正式luancher服上获取更新字段
        if (!IsReviewVersion && !string.IsNullOrEmpty(luancherurl))
        {
            UnityWebRequest www1 = UnityWebRequest.Get(luancherurl + "SerResVersion.data");
            www1.Send();

            while (!www1.isDone)
            {
            }
            verstr = www1.downloadHandler.text;
            www1.Dispose();
            ini.OpenFromString(verstr);
            GameDefine.LuancherURL = luancherurl;
        }
        m_SvrResVerStr = ini.ReadValue("SvrResVer", "ResVer", "");
        m_SvrAppVerStr = ini.ReadValue("SvrResVer", "AppVer", "");
        m_ServerIP     = ini.ReadValue("SvrResVer", "SvrIP", "");
        m_ServerPort   = ini.ReadValue("SvrResVer", "SvrPort", 16201);
        ini.Close();


        Debug.Log("Res:" + m_SvrResVerStr + ",ApkVer:" + m_SvrAppVerStr + " SerIP:" + m_ServerIP);
    }
        public Song(Song song) : this()
        {
            metaData   = new Metadata(song.metaData);
            offset     = song.offset;
            resolution = song.resolution;

            _events.Clear();
            _syncTrack.Clear();

            _events.AddRange(song._events);
            _syncTrack.AddRange(song._syncTrack);

            manualLength = song.manualLength;

            charts = new Chart[song.charts.Length];
            for (int i = 0; i < charts.Length; ++i)
            {
                charts[i] = new Chart(song.charts[i], this);
            }

            for (int i = 0; i < audioLocations.Length; ++i)
            {
                audioLocations[i] = song.audioLocations[i];
            }

            iniProperties = new INIParser();
            iniProperties.OpenFromString(string.Empty);
            iniProperties.WriteValue(song.iniProperties);
        }
Beispiel #3
0
    public static INIParser CreateFromString(string s)
    {
        INIParser result = new INIParser();

        result.OpenFromString(s);
        return(result);
    }
Beispiel #4
0
    void Start()
    {
        Value = new Vector4(0.5f, 0.5f, 0.5f, 0.5f);
        ini   = new INIParser();
        TextAsset textFile = Resources.Load <TextAsset>("event");

        ini.OpenFromString(textFile.text);
        card = new Card(1, ini);
    }
Beispiel #5
0
    public void loadINIFile(string data, bool loadFromFile = false)
    {
        var ini = new INIParser();

        if (loadFromFile)
        {
            ini.Open(data);
        }
        else
        {
            ini.OpenFromString(data);
        }

        MakeField(ini.ReadValue("Map", "width", 0), ini.ReadValue("Map", "height", 0));
        importCells(ini.ReadValue("Map", "cells", ""));
        ini.Close();
        g.cameraController.SetState(State.GamePlay);
        Trigger(Channel.Map.Loaded);
    }
Beispiel #6
0
    /// <summary>
    /// 读取应用程序版本号
    /// </summary>
    private void ReadAppVersion()
    {
        string    appconfigfilepath = GameCommon.GetAppStreamingAssetPath() + "AppConfig.ini";
        INIParser ini = new INIParser();

        if (Application.platform == RuntimePlatform.Android)
        {
            WWW www = new WWW(appconfigfilepath);
            while (!www.isDone)
            {
            }
            ini.OpenFromString(www.text);
            www.Dispose();
        }
        else
        {
            ini.Open(appconfigfilepath);
        }
        m_strAppVersion = ini.ReadValue("Config", "AppVer", "1.0");
        ini.Close();
    }
Beispiel #7
0
    public Configuration(string path) : base()
    {
        //Initialize the parser
        INIParser    parser       = new INIParser();
        StreamReader reader       = new StreamReader(path);
        string       fileContents = reader.ReadToEnd();

        reader.Close();
        parser.OpenFromString(fileContents);
        try
        {
            //Read the trial strings
            string trialStr = parser.ReadValue("Global", "TrialStrings", "Practice - Flags,Practice - Hills,Practice - Visible Platform,Trial 1,Trial 2-5,Trial 6-10,Trial 11-15,Probe Trial");
            TrialStrings = trialStr.Split(new char[] { ',' });

            //Read the global settings

            enableTCP = parser.ReadValue("Global", "EnableTCP", 0) != 0;
            port      = parser.ReadValue("Global", "Port", 5005);
            frameMode = parser.ReadValue("Global", "FrameMode", 1);

            //RandomSamplePositions
            string         samplePosStr    = parser.ReadValue("Global", "RandomSamplePoints", "");
            List <Vector2> randomPositions = new List <Vector2>();
            string[]       splt            = samplePosStr.Split(new char[] { ',' });
            for (int i = 0; i < splt.Length - 1; i += 2)
            {
                randomPositions.Add(new Vector2(float.Parse(splt[i]), float.Parse(splt[i + 1])));
            }

            //RandomSampleOrientations
            List <Quaternion> randomOrientations = new List <Quaternion>();
            string            sampleOriStr       = parser.ReadValue("Global", "RandomSampleOrientations", "");
            string []         splt2 = sampleOriStr.Split(new char[] { ',' });
            for (int i = 0; i < splt2.Length; i++)
            {
                randomOrientations.Add(Quaternion.Euler(0f, float.Parse(splt2[i]), 0f));
            }

            //Popualte the data arrays with defaults
            int n = TrialStrings.Length;

            InitializeDataArrays(n);

            //Iterate through the sections
            for (int i = 0; i < TrialStrings.Length; i++)
            {
                string trialString = TrialStrings[i];

                bool   startNewRandomSample = parser.ReadValue(trialString, "StartNewRandomSample", 0) != 0;
                string randomSampleIdx      = parser.ReadValue(trialString, "RandomSampleIndex", "");
                int[]  randomSampleIndices;
                if (randomSampleIdx != "")
                {
                    string[] rsplit = randomSampleIdx.Split(new char[] { ',' });
                    randomSampleIndices = new int[rsplit.Length];
                    for (int j = 0; j < rsplit.Length; j++)
                    {
                        randomSampleIndices[j] = int.Parse(rsplit[j]);
                    }
                }
                else
                {
                    randomSampleIndices = new int[0];
                }

                //Get the number of executions to look for values for
                NumberOfExecutions[i] = parser.ReadValue(trialString, "NumberOfExecutions", 1);
                if (NumberOfExecutions[i] < 1)
                {
                    NumberOfExecutions[i] = 1; //Must be at least 1
                }
                if (NumberOfExecutions[i] > 1) //If there are multiple executions, initalize the position/orientation arrays appropriately
                {
                    platformPositions[i]       = new Vector2[NumberOfExecutions[i]];
                    playerStartPositions[i]    = new Vector2[NumberOfExecutions[i]];
                    playerStartOrientations[i] = new Quaternion[NumberOfExecutions[i]];
                    for (int j = 0; j < NumberOfExecutions[i]; j++)
                    {
                        platformPositions[i][j]       = Vector2.zero;
                        playerStartPositions[i][j]    = Vector2.zero;
                        playerStartOrientations[i][j] = Quaternion.identity;
                    }
                }

                //Populate the platform positions if specified (zeros default)
                string platformPositionStr = parser.ReadValue(trialString, "PlatformPosition", "");
                if (platformPositionStr != "")
                {
                    string[] split = platformPositionStr.Split(new char[] { ',' });
                    for (int j = 0; j < Math.Floor((float)split.Length / 2f) * 2f; j += 2)
                    {
                        if (j < NumberOfExecutions[i] * 2)
                        {
                            platformPositions[i][j / 2] = ParseVector2(split[j] + ',' + split[j + 1]);
                        }
                    }
                }

                //Populate the player start position if specified (zeros default)
                string playerStartPositionStr = parser.ReadValue(trialString, "PlayerStartPosition", "");
                if (playerStartPositionStr != "")
                {
                    string[] split = playerStartPositionStr.Split(new char[] { ',' });
                    for (int j = 0; j < Math.Floor((float)split.Length / 2f) * 2f; j += 2)
                    {
                        if (j < NumberOfExecutions[i] * 2)
                        {
                            playerStartPositions[i][j / 2] = ParseVector2(split[j] + ',' + split[j + 1]);
                        }
                    }
                }
                else
                {
                    //Sample from playerprefs and randomsaplepoints
                    int   perm = getSamplePlayerPrefsPerm(startNewRandomSample);
                    int[] idxs = permutation5(perm);
                    for (int j = 0; j < NumberOfExecutions[i]; j++)
                    {
                        if (j < NumberOfExecutions[i] && j < randomSampleIndices.Length)
                        {
                            playerStartPositions[i][j] = randomPositions[idxs[randomSampleIndices[j]]];
                        }
                    }
                }

                //Populate the player starting orientation if specified
                string orientationStr = parser.ReadValue(trialString, "PlayerStartOrientationRadians", "");
                if (playerStartPositionStr != "")
                {
                    string[] split = playerStartPositionStr.Split(new char[] { ',' });
                    for (int j = 0; j < split.Length; j++)
                    {
                        if (j < NumberOfExecutions[i])
                        {
                            try
                            {
                                float orientation = float.Parse(split[j].Trim());
                                playerStartOrientations[i][j] = Quaternion.Euler(0f, orientation, 0f);
                            }
                            catch (Exception) { }
                        }
                    }
                }
                else
                {
                    //Sample from playerprefs and randomsampleorientations
                    int   perm = getSamplePlayerPrefsPerm(false);
                    int[] idxs = permutation5(perm);
                    for (int j = 0; j < NumberOfExecutions[i]; j++)
                    {
                        if (j < NumberOfExecutions[i] && j < randomSampleIndices.Length)
                        {
                            playerStartOrientations[i][j] = randomOrientations[idxs[randomSampleIndices[j]]];
                        }
                    }
                }

                //Read the timeout (float.PositiveInfinity is default)
                string timeoutString = parser.ReadValue(trialString, "TimeoutInMilliseconds", "");
                float  timeout       = float.PositiveInfinity;
                if (timeoutString.Trim().ToLower() != "none")
                {
                    timeout = (float)parser.ReadValue(trialString, "TimeoutInMilliseconds", float.PositiveInfinity) / 1000f;
                }
                trialTimeLimits[i] = timeout;

                //Read the visibility booleans
                landmarkVisibilities[i]   = parser.ReadValue(trialString, "LandmarkVisibilities", 1) != 0;
                platformVisibilities[i]   = parser.ReadValue(trialString, "PlatformVisible", 1) != 0;
                flagVisibilities[i]       = parser.ReadValue(trialString, "FlagsVisible", 1) != 0;
                hillVisibilities[i]       = parser.ReadValue(trialString, "HillsVisible", 1) != 0;
                platformTriggerEnabled[i] = parser.ReadValue(trialString, "PlatformTriggerEnabled", 1) != 0;

                //Get the sound setting
                SoundEffectsEnabled[i] = parser.ReadValue(trialString, "SoundEffectsEnabled", 1) != 0;

                //Get the movement speed and ensure it is greater than or equal to 0
                MovementSpeeds[i] = (float)parser.ReadValue(trialString, "MovementSpeed", 5.0f);
                if (MovementSpeeds[i] < 0f)
                {
                    MovementSpeeds[i] = 0f;
                }
            }
        }
        catch (Exception) { }
        parser.Close();
    }