public HouseData TryToCreateRoom(HouseData houseData, int x, int z)
    {
        HouseConfig config    = houseData.houseConfig;
        FloorPlan   floorPlan = houseData.floorPlan;
        int         roomWidth = Mathf.Min(config.houseWidth - x - 1,
                                          //10);
                                          randomGenerator.Next(config.roomWidthMax - config.roomWidthMin) + config.roomWidthMin);
        int tmpRoomLength = Mathf.Min(config.houseLength - z - 1,
                                      //10);
                                      randomGenerator.Next(config.roomLengthMax - config.roomLengthMin) + config.roomLengthMin);

//		int roomWidth = 10, roomLength = 10;
        if (x + roomWidth >= config.houseWidth || z + tmpRoomLength >= config.houseLength)
        {
            return(houseData);
        }

        int roomLength = CorrectLength(x, z, floorPlan, tmpRoomLength);

        if (roomWidth < config.roomWidthMin || roomLength < config.roomLengthMin)
        {
            return(houseData);
        }
//		Debug.Log ("Room Width: " + roomWidth);
//		Debug.Log ("Room WidthMin: " + config.roomWidthMin);
//		Debug.Log ("Room Length: " + roomLength);
//		Debug.Log ("Room LengthMin: " + config.roomLengthMin);
        houseData = CreateRoom(x, z, roomWidth, roomLength, houseData);
        return(houseData);
    }
Exemplo n.º 2
0
    public static Texture2D Visualize(Texture2D oldtexture, HouseConfig houseConfig, FloorPlan floorData, UnitType unitTypeToPaint, Color color)
    {
        Texture2D texture;
        int       width  = floorData.area.GetLength(0) * (int)houseConfig.blockWidth;
        int       length = floorData.area.GetLength(1) * (int)houseConfig.blockLength;

        if (oldtexture == null)
        {
            texture = new Texture2D(width, length);
        }
        else
        {
            texture = oldtexture;
        }

        for (int x = 0; x < texture.width; x++)
        {
            for (int z = 0; z < texture.height; z++)
            {
                if (floorData.area [(int)(x / houseConfig.blockWidth), (int)(z / houseConfig.blockLength)] == unitTypeToPaint)
                {
                    //Paint in Color
                    texture.SetPixel(x, texture.height - z, color);
                }
            }
        }

        texture.Apply();
        return(texture);
    }
    /**
     *
     * Berechnung der Punkte, die für die Stufe benätigt werden
     * Vector3[] points = Ausgangspunkt (Leeres Array oder schon bestehende Punkte)
     * Vector3 m = mittelpunkt auf der Unterkante einer Stufe
     *
     *     /‾‾‾‾‾‾‾m‾‾‾‾‾‾‾‾/
     *    /________________/ |
     *    |                | /
     *    |p3            p7|/|
     *   /‾‾‾‾‾‾‾m‾‾‾‾‾‾‾‾/  /
     *  /p2____________p5/ |/
     *  |  p1            | /p6
     *  |p0              |/p4
     *   ‾‾‾‾‾‾‾m‾‾‾‾‾‾‾‾
     **/
    public Vector3[] CalculatePoints(Vector3[] points, Vector3 m)
    {
        HouseConfig config = houseData.houseConfig;

        points[0] = m + Vector3.left * config.treadWidth / 2;
        points[1] = points[0] + Vector3.forward * config.treadLength;
        points[2] = points[0] + Vector3.up * config.treadHeight;
        points[3] = points[1] + Vector3.up * config.treadHeight;
        points[4] = m + Vector3.right * config.treadWidth / 2;
        points[5] = points[4] + Vector3.up * config.treadHeight;
        points[6] = points[4] + Vector3.forward * config.treadLength;
        points[7] = points[6] + Vector3.up * config.treadHeight;
        return(points);
    }
    public Vector3[] CalculatePoints(Vector3[] points, Vector3 p0, Vector3 p1)
    {
        HouseConfig config = houseData.houseConfig;

        int roomHeight = config.roomHeight;
        int treadCount = (int)(config.roomHeight / config.treadHeight);
        int length     = treadCount * config.treadLength;

        points[0] = p0 + Vector3.up * roomHeight + Vector3.left * config.treadWidth / 2;
        points[1] = points[0] + Vector3.up * config.treadHeight;
        points[2] = p0 + Vector3.up * roomHeight + Vector3.right * config.treadWidth / 2;
        points[3] = points[2] + Vector3.up * config.treadHeight;

        points[4] = p1 + Vector3.forward * config.treadLength + Vector3.left * config.treadWidth / 2;
        points[5] = points[4] + Vector3.up * config.treadHeight;
        points[6] = p1 + Vector3.forward * config.treadLength + Vector3.right * config.treadWidth / 2;
        points[7] = points[6] + Vector3.up * config.treadHeight;

        return(points);
    }
Exemplo n.º 5
0
 public HouseData()
 {
     this.houseConfig = new HouseConfig();
 }
Exemplo n.º 6
0
 public HouseData(HouseConfig houseConfig)
 {
     this.houseConfig = houseConfig;
 }