/*
		 * Types currently supported:
		 * CrewMember
		 * Gadget
		 * HighScoreRecord
		 * Shield
		 * StarSystem
		 * Weapon
		 *
		 * If an array of a type not listed is converted using ArrayToArrayList, the type
		 * needs to be added here.
		 */
		public static STSerializableObject[] ArrayListToArray(ArrayList list, string type)
		{
			STSerializableObject[] array = null;

			if (list != null)
			{
				switch (type)
				{
					case "CrewMember":
						array = new CrewMember[list.Count];
						break;
					case "Gadget":
						array = new Gadget[list.Count];
						break;
					case "HighScoreRecord":
						array = new HighScoreRecord[list.Count];
						break;
					case "Shield":
						array = new Shield[list.Count];
						break;
					case "StarSystem":
						array = new StarSystem[list.Count];
						break;
					case "Weapon":
						array = new Weapon[list.Count];
						break;
				}

				for (int index = 0; index < list.Count; index++)
				{
					Hashtable hash = (Hashtable)list[index];
					STSerializableObject obj = null;

					if (hash != null)
					{
						switch (type)
						{
							case "CrewMember":
								obj = new CrewMember(hash);
								break;
							case "Gadget":
								obj = new Gadget(hash);
								break;
							case "HighScoreRecord":
								obj = new HighScoreRecord(hash);
								break;
							case "Shield":
								obj = new Shield(hash);
								break;
							case "StarSystem":
								obj = new StarSystem(hash);
								break;
							case "Weapon":
								obj = new Weapon(hash);
								break;
						}
					}

					array[index] = obj;
				}
			}

			return array;
		}
Exemplo n.º 2
0
 public override Equipment Clone()
 {
     Shield shield = new Shield(_type, _power, _price, _minTech, _chance) { Charge = Charge };
     return shield;
 }