Exemplo n.º 1
0
        public void Add(int numCurrency, WICurrencyType type)
        {
            if (numCurrency < 0)
            {
                //can't add negative currency
                return;
            }

            switch (type)
            {
            case WICurrencyType.A_Bronze:
            default:
                Bronze += numCurrency;
                break;

            case WICurrencyType.B_Silver:
                Silver += numCurrency;
                break;

            case WICurrencyType.C_Gold:
                Gold += numCurrency;
                break;

            case WICurrencyType.D_Luminite:
                Lumen += numCurrency;
                break;

            case WICurrencyType.E_Warlock:
                Warlock += numCurrency;
                break;
            }
            //Debug.Log ("Added " + numCurrency.ToString () + " currency of type " + type.ToString () + ", refresh action null? " + (RefreshAction == null).ToString ());
            RefreshAction.SafeInvoke();
            OnMoneyAdded.SafeInvoke();
        }
Exemplo n.º 2
0
            public static int ConvertFromBaseCurrency(int numBaseCurrency, WICurrencyType type)
            {
                int numActualCurrency = 0;

                switch (type)
                {
                case WICurrencyType.A_Bronze:
                    numActualCurrency = numBaseCurrency;
                    break;

                case WICurrencyType.B_Silver:
                    numActualCurrency = numBaseCurrency / Globals.BaseValueSilver;
                    break;

                case WICurrencyType.C_Gold:
                    numActualCurrency = numBaseCurrency / Globals.BaseValueGold;
                    break;

                case WICurrencyType.D_Luminite:
                    numActualCurrency = numBaseCurrency / Globals.BaseValueLumen;
                    break;

                case WICurrencyType.E_Warlock:
                    numActualCurrency = numBaseCurrency / Globals.BaseValueWarlock;
                    break;

                default:
                    break;
                }
                return(numActualCurrency);
            }
Exemplo n.º 3
0
        public bool TakeOutLoan(
            string organizationName,
            int principal,
            double dailyInterestRate,
            List <MobileReference> collateralStructures,
            List <string> collateralReputation,
            WICurrencyType currencyType,
            out Loan newLoan)
        {
            if (HasOutstandingLoan(organizationName, out newLoan))
            {
                //can only have one loan per organization at a time
                return(false);
            }

            newLoan = new Loan();
            newLoan.CurrencyType       = currencyType;
            newLoan.OrganizationName   = organizationName;
            newLoan.LoanNumber         = GetNumLoansFromOrganization(organizationName) + 1;
            newLoan.DayCreated         = WorldClock.DaysSinceBeginningOfTime;
            newLoan.DayLastPaymentMade = WorldClock.DaysSinceBeginningOfTime;
            newLoan.DayPaidOff         = -1;
            newLoan.InitialPrincipal   = principal;
            newLoan.CurrentPrincipal   = principal;
            newLoan.DailyInterestRate  = dailyInterestRate;
            newLoan.CollateralStructures.AddRange(collateralStructures);
            newLoan.CollateralReputation.AddRange(collateralReputation);
            newLoan.Name = organizationName + "-" + newLoan.LoanNumber.ToString();
            Mods.Get.Runtime.SaveMod <Loan>(newLoan, "Loan", newLoan.Name);
            Loans.Add(newLoan);
            return(true);
        }
Exemplo n.º 4
0
 public void SetCurrentOfferCurrencyType(WICurrencyType currencyType)
 {
     if (currencyType != WICurrencyType.None)
     {
         CurrentOfferCurrencyType = currencyType;
     }
 }
Exemplo n.º 5
0
 public bool CanAfford(int numCurrency, WICurrencyType currencyType)
 {
     if (numCurrency <= 0)
     {
         return(true);
     }
     return(BaseCurrencyValue >= Currency.ConvertToBaseCurrency(numCurrency, currencyType));
 }
