/// <summary> /// Sets the provided drop rate for the provided EnemyDrop in this EnemyDrops. /// </summary> /// <param name="enemyDrop">The enemy drop for which to set a drop rate</param> /// <param name="dropRate">The drop rate to set</param> public void SetDropRate(EnemyDropEnum enemyDrop, decimal dropRate) { switch (enemyDrop) { case EnemyDropEnum.NO_DROP: NoDrop = dropRate; break; case EnemyDropEnum.SMALL_ENERGY: SmallEnergy = dropRate; break; case EnemyDropEnum.BIG_ENERGY: BigEnergy = dropRate; break; case EnemyDropEnum.MISSILE: Missile = dropRate; break; case EnemyDropEnum.SUPER: Super = dropRate; break; case EnemyDropEnum.POWER_BOMB: PowerBomb = dropRate; break; } }
/// <summary> /// Returns what quantity of its associated resource the provided enemy drop restores. /// </summary> /// <param name="enemyDrop">The enemy drop to evaluate</param> /// <returns></returns> public virtual int GetDropResourceCount(EnemyDropEnum enemyDrop) { return(enemyDrop switch { EnemyDropEnum.NO_DROP => 0, EnemyDropEnum.SMALL_ENERGY => 5, EnemyDropEnum.BIG_ENERGY => 20, EnemyDropEnum.MISSILE => 2, EnemyDropEnum.SUPER => 1, EnemyDropEnum.POWER_BOMB => 1, _ => throw new Exception($"Unrecognized enemy drop {enemyDrop}") });
/// <summary> /// Returns the drop rate in this EnemyDrops for the provided enemy drop. /// </summary> /// <param name="enemyDrop"></param> /// <returns></returns> public decimal GetDropRate(EnemyDropEnum enemyDrop) { return(enemyDrop switch { EnemyDropEnum.NO_DROP => NoDrop, EnemyDropEnum.SMALL_ENERGY => SmallEnergy, EnemyDropEnum.BIG_ENERGY => BigEnergy, EnemyDropEnum.MISSILE => Missile, EnemyDropEnum.SUPER => Super, EnemyDropEnum.POWER_BOMB => PowerBomb, _ => throw new Exception($"Unrecognized enemy drop {enemyDrop}") });
/// <summary> /// Returns the consumable resource that consumes this enemy drop. /// /// If this drop recharges no resources, returns null. /// </summary> /// <param name="enemyDrop">This enemy drop</param> /// <returns>The resources that this enemy drop can refill</returns> public static ConsumableResourceEnum?GetConsumableResource(this EnemyDropEnum enemyDrop) { return(enemyDrop switch { EnemyDropEnum.NO_DROP => null, EnemyDropEnum.SMALL_ENERGY => ConsumableResourceEnum.ENERGY, EnemyDropEnum.BIG_ENERGY => ConsumableResourceEnum.ENERGY, EnemyDropEnum.MISSILE => ConsumableResourceEnum.MISSILE, EnemyDropEnum.SUPER => ConsumableResourceEnum.SUPER, EnemyDropEnum.POWER_BOMB => ConsumableResourceEnum.POWER_BOMB, _ => throw new Exception($"Unrecognized enemy drop {enemyDrop}") });
/// <summary> /// Returns the rechargeable resources that this enemy drop can recharge. /// If this drop recharges no resources, returns an empty enumeration. /// </summary> /// <param name="enemyDrop">This enemy drop</param> /// <returns>The resources that this enemy drop can refill</returns> public static IEnumerable <RechargeableResourceEnum> GetRechargeableResources(this EnemyDropEnum enemyDrop) { ConsumableResourceEnum?consumableResource = enemyDrop.GetConsumableResource(); return(consumableResource == null?Enumerable.Empty <RechargeableResourceEnum>() : ((ConsumableResourceEnum)consumableResource).ToRechargeableResources()); }