public static Color GetPaintColor(Item paintItem) { BlasterPaintType paintType = PaintBlasterHelpers.GetPaintType(paintItem); Color color; switch (paintType) { case BlasterPaintType.Can: color = WorldGen.paintColor(paintItem.paint); break; case BlasterPaintType.ColorCartridge: var mycolorcart = (ColorCartridgeItem)paintItem.modItem; color = mycolorcart.MyColor; break; case BlasterPaintType.GlowCartridge: var myglowcart = (GlowCartridgeItem)paintItem.modItem; color = myglowcart.MyColor; break; default: throw new ModHelpersException("Not implemented."); } return(color); }
//////////////// public static void ConsumePaint(Item paintItem, float amount) { BlasterPaintType paintType = PaintBlasterHelpers.GetPaintType(paintItem); switch (paintType) { case BlasterPaintType.Can: paintItem.stack -= (int)amount; if (paintItem.stack < 0) { paintItem.stack = 0; } break; case BlasterPaintType.ColorCartridge: var mycolorcart = (ColorCartridgeItem)paintItem.modItem; mycolorcart.ConsumePaint(amount); break; case BlasterPaintType.GlowCartridge: var myglowcart = (GlowCartridgeItem)paintItem.modItem; myglowcart.ConsumePaint(amount); break; default: throw new ModHelpersException("Not implemented."); } }
public static byte GetPaintGlow(Item paintItem) { BlasterPaintType paintType = PaintBlasterHelpers.GetPaintType(paintItem); byte glow; switch (paintType) { case BlasterPaintType.Can: glow = 0; break; case BlasterPaintType.ColorCartridge: glow = 0; break; case BlasterPaintType.GlowCartridge: glow = 255; break; default: throw new ModHelpersException("Not implemented."); } return(glow); }
//////////////// public void DrawHUD(BetterPaintMod mymod, SpriteBatch sb, PaintBlasterItem myblaster) { int x = mymod.Config.HudPaintAmmoOffsetX >= 0 ? mymod.Config.HudPaintAmmoOffsetX : (Main.screenWidth + mymod.Config.HudPaintAmmoOffsetX); int y = mymod.Config.HudPaintAmmoOffsetY >= 0 ? mymod.Config.HudPaintAmmoOffsetY : (Main.screenHeight + mymod.Config.HudPaintAmmoOffsetY); sb.Draw(PaintBlasterHUD.AmmoCan, new Vector2(x, y), Color.White); Item paintItem = myblaster.GetCurrentPaintItem(); if (paintItem != null) { BlasterPaintType paintType = PaintBlasterHelpers.GetPaintType(paintItem); Color paintColor = PaintBlasterHelpers.GetPaintColor(paintItem); float quantity = PaintBlasterHelpers.GetPaintAmount(paintItem); float capacity = paintType == BlasterPaintType.Can ? (float)paintItem.maxStack : (float)mymod.Config.PaintCartridgeCapacity; float capacityPercent = quantity / capacity; int height = (int)(capacityPercent * 50f) * 2; int top = 100 - height; Color color = capacityPercent >= 0.01f ? paintColor : paintColor * 0.25f; sb.Draw(PaintBlasterHUD.AmmoTop, new Vector2(x, y + 16 + top), color); sb.Draw(PaintBlasterHUD.AmmoBot, new Vector2(x, y + 124), color); sb.Draw(Main.magicPixel, new Rectangle(x + 4, y + 24 + top, 16, height), color); if (Main.mouseX >= x && Main.mouseX < (x + PaintBlasterHUD.AmmoCan.Width)) { if (Main.mouseY >= y && Main.mouseY < (y + PaintBlasterHUD.AmmoCan.Height)) { string percentStr = capacityPercent.ToString("P", CultureInfo.InvariantCulture); Utils.DrawBorderStringFourWay(sb, Main.fontMouseText, percentStr, Main.mouseX - 40, Main.mouseY + 16, Color.White, Color.Black, default(Vector2), 1f); } } } else { if (Main.mouseX >= x && Main.mouseX < (x + PaintBlasterHUD.AmmoCan.Width)) { if (Main.mouseY >= y && Main.mouseY < (y + PaintBlasterHUD.AmmoCan.Height)) { string str = "Color Cartridge needed"; Utils.DrawBorderStringFourWay(sb, Main.fontMouseText, str, Main.mouseX - 160, Main.mouseY + 16, Color.White, Color.Black, default(Vector2), 1f); } } } }
public static float GetPaintAmount(Item paintItem) { BlasterPaintType paintType = PaintBlasterHelpers.GetPaintType(paintItem); switch (paintType) { case BlasterPaintType.Can: return(paintItem.stack); case BlasterPaintType.ColorCartridge: var mycolorcart = (ColorCartridgeItem)paintItem.modItem; return(mycolorcart.Quantity); case BlasterPaintType.GlowCartridge: var myglowcart = (GlowCartridgeItem)paintItem.modItem; return(myglowcart.Quantity); default: throw new ModHelpersException("Not implemented."); } }