public Texture GetTreeTops(int num) { if (!treeTops.ContainsKey(num)) { string name = String.Format("Tree_Tops_{0}", num); treeTops[num] = new Texture(rootDir, name); } return treeTops[num]; }
public Texture GetWall(int num) { if (!walls.ContainsKey(num)) { string name = String.Format("Wall_{0}", num); walls[num] = new Texture(rootDir, name); } return walls[num]; }
public Texture GetShroomTop(int num) { if (!shrooms.ContainsKey(num)) { string name = String.Format("Shroom_Tops"); shrooms[num] = new Texture(rootDir, name); } return shrooms[num]; }
public Texture GetTile(int num) { if (!textures.ContainsKey(num)) { string name = String.Format("Tiles_{0}", num); textures[num] = new Texture(rootDir, name); } return textures[num]; }
void drawTextureFlip(Texture tex, int bw, int bh, int tofs, byte[] pixels, int px, int py, int w, int h, double zoom, double lightR, double lightG, double lightB,byte paint) { int tw = (int)(bw * zoom +0.5); int th = (int)(bh * zoom +0.5); int skipx = 0, skipy = 0; if (px < 0) skipx = -px; if (px + tw >= w) tw = w - px; if (bw <= 0) return; if (py < 0) skipy = -py; if (py + th >= h) th = h - py; if (bh <= 0) return; int bofs = py * w * 4 + px * 4; for (int y = 0; y < th; y++) { if (y < skipy) { bofs += w * 4; continue; } int t = tofs + (int)(y / zoom) * tex.width * 4; if (t >= tex.data.Length) continue; int b = bofs; for (int x = 0; x < tw; x++) { int tx = t + (int)(bw - x / zoom) * 4; if (x < skipx || tex.data[tx + 3] == 0) { b += 4; continue; } byte blue = tex.data[tx++]; byte green = tex.data[tx++]; byte red = tex.data[tx++]; if (paint > 0) applyPaint(paint, ref red, ref green, ref blue); if (tex.data[tx] < 255) //alpha blend { UInt32 c = (uint)(blue * lightB) | ((uint)(green * lightG) << 8) | ((uint)(red * lightR) << 16); UInt32 orig = (UInt32)(pixels[b] | (pixels[b + 1] << 8) | (pixels[b + 2] << 16)); orig = alphaBlend(orig, c, tex.data[tx] / 255.0); pixels[b++] = (byte)(orig & 0xff); pixels[b++] = (byte)((orig >> 8) & 0xff); pixels[b++] = (byte)((orig >> 16) & 0xff); pixels[b++] = 0xff; } else { pixels[b++] = (byte)(blue * lightB); pixels[b++] = (byte)(green * lightG); pixels[b++] = (byte)(red * lightR); pixels[b++] = 0xff; } } bofs += w * 4; } }
public Texture GetNPCHead(int num) { if (!npcHeads.ContainsKey(num)) { string name = String.Format("NPC_Head_{0}", num); npcHeads[num] = new Texture(rootDir, name); } return npcHeads[num]; }
public Texture GetFemaleBody(int num) { if (!femaleBodies.ContainsKey(num)) { string name = String.Format("Female_Body_{0}", num); femaleBodies[num] = new Texture(rootDir, name); } return femaleBodies[num]; }
public Texture GetWood(int wood) { if (!woods.ContainsKey(wood)) { string name = String.Format("Tiles_5_{0}", wood); woods[wood] = new Texture(rootDir, name); } return woods[wood]; }
public Texture GetBanner(int num) { if (!banners.ContainsKey(num)) { string name = String.Format("House_Banner_{0}", num); banners[num] = new Texture(rootDir, name); } return banners[num]; }
public Texture GetCactus(int num) { if (!cacti.ContainsKey(num)) { string name="Tiles_80"; switch (num) { case 1: //evil name = "Evil_Cactus"; break; case 2: //good name = "Good_Cactus"; break; case 3: //crimson name = "Crimson_Cactus"; break; } cacti[num] = new Texture(rootDir, name); } return cacti[num]; }
public Texture GetBackground(int num) { if (!backgrounds.ContainsKey(num)) { string name = String.Format("Background_{0}", num); backgrounds[num] = new Texture(rootDir, name); } return backgrounds[num]; }
public Texture GetArmorLegs(int num) { if (!armorLegs.ContainsKey(num)) { string name = String.Format("Armor_Legs_{0}", num); armorLegs[num] = new Texture(rootDir, name); } return armorLegs[num]; }
public Texture GetActuator(int num) { if (!actuators.ContainsKey(num)) { string name = String.Format("Actuator"); actuators[num] = new Texture(rootDir, name); } return actuators[num]; }
public Texture GetWallOutline(int num) { if (!wallOutlines.ContainsKey(num)) { string name = String.Format("Wall_Outline"); wallOutlines[num] = new Texture(rootDir, name); } return wallOutlines[num]; }
public Texture GetItem(int num) { if (!items.ContainsKey(num)) { string name = String.Format("Item_{0}", num); items[num] = new Texture(rootDir, name); } return items[num]; }
public Texture GetWire(int num) { if (!wires.ContainsKey(num)) { string name; if (num == 0) name = String.Format("Wires"); else name = String.Format("Wires{0}", num+1); wires[num] = new Texture(rootDir, name); } return wires[num]; }
public Texture GetLiquid(int num) { if (!liquids.ContainsKey(num)) { string name = String.Format("Liquid_{0}", num); liquids[num] = new Texture(rootDir, name); } return liquids[num]; }
public Texture GetXmasTree(int num) { if (!xmasTrees.ContainsKey(num)) { string name = String.Format("Xmas_{0}", num); xmasTrees[num] = new Texture(rootDir, name); } return xmasTrees[num]; }
void drawTextureAlpha(Texture tex, int bw, int bh, int tofs, byte[] pixels, int px, int py, int w, int h, double zoom, double lightR, double lightG, double lightB, byte paint, double alpha) { int tw = (int)(bw * zoom + 0.5); int th = (int)(bh * zoom + 0.5); int skipx = 0, skipy = 0; if (px < 0) skipx = -px; if (px + tw >= w) tw = w - px; if (bw <= 0) return; if (py < 0) skipy = -py; if (py + th >= h) th = h - py; if (bh <= 0) return; int bofs = py * w * 4 + px * 4; for (int y = 0; y < th; y++) { if (y < skipy) { bofs += w * 4; continue; } int t = tofs + (int)(y / zoom) * tex.width * 4; //if we go off the end of the texture (like with water) //we should duplicate the last line. while (t >= tex.data.Length) t -= tex.width * 4; int b = bofs; for (int x = 0; x < tw; x++) { int tx = t + (int)(x / zoom) * 4; if (x < skipx || tex.data[tx + 3] == 0) { b += 4; continue; } byte blue = tex.data[tx++]; byte green = tex.data[tx++]; byte red = tex.data[tx++]; if (paint > 0) applyPaint(paint, ref red, ref green, ref blue); UInt32 c = (uint)(blue * lightB) | ((uint)(green * lightG) << 8) | ((uint)(red * lightR) << 16); UInt32 orig = (UInt32)(pixels[b] | (pixels[b + 1] << 8) | (pixels[b + 2] << 16)); orig = alphaBlend(orig, c, alpha); pixels[b++] = (byte)(orig & 0xff); pixels[b++] = (byte)((orig >> 8) & 0xff); pixels[b++] = (byte)((orig >> 16) & 0xff); pixels[b++] = 0xff; } bofs += w * 4; } }