public bool HasPower(PowerSlotTag slot, out PowerTag tag, out bool isActive) { if (powerDict.TryGetValue(slot, out tag)) { if (tag != PowerTag.INVALID) { isActive = GetComponent <Stress>().CurrentStress >= ((int)slot + 1); return(true); } } tag = PowerTag.INVALID; isActive = false; return(false); }
public bool IsBuyable(PowerTag power, out PowerSlotTag slot, out int potion) { PowerSlotTag[] checkSlot = new PowerSlotTag[] { PowerSlotTag.Slot1, PowerSlotTag.Slot2, PowerSlotTag.Slot3 }; bool slotIsFull = true; bool preIsMissing = true; PowerTag prePower = powerData.GetPrerequisite(power); slot = PowerSlotTag.Slot1; potion = 0; potion = powerData.GetPowerCost(power); if (GetComponent <Potion>().CurrentPotion < potion) { return(false); } foreach (PowerSlotTag s in checkSlot) { if (powerDict[s] == prePower) { preIsMissing = false; } if (powerDict[s] == PowerTag.INVALID) { slotIsFull = false; slot = s; // If current slot is empty, it means we have checked all // powers that PC has and `preIsMissing` will no longer // change. We can break out of the loop safely. break; } } if (slotIsFull || preIsMissing) { return(false); } return(true); }
public void GainPower(PowerSlotTag slot, PowerTag power) { powerDict[slot] = power; }