Exemplo n.º 6
0
 public void ResetCurrentOffer()
 {
     CurrentOfferDailyInterestRate = 0;
     CurrentOfferPrincipal         = 0;
     CurrentOfferCollateral.Clear();
     CurrentOfferCurrencyType = WICurrencyType.None;
     CurrentOfferCollateralReputation.Clear();
 }
Exemplo n.º 7
0
        public void AddBaseCurrencyOfType(int numBaseCurrency, WICurrencyType type)
        {
            if (numBaseCurrency == 0 || type == WICurrencyType.None)
            {
                return;
            }

            int numActualCurrency = Currency.ConvertFromBaseCurrency(numBaseCurrency, type);

            Add(numActualCurrency, type);
        }
Exemplo n.º 8
0
        protected InventorySquareCurrency InstantiateSquare(GameObject prefab, WICurrencyType type, Vector3 position)
        {
            GameObject instantiatedSquareGameObject = NGUITools.AddChild(DisplayBase, prefab);

            instantiatedSquareGameObject.transform.localPosition = position;
            InventorySquareCurrency currencySquare = instantiatedSquareGameObject.GetComponent <InventorySquareCurrency> ();

            currencySquare.CurrencyType   = type;
            currencySquare.CurrencyAmount = 0;
            Squares.Add(currencySquare);
            return(currencySquare);
        }
Exemplo n.º 9
0
            public static string TypeToString(WICurrencyType type)
            {
                switch (type)
                {
                default:
                case WICurrencyType.A_Bronze:
                    return(gBronzeGenericWorldItem.DisplayName);

                case WICurrencyType.B_Silver:
                    return(gSilverGenericWorldItem.DisplayName);

                case WICurrencyType.C_Gold:
                    return(gGoldIGenericWorldItem.DisplayName);

                case WICurrencyType.D_Luminite:
                    return(gLumenGenericWorldItem.DisplayName);

                case WICurrencyType.E_Warlock:
                    return(gWarlockGenericWorldItem.DisplayName);
                }
            }
Exemplo n.º 10
0
 public void AddBaseCurrencyOfType(float numBaseCurrency, WICurrencyType type)
 {
     AddBaseCurrencyOfType(Mathf.FloorToInt(numBaseCurrency), type);
 }
Exemplo n.º 11
0
        public bool TryToRemove(int numToRemove, WICurrencyType type, bool makeChange)
        {
            if (makeChange)
            {
                return(TryToRemove(Currency.ConvertToBaseCurrency(numToRemove, type)));
            }
            else if (numToRemove == 0)
            {
                return(true);
            }
            else
            {
                bool result = false;
                switch (type)
                {
                case WICurrencyType.A_Bronze:
                default:
                    if (mBronze >= numToRemove)
                    {
                        mBronze -= numToRemove;
                        result   = true;
                    }
                    break;

                case WICurrencyType.B_Silver:
                    if (mSilver >= numToRemove)
                    {
                        mSilver -= numToRemove;
                        result   = true;
                    }
                    break;

                case WICurrencyType.C_Gold:
                    if (mGold >= numToRemove)
                    {
                        mGold -= numToRemove;
                        result = true;
                    }
                    break;

                case WICurrencyType.D_Luminite:
                    if (mLumen >= numToRemove)
                    {
                        mLumen -= numToRemove;
                        result  = true;
                    }
                    break;

                case WICurrencyType.E_Warlock:
                    if (mWarlock >= numToRemove)
                    {
                        mWarlock -= numToRemove;
                        result    = true;
                    }
                    break;
                }
                if (result)
                {
                    RefreshAction.SafeInvoke();
                    OnMoneyRemoved.SafeInvoke();
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 12
0
 public bool TryToRemove(int numToRemove, WICurrencyType type)
 {
     return(TryToRemove(numToRemove, type, true));
 }
Exemplo n.º 13
0
 public bool HasExactChange(int numCurrency, WICurrencyType type)
 {
     return(false);
 }