Ejemplo n.º 1
0
  private void CreateBalconyBodyTextures ()
  {
    var color = Color.white;
    var th = 22;
    ProceduralTexture tex;
    int h;

    // 1st texture
    tex = new ProceduralTexture(512, 1024);
    tex.SetBackgroundColor(new Color32(25, 0, 143, 255));
    AddBorders(ref tex, color, th);
    h = (tex.content.height * 3) >> 2;
    tex.lines.Add(new TextureLine(0, h, tex.content.width, h,
                                  color, th));
    tex.lines.Add(new TextureLine(tex.content.width >> 1, 0,
                                  tex.content.width >> 1, h,
                                  color, th << 1));
    tex.Draw();
    TextureManager.Instance.AddToCollection("tex_balcony_door", tex);
    // 1st texture

    // 2nd texture
    tex = new ProceduralTexture(512, 1024);
    tex.SetBackgroundColor(new Color32(25, 0, 143, 255));
    AddBorders(ref tex, color, th);
    h = (tex.content.height * 3) >> 2;
    tex.lines.Add(new TextureLine(0, h, tex.content.width, h,
                                  color, th));
    tex.lines.Add(new TextureLine(tex.content.width >> 1, 0,
                                  tex.content.width >> 1, h,
                                  color, th << 1));
    tex.lines.Add(new TextureLine(0, h >> 1, tex.content.width, h >> 1,
                                  color, th));
    tex.Draw();
    TextureManager.Instance.AddToCollection("tex_balcony_door", tex);
    // 2nd texture

    // 3rd texture
    tex = new ProceduralTexture(512, 1024);
    tex.SetBackgroundColor(new Color32(25, 0, 143, 255));
    AddBorders(ref tex, color, th);
    AddBalancedLines(ref tex, 3, color, th);
    tex.lines.Add(new TextureLine(tex.content.width >> 1, 0,
                                  tex.content.width >> 1, tex.content.height,
                                  color, th << 1));
    tex.Draw();
    TextureManager.Instance.AddToCollection("tex_balcony_door", tex);
    // 3rd texture

    // 4th texture
    tex = new ProceduralTexture(512, 1024);
    tex.SetBackgroundColor(new Color32(25, 0, 143, 255));
    AddBorders(ref tex, color, th);
    AddBalancedLines(ref tex, 4, color, th);
    tex.lines.Add(new TextureLine(tex.content.width >> 1, 0,
                                  tex.content.width >> 1, (tex.content.height << 2) / 5,
                                  color, th << 1));
    tex.Draw();
    TextureManager.Instance.AddToCollection("tex_balcony_door", tex);
    // 4th texture

    // 5th texture
    tex = new ProceduralTexture(512, 1024);
    tex.SetBackgroundColor(new Color32(25, 0, 143, 255));
    AddBorders(ref tex, color, th);
    AddBalancedLines(ref tex, 4, color, th);
    tex.lines.Add(new TextureLine(tex.content.width >> 1, 0,
                                  tex.content.width >> 1, tex.content.height,
                                  color, th << 1));
    tex.Draw();
    TextureManager.Instance.AddToCollection("tex_balcony_door", tex);
    // 5th texture
  }
        private void CreateWindowTextures()
        {
            var color = Color.white;
            var th = 22;
            ProceduralTexture tex;
            int h;

            // 1st texture
            tex = new ProceduralTexture(512, 1024);
            tex.SetBackgroundColor(new Color32(25, 0, 143, 255));
            AddBorders(ref tex, color, th);
            h = (tex.content.height * 3) >> 2;
            tex.lines.Add(new TextureLine(0, h, tex.content.width, h,
                                  color, th));
            tex.lines.Add(new TextureLine(tex.content.width >> 1, 0,
                                  tex.content.width >> 1, h,
                                  color, th << 1));
            tex.Draw();
            TextureManager.Instance.AddToCollection("tex_window", tex);
            // 1st texture

            // 2nd texture
            tex = new ProceduralTexture(512, 1024);
            tex.SetBackgroundColor(new Color32(25, 0, 143, 255));
            AddBorders(ref tex, color, th);
            h = (tex.content.height * 3) >> 2;
            tex.lines.Add(new TextureLine(0, h, tex.content.width, h,
                                  color, th));
            tex.lines.Add(new TextureLine(tex.content.width >> 1, 0,
                                  tex.content.width >> 1, h,
                                  color, th << 1));
            tex.lines.Add(new TextureLine(0, h >> 1, tex.content.width, h >> 1,
                                  color, th));
            tex.Draw();
            TextureManager.Instance.AddToCollection("tex_window", tex);
            // 2nd texture

            // 3rd texture
            tex = new ProceduralTexture(512, 1024);
            tex.SetBackgroundColor(new Color32(25, 0, 143, 255));
            AddBorders(ref tex, color, th);
            AddBalancedLines(ref tex, 2, color, th);
            tex.lines.Add(new TextureLine(tex.content.width >> 1, 0,
                                  tex.content.width >> 1, tex.content.height,
                                  color, th << 1));
            tex.Draw();
            TextureManager.Instance.AddToCollection("tex_window", tex);
            // 3rd texture

            // 4th texture
            tex = new ProceduralTexture(512, 1024);
            tex.SetBackgroundColor(new Color32(25, 0, 143, 255));
            AddBorders(ref tex, color, th);
            AddBalancedLines(ref tex, 3, color, th);
            tex.lines.Add(new TextureLine(tex.content.width >> 1, 0,
                                  tex.content.width >> 1, (tex.content.height * 3) >> 2,
                                  color, th << 1));
            tex.Draw();
            TextureManager.Instance.AddToCollection("tex_window", tex);
            // 4th texture

            // 5th texture
            tex = new ProceduralTexture(512, 1024);
            tex.SetBackgroundColor(new Color32(25, 0, 143, 255));
            AddBorders(ref tex, color, th);
            AddBalancedLines(ref tex, 3, color, th);
            tex.lines.Add(new TextureLine(tex.content.width >> 1, 0,
                                  tex.content.width >> 1, tex.content.height,
                                  color, th << 1));
            tex.Draw();
            TextureManager.Instance.AddToCollection("tex_window", tex);
            // 5th texture
        }
