public void SubmitAllocatedMana(Object target, params object[] args)
    {
        if (plyrPaying == null)
        {
            Debug.Log("Cannot submit a mana payment since no player is paying a mana cost");
            return;
        }

        if (bCanPayCost == false)
        {
            Debug.Log("Cannot submit this mana payment since this cost cannot be paid with the player's mana resources");
            return;
        }

        if (manaToSpendOnEffort.GetTotalMana() < manaToPay[Mana.MANATYPE.EFFORT])
        {
            Debug.Log("Cannot submit this mana payment since not enough mana has been allocated to pay for the effort portion");
            return;
        }

        if (modTarMana.manaCostRequired.CanBePaidWith(manaToSpend) == false)
        {
            Debug.Log("Cannot submit this mana payment: " + manaToSpend + " for cost: " + modTarMana.manaCostRequired);
            return;
        }

        //At this point, they should be able to pay, and should have allocated some amount of their mana to pay for the effort portion
        //  We can pass along the total mana amount to the TarMana model to submit as its payment
        modTarMana.AttemptSelection(manaToSpend);
    }
Example #2
0
 public int GetXPaid(Mana manaPaid)
 {
     if (bXCost == false)
     {
         return(0);
     }
     //return the total amount of mana spent minus the total amount needed for the cost (before the X)
     return(manaPaid.GetTotalMana() - pManaCost.Get().GetTotalMana());
 }
    public void UpdateEffortManaIcons()
    {
        List <Mana.MANATYPE> lstManaAllocatedForEffort = Mana.ManaToListOfTypes(manaToSpendOnEffort);

        int iManaIcon       = manaToPay.GetTotalColouredMana();
        int jEffortPaidWith = 0;
        int nManaToSpend    = manaToSpend.GetTotalMana();
        int nManaToPay      = manaToPay.GetTotalMana();


        //First, add icons for all paid-for effort
        for (; iManaIcon < nManaToSpend; iManaIcon++, jEffortPaidWith++)
        {
            if (iManaIcon == lstgoManaIcons.Count)
            {
                //If we're trying to update an icon we haven't spawned yet, then spawn it instead
                AddManaIcon(Mana.MANATYPE.EFFORT, true, lstManaAllocatedForEffort[jEffortPaidWith]);
            }
            else
            {
                //If we've already spawned an icon for this position, just update that icon
                ReplaceManaIcon(iManaIcon, Mana.MANATYPE.EFFORT, true, lstManaAllocatedForEffort[jEffortPaidWith]);
            }
        }

        //Then, add any icons for unpaid effort
        for (; iManaIcon < nManaToPay; iManaIcon++, jEffortPaidWith++)
        {
            //Note that we'll only ever reach here if nManaToSpend <= iManaIcon < nManaToPay so there must be some amount
            // of the cost that has not been paid.
            ReplaceManaIcon(iManaIcon, Mana.MANATYPE.EFFORT, false);
        }

        //Next, remove any icons that aren't needed
        int nGoManaIcons = lstgoManaIcons.Count;

        for (; iManaIcon < nGoManaIcons; iManaIcon++)
        {
            DestroyManaIcon();
        }

        // Finally, potentially add a special icon for prompting the player to pay more for X if they want to
        SpawnXIconIfNeeded();
    }
Example #4
0
    public bool CanBePaidWith(Mana manaPaid)
    {
        Mana manaFinalCost = pManaCost.Get();

        for (int i = 0; i < (int)Mana.MANATYPE.EFFORT; i++)
        {
            if (manaPaid[i] < manaFinalCost[i])
            {
                //The paid amount can't affored the cost for mana type i
                return(false);
            }
        }
        if (manaPaid.GetTotalMana() < manaFinalCost.GetTotalMana())
        {
            //The total amount of mana paid wasn't enough (so if all the coloured mana
            //   was enough, then the total amount of extra coloured mana can't have covered the effort cost)
            return(false);
        }

        return(true);
    }