Example #1
0
        public static Singly intersection(Singly l1, Singly l2)
        {
            if (l1 == null || l2 == null)
            {
                return(null);
            }

            infoList res1 = getTailandSize(l1);
            infoList res2 = getTailandSize(l2);

            if (res1.lastNode != res2.lastNode)
            {
                return(null);
            }

            int diffLists = 0;;

            if (res1.size > res2.size)
            {
                diffLists = res1.size - res2.size;
                l1        = alignList(l1, diffLists);
            }
            else if (res1.size < res2.size)
            {
                diffLists = res2.size - res1.size;
                l2        = alignList(l2, diffLists);
            }

            return(findIntersectionNode(l1, l2));
        }
    public void spawnPuzzle()
    {
        Scene currScene = SceneManager.GetActiveScene();

        sceneName = currScene.name;
        // int x;
        //int y;

        if (sceneName == "Pipe_test")
        {
            //jsonPath = Application.streamingAssetsPath + "/json/Pipe_test.json";
            // json = File.ReadAllText(jsonPath);
            TextAsset asset = Resources.Load("json/Pipe_test") as TextAsset;
            if (asset != null)
            {
                informationList = JsonUtility.FromJson <infoList>(asset.text);
                for (int i = 0; i < informationList.info.Count; i++)
                {
                    Debug.Log(informationList.info[i].type);
                    Debug.Log(informationList.info[i].xPos);
                    Debug.Log(informationList.info[i].yPos);
                    Debug.Log(informationList.info[i].numRotates);
                }
            }
            else
            {
                Debug.Log("json not loaded");
            }
        }
        foreach (info i in informationList.info)
        {
            int x      = i.xPos;
            int y      = i.yPos;
            int rotate = i.numRotates;
            if (i.type == "angle")
            {
                pipe = Instantiate(Resources.Load("PipeGamePrefabs/angle"), new Vector3(x, y, 0), Quaternion.Euler(0, 0, 0)) as Pipe_Piece;
            }
            if (i.type == "straight")
            {
                pipe = Instantiate(Resources.Load("PipeGamePrefabs/straight"), new Vector3(x, y, 0), Quaternion.Euler(0, 0, 0)) as Pipe_Piece;
            }
            if (i.type == "cross")
            {
                pipe = Instantiate(Resources.Load("PipeGamePrefabs/cross"), new Vector3(x, y, 0), Quaternion.Euler(0, 0, 0)) as Pipe_Piece;
            }
            if (i.type == "t")
            {
                pipe = Instantiate(Resources.Load("PipeGamePrefabs/t"), new Vector3(x, y, 0), Quaternion.Euler(0, 0, 0)) as Pipe_Piece;
            }
            if (i.type == "end")
            {
                pipe = Instantiate(Resources.Load("PipeGamePrefabs/end"), new Vector3(x, y, 0), Quaternion.Euler(0, 0, 0)) as Pipe_Piece;
            }
            if (i.type == "start")
            {
                pipe = Instantiate(Resources.Load("PipeGamePrefabs/start"), new Vector3(x, y, 0), Quaternion.Euler(0, 0, 0)) as Pipe_Piece;
            }

            Debug.Log("spawning at");
            Debug.Log(i.xPos);
            Debug.Log(i.yPos);
            Debug.Log(i.type);
            Debug.Log(i.numRotates);

            for (int q = 0; q < rotate; q++)
            {
                // pipe.RotatePiece();
            }
        }
    }