Ejemplo n.º 3
0
  private void CreateBalconyRailTexture ()
  {
    var tex = new ProceduralTexture();
    tex.content = new Texture2D(1024, 512);
    tex.Clear();

    var ratio = 2f;
    var outBorderSize = 0.02f;
    var inBorderSize = 0.018f;
    var spaceBetweenBorders = 0.06f;

    int vOutBorderWidth    = Mathf.FloorToInt(tex.content.width * outBorderSize);
    int topOutBorderWidth  = Mathf.FloorToInt(tex.content.height * outBorderSize * 2 * ratio);
    int vInBorderWidth     = Mathf.FloorToInt(tex.content.width * inBorderSize);
    int hInBorderWidth     = Mathf.FloorToInt(tex.content.height * inBorderSize * ratio);
    int vInBorderOffset    = Mathf.FloorToInt(tex.content.width * spaceBetweenBorders) +
                                              vOutBorderWidth;
    int botInBorderOffset  = Mathf.FloorToInt(tex.content.height * spaceBetweenBorders * ratio);

    var halfWidth = tex.content.width >> 1;

    int topOutBorderY    = tex.content.height - (topOutBorderWidth >> 1);
    int botInBorderY     = botInBorderOffset + (hInBorderWidth >> 1);
    int topInBorderY     = tex.content.height - botInBorderY - topOutBorderWidth;
    int leftOutBorderX   = (vOutBorderWidth >> 1) - 1;
    int rightOutBorderX  = tex.content.width - leftOutBorderX;
    int leftInBorderX    = vInBorderOffset + (vInBorderWidth >> 1);
    int rightInBorderX   = tex.content.width - leftInBorderX;

    // top out border
    tex.lines.Add(new TextureLine(0, topOutBorderY,
                                  tex.content.width, topOutBorderY,
                                  Color.black, topOutBorderWidth));
    // bot in border
    tex.lines.Add(new TextureLine(0, botInBorderY,
                                  tex.content.width, botInBorderY,
                                  Color.black, hInBorderWidth));
    // top in border
    tex.lines.Add(new TextureLine(0, topInBorderY,
                                  tex.content.width, topInBorderY,
                                  Color.black, hInBorderWidth));
    // left out border
    tex.lines.Add(new TextureLine(leftOutBorderX, 0,
                                  leftOutBorderX, tex.content.height,
                                  Color.black, vOutBorderWidth));
    // right out border
    tex.lines.Add(new TextureLine(rightOutBorderX, 0,
                                  rightOutBorderX, tex.content.height,
                                  Color.black, vOutBorderWidth));
    // left in border
    tex.lines.Add(new TextureLine(leftInBorderX, 0,
                                  leftInBorderX, tex.content.width,
                                  Color.black, vInBorderWidth));
    // right in border
    tex.lines.Add(new TextureLine(rightInBorderX, 0,
                                  rightInBorderX, tex.content.width,
                                  Color.black, vInBorderWidth));
    // middle border
    tex.lines.Add(new TextureLine(halfWidth, 0,
                                  halfWidth, tex.content.height,
                                  Color.black, vInBorderWidth));
    // left inner box
    tex.lines.Add(new TextureLine(leftInBorderX, botInBorderY + 2,
                                  halfWidth + 1, topInBorderY,
                                  Color.black, vInBorderWidth));

    tex.lines.Add(new TextureLine(leftInBorderX, topInBorderY - 1,
                                  halfWidth + 1, botInBorderY,
                                  Color.black, vInBorderWidth));
    // right inner box
    tex.lines.Add(new TextureLine(halfWidth + 1, botInBorderY,
                                  rightInBorderX, topInBorderY,
                                  Color.black, vInBorderWidth));

    tex.lines.Add(new TextureLine(halfWidth + 1, topInBorderY,
                                  rightInBorderX, botInBorderY,
                                  Color.black, vInBorderWidth));

    tex.Draw();

    TextureManager.Instance.Add("tex_balcony", tex);
  }
        private void CreateBalconyRailTexture()
        {
            var tex = new ProceduralTexture();
            tex.content = new Texture2D(1024, 512);
            tex.Clear();

            var ratio = 2f;
            var outBorderSize = 0.02f;
            var inBorderSize = 0.018f;
            var spaceBetweenBorders = 0.06f;

            int vOutBorderWidth    = Mathf.FloorToInt(tex.content.width * outBorderSize);
            int topOutBorderWidth  = Mathf.FloorToInt(tex.content.height * outBorderSize * 2 * ratio);
            int vInBorderWidth     = Mathf.FloorToInt(tex.content.width * inBorderSize);
            int hInBorderWidth     = Mathf.FloorToInt(tex.content.height * inBorderSize * ratio);
            int vInBorderOffset    = Mathf.FloorToInt(tex.content.width * spaceBetweenBorders) +
                                              vOutBorderWidth;
            int botInBorderOffset  = Mathf.FloorToInt(tex.content.height * spaceBetweenBorders * ratio);

            var halfWidth = tex.content.width >> 1;

            int topOutBorderY    = tex.content.height - (topOutBorderWidth >> 1);
            int botInBorderY     = botInBorderOffset + (hInBorderWidth >> 1);
            int topInBorderY     = tex.content.height - botInBorderY - topOutBorderWidth;
            int leftOutBorderX   = (vOutBorderWidth >> 1) - 1;
            int rightOutBorderX  = tex.content.width - leftOutBorderX;
            int leftInBorderX    = vInBorderOffset + (vInBorderWidth >> 1);
            int rightInBorderX   = tex.content.width - leftInBorderX;

            // top out border
            tex.lines.Add(new TextureLine(0, topOutBorderY,
                                  tex.content.width, topOutBorderY,
                                  Color.black, topOutBorderWidth));
            // bot in border
            tex.lines.Add(new TextureLine(0, botInBorderY,
                                  tex.content.width, botInBorderY,
                                  Color.black, hInBorderWidth));
            // top in border
            tex.lines.Add(new TextureLine(0, topInBorderY,
                                  tex.content.width, topInBorderY,
                                  Color.black, hInBorderWidth));
            // left out border
            tex.lines.Add(new TextureLine(leftOutBorderX, 0,
                                  leftOutBorderX, tex.content.height,
                                  Color.black, vOutBorderWidth));
            // right out border
            tex.lines.Add(new TextureLine(rightOutBorderX, 0,
                                  rightOutBorderX, tex.content.height,
                                  Color.black, vOutBorderWidth));
            // left in border
            tex.lines.Add(new TextureLine(leftInBorderX, 0,
                                  leftInBorderX, tex.content.width,
                                  Color.black, vInBorderWidth));
            // right in border
            tex.lines.Add(new TextureLine(rightInBorderX, 0,
                                  rightInBorderX, tex.content.width,
                                  Color.black, vInBorderWidth));
            // middle border
            tex.lines.Add(new TextureLine(halfWidth, 0,
                                  halfWidth, tex.content.height,
                                  Color.black, vInBorderWidth));
            // left inner box
            tex.lines.Add(new TextureLine(leftInBorderX, botInBorderY + 2,
                                  halfWidth + 1, topInBorderY,
                                  Color.black, vInBorderWidth));

            tex.lines.Add(new TextureLine(leftInBorderX, topInBorderY - 1,
                                  halfWidth + 1, botInBorderY,
                                  Color.black, vInBorderWidth));
            // right inner box
            tex.lines.Add(new TextureLine(halfWidth + 1, botInBorderY,
                                  rightInBorderX, topInBorderY,
                                  Color.black, vInBorderWidth));

            tex.lines.Add(new TextureLine(halfWidth + 1, topInBorderY,
                                  rightInBorderX, botInBorderY,
                                  Color.black, vInBorderWidth));

            tex.Draw();

            TextureManager.Instance.Add("tex_balcony", tex);
        }