Exemple #1
0
    // Debug function
    IEnumerator TestCoinOrientation()
    {
        buildPoint.transform.position = new Vector3(-30, 0, 30);
        GameObject stand, head;
        Direction  cur = Direction.North; // testing only one direction

        foreach (Direction e in System.Enum.GetValues(typeof(Direction)))
        {
            foreach (int firstpiece in new int[] { 0, 1, 2 })
            {
                foreach (int secondpiece in new int[] { 0, 1, 2 })
                {
                    // ignore opposite direction block
                    if (e == cur.Opposite())
                    {
                        continue;
                    }

                    // bootstrap first piece
                    stand = Instantiate(pathPrefab, buildPoint.transform.position, DirectedRotation(cur));
                    PathPrefab standPrefab = stand.GetComponent <PathPrefab>();
                    standPrefab.blockDirection = cur;
                    standPrefab.blockObject    = stand;
                    coinGenerator.DebugNextCoins(1, firstpiece, standPrefab);

                    // create second piece as it would be created in game
                    head = Instantiate(pathPrefab, buildPoint.position + DirectedOffset(cur, e), DirectedRotation(e));
                    PathPrefab headPrefab = head.GetComponent <PathPrefab>();
                    headPrefab.blockDirection = e;
                    headPrefab.blockObject    = head;
                    coinGenerator.DebugNextCoins(1, secondpiece, headPrefab, standPrefab);

                    // next iteration after 2 seconds
                    yield return(new WaitForSeconds(2));

                    Destroy(head);
                    Destroy(stand);
                }
            }
        }
    }