Exemple #1
0
    void ConvertLabyrinthToStampCollection()
    {
        arenaCollection = GetComponent <ArenaCollection> () as ArenaCollection;

        StampCollection rootStampCollection = this.transform.parent.GetComponentInChildren <StampCollection> () as StampCollection;

        foreach (LabyrinthRoom room in finishedRoomList)
        {
            //GameObject newCircleStamp = Instantiate (circleHoleStampPrefab, room.GetPosition(), Quaternion.identity);
            GameObject newArenaStamp = Instantiate(arenaCollection.GetRandomArena(), room.GetPosition(), Quaternion.identity);

            float horFlip  = 1;
            float vertFlip = 1;
            //Flip horizontally or vertically randomly.
            if (Random.Range(0, 1) > 0.5f)
            {
                horFlip = -1;
            }
            if (Random.Range(0, 1) > 0.5f)
            {
                vertFlip = -1;
            }
            newArenaStamp.transform.localScale = new Vector3(room.GetDiameter() * horFlip, room.GetDiameter() * vertFlip, 1f);

            //Rotate 90 degrees half the time
            if (Random.Range(0, 1) > 0.5f)
            {
                newArenaStamp.transform.rotation = Quaternion.LookRotation(transform.forward, room.GetUpVector());
            }
            else
            {
                newArenaStamp.transform.rotation = Quaternion.LookRotation(transform.forward, room.GetRightVector());
            }
            rootStampCollection.AddChildStamp(newArenaStamp);
        }

        foreach (LabyrinthTunnel tunnel in tunnelList)
        {
            GameObject newRectStamp = Instantiate(rectHoleStampPrefab, tunnel.GetPosition(), Quaternion.identity);
            newRectStamp.transform.localScale = new Vector3(tunnel.GetWidth(), tunnel.GetLength(), 1f);
            newRectStamp.transform.rotation   = Quaternion.LookRotation(transform.forward, (tunnel.GetStart() - tunnel.GetEnd()));
            rootStampCollection.AddChildStamp(newRectStamp);
        }

        AddBoundingStamps(rootStampCollection);
    }
Exemple #2
0
    void MakeImpassableStamp(Vector3 location, float width, float height, StampCollection rootStampCollection)
    {
        width  = width + 0.1f;
        height = height + 0.1f;
        GameObject newRectStamp = Instantiate(impassableStampPrefab, location, Quaternion.identity);

        newRectStamp.transform.localScale = new Vector3(width, height, 1f);
        rootStampCollection.AddChildStamp(newRectStamp);
    }