public static Weapon unpackWeapon(storedWeapon packedWeapon) { WeaponType type = (WeaponType)packedWeapon.type; switch (type) { case WeaponType.JumpWeapon: return new JumpWeapon(); case WeaponType.ProjectileWeapon: return new ProjectileWeapon(); case WeaponType.FishWeapon: return new FishWeapon(packedWeapon.count); case WeaponType.TorchWeapon: return new TorchWeapon(packedWeapon.count); case WeaponType.FireballWeapon: return new FireballWeapon(); case WeaponType.GhostlyWeapon: return new GhostlyWeapon(); case WeaponType.FarWeapon: return new FarWeapon(); case WeaponType.CatnipWeapon: return new CatnipWeapon(packedWeapon.count); case WeaponType.PillWeapon: return new PillWeapon(packedWeapon.count); default: return new NullWeapon(); } }
public storedWeapon packWeapon() { int type = 0; if (this is JumpWeapon) type = (int)WeaponType.JumpWeapon; else if (this is FireballWeapon) type = (int)WeaponType.FireballWeapon; else if (this is GhostlyWeapon) type = (int)WeaponType.GhostlyWeapon; else if (this is FarWeapon) type = (int)WeaponType.FarWeapon; else if (this is ProjectileWeapon) type = (int)WeaponType.ProjectileWeapon; else if (this is FishWeapon) type = (int)WeaponType.FishWeapon; else if (this is TorchWeapon) type = (int)WeaponType.TorchWeapon; else if (this is CatnipWeapon) type = (int)WeaponType.CatnipWeapon; else if (this is PillWeapon) type = (int)WeaponType.PillWeapon; storedWeapon sW = new storedWeapon(); sW.type = type; sW.count = count; return sW; }