public ColoredTextureWrapper this[ColoredTexture textureType] { get { return this.textures[textureType]; } }
public ColoredTextureWrapper this[ColoredTexture textureType] { get { return(this.textures[textureType]); } }
public Palette(GraphicsDevice graphics) { Primary = new ColoredTexture(graphics, Color.Blue); Secondary = new ColoredTexture(graphics, Color.DarkCyan); Success = new ColoredTexture(graphics, Color.Green); Danger = new ColoredTexture(graphics, Color.Red); Warning = new ColoredTexture(graphics, Color.Yellow); Info = new ColoredTexture(graphics, Color.LightBlue); Light = new ColoredTexture(graphics, Color.White); Dark = new ColoredTexture(graphics, Color.Black); }
/// <summary> /// Recreates this object with new values. /// </summary> /// <param name="id">The game ID of the item.</param> /// <param name="name">The name of the item.</param> /// <param name="description">The description of the item.</param> /// <param name="image">The asset ID of the thumbnail image of the item.</param> /// <param name="weight">The weight of the item.</param> /// <param name="value">The item's value in Poke Dollars.</param> /// <param name="tradeable">A value indicating whether the item is tradeable.</param> /// <param name="category">The type of clothing.</param> /// <param name="textures">The textures used by the clothing.</param> /// <returns>The new object.</returns> public ClothingTexture Recreate(int id, string name, string description, ushort image, float weight, int value, bool tradeable, ClothingCategory category, ColoredTexture[] textures) { this.ID = id; this.Name = name; this.Description = description; this.Image = image; this.Weight = weight; this.Value = value; this.Tradeable = tradeable; this.Category = category; this.Textures = textures; return this; }
// Returns a Texture with a color based on the current Health of the entity. Texture2D healthTexture() { float healthPercentage = ((float)curHealth) / ((float)maxHealth); // Reach 0 a bit faster than standard if (healthPercentage < 0.2) { healthPercentage -= 0.1f; } if (healthPercentage < 0) { healthPercentage = 0; } return(ColoredTexture.generatePixel(r: 1 - healthPercentage, g: healthPercentage, b: 0)); }
public ColoredTextureWrapper AddTexture(Image bmp, int width, int height, ColoredTexture textureType) { this.textures[textureType] = BuildTexture(bmp, height, width); return(this.textures[textureType]); }
public ColoredTextureWrapper AddTexture(Image bmp, int width, int height, ColoredTexture textureType) { this.textures[textureType] = BuildTexture(bmp, height, width); return this.textures[textureType]; }
public ColoredTextureWrapper this[ColoredTexture textureType] => this.textures[textureType];
public static void Deserialize(byte[] serialized, out Item item) { using (MemoryStream stream = new MemoryStream(serialized)) using (BinaryReader reader = new BinaryReader(stream)) { try { ItemIdentifier type = (ItemIdentifier)reader.ReadByte(); int id = reader.ReadInt32(); string name = reader.ReadString(); string description = reader.ReadString(); ushort image = reader.ReadUInt16(); bool tradeable = reader.ReadBoolean(); float weight = reader.ReadSingle(); int value = reader.ReadInt32(); if (type == ItemIdentifier.ClothingMesh) { ClothingMesh clothing = ObjectPool.Instance.New<ClothingMesh>(); ClothingCategory category = (ClothingCategory)reader.ReadByte(); ushort mesh = reader.ReadUInt16(); ColoredTexture[] textures = new ColoredTexture[reader.ReadByte()]; for (int i = 0; i < textures.Length; i++) { textures[i] = ObjectPool.Instance.New<ColoredTexture>(); bool colorable = reader.ReadBoolean(); Color color = Utility.ReadColor(reader); ushort texture = reader.ReadUInt16(); textures[i].Recreate(colorable, color, texture); } clothing.Recreate(id, name, description, image, weight, value, tradeable, category, mesh, textures); item = clothing; } else if (type == ItemIdentifier.ClothingTexture) { ClothingTexture clothing = ObjectPool.Instance.New<ClothingTexture>(); ClothingCategory category = (ClothingCategory)reader.ReadByte(); ColoredTexture[] textures = new ColoredTexture[reader.ReadByte()]; for (int i = 0; i < textures.Length; i++) { textures[i] = ObjectPool.Instance.New<ColoredTexture>(); bool colorable = reader.ReadBoolean(); Color color = Utility.ReadColor(reader); ushort texture = reader.ReadUInt16(); textures[i].Recreate(colorable, color, texture); } clothing.Recreate(id, name, description, image, weight, value, tradeable, category, textures); item = clothing; } else if (type == ItemIdentifier.Dye) { Dye dye = ObjectPool.Instance.New<Dye>(); Color color = Utility.ReadColor(reader); dye.Recreate(id, name, description, image, weight, value, tradeable, color); item = dye; } else if (type == ItemIdentifier.Machine) { Machine machine = ObjectPool.Instance.New<Machine>(); Move move; Deserialize(reader.ReadBytes(reader.ReadInt32()), out move); machine.Recreate(id, name, description, image, weight, value, tradeable, move); item = machine; } else if (type == ItemIdentifier.PokeBall) { PokeBall pokeBall = ObjectPool.Instance.New<PokeBall>(); float catchRate = reader.ReadSingle(); float breakRate = reader.ReadSingle(); PokeBall.Attribute[] attributes = new PokeBall.Attribute[reader.ReadInt32()]; for (int i = 0; i < attributes.Length; i++) { attributes[i] = (PokeBall.Attribute)reader.ReadInt32(); } pokeBall.Recreate(id, name, description, image, weight, value, tradeable, catchRate, breakRate, attributes); item = pokeBall; } else if (type == ItemIdentifier.Recipe) { Recipe recipe = ObjectPool.Instance.New<Recipe>(); Ingredient[] ingredients = new Ingredient[reader.ReadUInt16()]; for (int i = 0; i < ingredients.Length; i++) { ingredients[i] = ObjectPool.Instance.New<Ingredient>(); Item ingredientItem; Deserialize(reader.ReadBytes(reader.ReadInt32()), out ingredientItem); int amount = reader.ReadInt32(); ingredients[i].Recreate(ingredientItem, amount); } Item creation; Deserialize(reader.ReadBytes(reader.ReadInt32()), out creation); recipe.Recreate(id, name, description, image, weight, value, tradeable, ingredients, creation); item = recipe; } else if (type == ItemIdentifier.Restorative) { Restorative restorative = ObjectPool.Instance.New<Restorative>(); int healthMod = reader.ReadInt32(); int staminaMod = reader.ReadInt32(); InflictedStatus[] inflictedStatuses = new InflictedStatus[reader.ReadByte()]; for (int i = 0; i < inflictedStatuses.Length; i++) { inflictedStatuses[i] = ObjectPool.Instance.New<InflictedStatus>(); Status status; Deserialize(reader.ReadBytes(reader.ReadInt32()), out status); float duration = reader.ReadSingle(); inflictedStatuses[i].Recreate(status, duration); } Status[] curedStatuses = new Status[reader.ReadByte()]; for (int i = 0; i < curedStatuses.Length; i++) { Deserialize(reader.ReadBytes(reader.ReadInt32()), out curedStatuses[i]); } restorative.Recreate(id, name, description, image, weight, value, tradeable, healthMod, staminaMod, inflictedStatuses, curedStatuses); item = restorative; } else if (type == ItemIdentifier.Unique) { Unique unique = ObjectPool.Instance.New<Unique>(); Unique.Trigger[] triggers = new Unique.Trigger[reader.ReadInt32()]; for (int i = 0; i < triggers.Length; i++) { triggers[i] = (Unique.Trigger)reader.ReadInt32(); } bool usable = reader.ReadBoolean(); bool reusable = reader.ReadBoolean(); bool discardable = reader.ReadBoolean(); unique.Recreate(id, name, description, image, weight, value, tradeable, triggers, usable, reusable, discardable); item = unique; } else { Common common = ObjectPool.Instance.New<Common>(); common.Recreate(id, name, description, image, weight, value, tradeable); item = common; } } catch (Exception e) { item = null; Debug.Log("Exception at Serialization.Deserialize: " + e.Message); } } }
// Initializes border and background textures. private void initTextures() { backgroundTexture = ColoredTexture.generatePixel(g: 255, b: 255); borderTexture = ColoredTexture.generatePixel(); clearTexture = ColoredTexture.generatePixel(a: 0); }