public Potion(string assetName, PotionType potionType, PotionPower potionPower, int stackCount = 1, int stackSize = 10, int layer = 0) : base(assetName, stackSize, layer) { this.potionType = potionType; this.potionPower = potionPower; this.stackCount = stackCount; setPotionPower(); SetId(); }
void SetRandomPotion(int floorNumber, PotionType genType) { // set type potionType = genType; if (potionType == PotionType.gen) { Array pTypeValues = Enum.GetValues(typeof(PotionType)); potionType = (PotionType)pTypeValues.GetValue(GameEnvironment.Random.Next(pTypeValues.Length - 1)); } switch (potionType) { case PotionType.Health: spriteAssetName = "Sprites/Potions/ruby"; //TODO: replace by correct spritename break; case PotionType.Mana: spriteAssetName = "Sprites/Potions/brilliant_blue"; //TODO: replace by correct spritename break; default: throw new Exception("invalid potionType"); } // set power Array pPowerValues = Enum.GetValues(typeof(PotionPower)); int pPVNumber = floorNumber; if (pPVNumber > pPowerValues.Length) { pPVNumber = pPowerValues.Length; } potionPower = (PotionPower)pPowerValues.GetValue(GameEnvironment.Random.Next(pPVNumber)); //set number of stackCount = GameEnvironment.Random.Next(1, (getStackSize * (floorNumber + 1))); if (stackCount > getStackSize) { stackCount = getStackSize; } }
public Potion(SerializationInfo info, StreamingContext context) : base(info, context) { potionType = (PotionType)info.GetValue("potionType", typeof(PotionType)); potionPower = (PotionPower)info.GetValue("potionPower", typeof(PotionPower)); potionValue = info.GetInt32("potionValue"); }