コード例 #1
0
    static void Main(string[] args)
    {
        /* 3 pages, of a 4x2 matrix
         *
         *         |16 17|
         *      | 8  9|19|
         *   | 0  1|11|21|
         *   | 2  3|13|23|
         *   | 4  5|15|
         *   | 6  7|
         *
         *  shown above are the sequential indeces for a rank 3 array
         */
        SeqArray <double> arr = new SeqArray <double>(3, 4, 2);
        // Initialize values to squential index "num"
        int num = 0;

        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 4; j++)
            {
                for (int k = 0; k < 2; k++)
                {
                    arr[i, j, k] = num++;
                }
            }
        }
        // Check that the array values correspond to the index sequence
        num = 0;
        for (int i = 0; i < 3 * 4 * 2; i++)
        {
            Trace.Assert(arr.InnerArray[i] == num++);
        }
        // Initialize with value=π
        arr = new SeqArray <double>(Math.PI, 4, 5, 6);
    }
コード例 #2
0
    void Awake()
    {
        //TODO: Find solution for JSON on Android

        sequencePath = Application.streamingAssetsPath + "/Sequence.json";
        menuPath     = Application.streamingAssetsPath + "/MainMenu.json";
        boardPath    = Application.streamingAssetsPath + "/TestLevel1.json";
        chamberPath  = Application.streamingAssetsPath + "/Chamber.json";
        cutScenePath = Application.streamingAssetsPath + "/CutScene.json";

        //F**k it. For now, not reading JSON from external JSON file, so config will go here for the time being.

        string jsonString  = "{ \"sequences\": [{\"seq1\":\"8484239823\",\"seq2\":\"Powai\",\"seq3\":\"Random Nick\"}]}";
        string jsonString2 = "{ \"sequences\": [\"fuu fuu\",\"fee fee\",3,4]}";


        SeqArray seqArray = JsonUtility.FromJson <SeqArray> (jsonString2);

        //Debug.Log (seqArray.sequences [0]);

        for (int i = 0; i < seqArray.sequences.Count; i++)
        {
            //Debug.Log(seqArray.sequences[i].faa_faa);
        }


        //MAKE THIS INTO A SINGLE FUNCTION ------------------------

        // Main Menu JSON
        if (Application.platform == RuntimePlatform.Android)           //Need to extract file from apk first
        {
            WWW menuReader = new WWW(menuPath);

            while (!menuReader.isDone)
            {
            }

            menuJSONString = menuReader.text;
        }
        else
        {
            menuJSONString = File.ReadAllText(menuPath);
        }

        //Board JSON
        if (Application.platform == RuntimePlatform.Android)           //Need to extract file from apk first
        {
            WWW boardReader = new WWW(boardPath);

            while (!boardReader.isDone)
            {
            }

            boardJSONString = boardReader.text;
        }
        else
        {
            boardJSONString = File.ReadAllText(boardPath);
        }

        //Chamber JSON
        if (Application.platform == RuntimePlatform.Android)           //Need to extract file from apk first
        {
            WWW chamberReader = new WWW(chamberPath);

            while (!chamberReader.isDone)
            {
            }

            chamberJSONString = chamberReader.text;
        }
        else
        {
            chamberJSONString = File.ReadAllText(chamberPath);
        }

        //Cut Scene JSON
        if (Application.platform == RuntimePlatform.Android)           //Need to extract file from apk first
        {
            WWW cutSceneReader = new WWW(cutScenePath);

            while (!cutSceneReader.isDone)
            {
            }

            cutSceneJSONString = cutSceneReader.text;
        }
        else
        {
            cutSceneJSONString = File.ReadAllText(cutScenePath);
        }
        //--------------------------------------

        sequenceConfig = JsonUtility.FromJson <SequenceConfig> (sequenceJSONString);
        menuConfig     = JsonUtility.FromJson <MenuConfig> (menuJSONString);
        boardConfig    = JsonUtility.FromJson <BoardConfig> (boardJSONString);
        chamberConfig  = JsonUtility.FromJson <ChamberConfig> (chamberJSONString);
        cutSceneConfig = JsonUtility.FromJson <CutSceneConfig> (cutSceneJSONString);
    }