예제 #1
0
	/// <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="healthMod">The modification to the Pokemon's health by this item.</param>
	/// <param name="staminaMod">The modification to the Pokemon's stamina by this item.</param>
	/// <param name="inflictedStatuses">The status conditions inflicted by this item.</param>
	/// <param name="curedStatuses">The status conditions cured by this item.</param>
	/// <returns>The new object.</returns>
	public Restorative Recreate(int id, string name, string description, ushort image, float weight, int value, bool tradeable, int healthMod, int staminaMod, InflictedStatus[] inflictedStatuses, Status[] curedStatuses)
	{
		this.ID = id;
		this.Name = name;
		this.Description = description;
		this.Image = image;
		this.Weight = weight;
		this.Value = value;
		this.Tradeable = tradeable;
		this.HealthMod = healthMod;
		this.StaminaMod = staminaMod;
		this.InflictedStatuses = inflictedStatuses;
		this.CuredStatuses = curedStatuses;
		return this;
	}
예제 #2
0
	public static void Deserialize(byte[] serialized, out InflictedStatus status)
	{
		// TODO
		status = null;
	}
예제 #3
0
	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);
			}
		}
	}
예제 #4
0
	public static byte[] Serialize(InflictedStatus status)
	{
		// TODO
		return null;
	}