//转换货币 public BankMoney TransformCoin(int nMoney) { int nGoldCoin; int nSilverCoin; int nCopperCoin; nCopperCoin = nMoney % 100; if (nMoney >= 100) { nSilverCoin = ((nMoney - nCopperCoin) / 100) % 100; } else { nSilverCoin = 0; } if (nMoney >= 10000) { nGoldCoin = (((nMoney - nCopperCoin) / 100) - nSilverCoin) / 100; } else { nGoldCoin = 0; } BankMoney luaMoney = new BankMoney(); luaMoney.goldCoin = nGoldCoin; luaMoney.silverCoin = nSilverCoin; luaMoney.copperCoin = nCopperCoin; return(luaMoney); }
//金钱的转换 BankMoney GetInputMoney(string szGold, string szSilver, string szCopperCoin) { /* * 检查数值的大小不能大于1亿,如果已经输入了 */ if (szGold.Length > 6) { szGold = szGold.Remove(0, szGold.Length - 6); } if (szSilver.Length > 2) { szSilver = szSilver.Remove(0, szSilver.Length - 2); } if (szCopperCoin.Length > 2) { szCopperCoin = szCopperCoin.Remove(0, szCopperCoin.Length - 2); } int nGold = int.Parse(szGold); int nSilver = int.Parse(szSilver); int nCopperCoin = int.Parse(szCopperCoin); bool bAvailability = true; int nMoney = 0; nMoney = nCopperCoin + nSilver * 100 + nGold * 10000; BankMoney luaMoney = new BankMoney(); luaMoney.available = bAvailability; luaMoney.nMoney = nMoney; return(luaMoney); }
//导出银行的金钱数 public BankMoney GetBankMoney() { int nMoney = CDataPool.Instance.UserBank_GetBankMoney(); int nGoldCoin; int nSilverCoin; int nCopperCoin; nCopperCoin = nMoney % 100; if (nMoney >= 100) { nSilverCoin = ((nMoney - nCopperCoin) / 100) % 100; } else { nSilverCoin = 0; } if (nMoney >= 10000) { nGoldCoin = (((nMoney - nCopperCoin) / 100) - nSilverCoin) / 100; } else { nGoldCoin = 0; } BankMoney luaMoney = new BankMoney(); luaMoney.nMoney = nMoney; luaMoney.goldCoin = nGoldCoin; luaMoney.silverCoin = nSilverCoin; luaMoney.copperCoin = nCopperCoin; return(luaMoney); }