Example #1
0
        public Dictionary<ExchangeType, Currency> GetCurrencyDictionary(CoinType exchangeType)
        {
            Dictionary<ExchangeType, Currency> currencyDict = new Dictionary<ExchangeType, Currency>();
            currenciesDictionary.TryGetValue(exchangeType, out currencyDict);

            return currencyDict;
        }
Example #2
0
        /// <summary>
        /// Gets all the pub keys contained in this wallet.
        /// </summary>
        /// <param name="coinType">Type of the coin.</param>
        /// <returns></returns>
        public IEnumerable <Script> GetAllPubKeysByCoinType(CoinType coinType)
        {
            List <HdAccount> accounts = this.GetAccountsByCoinType(coinType).ToList();

            foreach (Script script in accounts.SelectMany(x => x.ExternalAddresses).Select(x => x.ScriptPubKey))
            {
                yield return(script);
            }

            foreach (Script script in accounts.SelectMany(x => x.InternalAddresses).Select(x => x.ScriptPubKey))
            {
                yield return(script);
            }
        }
Example #3
0
        public static BitcoinCoinProperties GetCoinProperties(CoinType coin, string algorithm = null)
        {
            if (coin == CoinType.DGB)
            {
                return(GetDigiByteProperties(algorithm));
            }
            else if (coin == CoinType.XVG)
            {
                return(GetVergeProperties(algorithm));
            }

            coinProperties.TryGetValue(coin, out var props);
            return(props);
        }
 public SmartContractWalletController(
     IBroadcasterManager broadcasterManager,
     IConnectionManager connectionManager,
     ILoggerFactory loggerFactory,
     Network network,
     IWalletManager walletManager)
 {
     this.broadcasterManager = broadcasterManager;
     this.connectionManager  = connectionManager;
     this.coinType           = (CoinType)network.Consensus.CoinType;
     this.logger             = loggerFactory.CreateLogger(this.GetType().FullName);
     this.network            = network;
     this.walletManager      = walletManager;
 }
 public WalletTransactionHandler(
     ILoggerFactory loggerFactory,
     ConcurrentChain chain,
     IWalletManager walletManager,
     IWalletFeePolicy walletFeePolicy,
     Network network)
 {
     this.chain           = chain;
     this.walletManager   = walletManager;
     this.walletFeePolicy = walletFeePolicy;
     this.network         = network;
     this.coinType        = (CoinType)network.Consensus.CoinType;
     this.logger          = loggerFactory.CreateLogger(this.GetType().FullName);
 }
Example #6
0
        /// <summary>
        /// Gets all the transactions by coin type.
        /// </summary>
        /// <param name="coinType">Type of the coin.</param>
        /// <returns></returns>
        public IEnumerable <TransactionData> GetAllTransactionsByCoinType(CoinType coinType)
        {
            List <HdAccount> accounts = this.GetAccountsByCoinType(coinType).ToList();

            foreach (TransactionData txData in accounts.SelectMany(x => x.ExternalAddresses).SelectMany(x => x.Transactions))
            {
                yield return(txData);
            }

            foreach (TransactionData txData in accounts.SelectMany(x => x.InternalAddresses).SelectMany(x => x.Transactions))
            {
                yield return(txData);
            }
        }
Example #7
0
 private static Coin RandomCoin(Key[] bobs, Money amount, CoinType type)
 {
     if (bobs.Length == 1)
     {
         var bob = bobs[0];
         if (type == CoinType.Normal)
         {
             return(new Coin(new uint256(RandomUtils.GetBytes(32)), 0, amount, bob.PubKey.Hash.ScriptPubKey));
         }
         if (type == CoinType.P2WPKH)
         {
             return(new Coin(new uint256(RandomUtils.GetBytes(32)), 0, amount, bob.PubKey.WitHash.ScriptPubKey));
         }
         if (type == CoinType.P2SH)
         {
             return(new Coin(new uint256(RandomUtils.GetBytes(32)), 0, amount, bob.PubKey.ScriptPubKey.Hash.ScriptPubKey).ToScriptCoin(bob.PubKey.ScriptPubKey));
         }
         if (type == CoinType.SegwitP2SH)
         {
             return(new Coin(new uint256(RandomUtils.GetBytes(32)), 0, amount, bob.PubKey.ScriptPubKey.WitHash.ScriptPubKey.Hash.ScriptPubKey).ToScriptCoin(bob.PubKey.ScriptPubKey));
         }
         if (type == CoinType.Segwit)
         {
             return(new Coin(new uint256(RandomUtils.GetBytes(32)), 0, amount, bob.PubKey.ScriptPubKey.WitHash.ScriptPubKey).ToScriptCoin(bob.PubKey.ScriptPubKey));
         }
         throw new NotSupportedException();
     }
     else
     {
         while (type == CoinType.Normal || type == CoinType.P2WPKH)
         {
             type = (CoinType)(RandomUtils.GetUInt32() % 5);
         }
         var script = PayToMultiSigTemplate.Instance.GenerateScriptPubKey((int)(1 + (RandomUtils.GetUInt32() % bobs.Length)), bobs.Select(b => b.PubKey).ToArray());
         if (type == CoinType.P2SH)
         {
             return(new Coin(new uint256(RandomUtils.GetBytes(32)), 0, amount, script.Hash.ScriptPubKey).ToScriptCoin(script));
         }
         if (type == CoinType.SegwitP2SH)
         {
             return(new Coin(new uint256(RandomUtils.GetBytes(32)), 0, amount, script.WitHash.ScriptPubKey.Hash.ScriptPubKey).ToScriptCoin(script));
         }
         if (type == CoinType.Segwit)
         {
             return(new Coin(new uint256(RandomUtils.GetBytes(32)), 0, amount, script.WitHash.ScriptPubKey).ToScriptCoin(script));
         }
         throw new NotSupportedException();
     }
 }
Example #8
0
        /// <summary>
        /// 显示抛硬币面板
        /// </summary>
        public void ShowTossCoinPanel(bool showSelectCoinPanel, Action <CoinType, CoinType> actionTossCoin, CoinType coinType = CoinType.Unknown)
        {
            tossCoinPanel.SetActive(true);
            this.actionTossCoin = actionTossCoin;
            if (showSelectCoinPanel)
            {
                tossCoinPanel.transform.GetChild(0).gameObject.SetActive(true);
                tossCoinPanel.transform.GetChild(1).gameObject.SetActive(false);
            }
            else
            {
                tossCoinPanel.transform.GetChild(0).gameObject.SetActive(false);
                tossCoinPanel.transform.GetChild(1).gameObject.SetActive(true);
                StringResConfig stringResConfig = ConfigManager.GetConfigByName("StringRes") as StringResConfig;
                Text            playInfoText    = tossCoinPanel.transform.GetChild(1).GetChild(0).gameObject.GetComponent <Text>();
                switch (coinType)
                {
                case CoinType.Unknown:
                    playInfoText.text = "";
                    break;

                case CoinType.Front:
                    playInfoText.text = stringResConfig.GetRecordById(19).value + "正面";
                    break;

                case CoinType.Back:
                    playInfoText.text = stringResConfig.GetRecordById(19).value + "反面";
                    break;

                default:
                    break;
                }
            }

            CoinType resultCoinType = (CoinType)UnityEngine.Random.Range(1, 3);
            Sprite   coinSprite     = tossCoinPanel.transform.GetChild(0).GetChild((int)resultCoinType).GetChild(0).gameObject.GetComponent <Image>().sprite;

            tossCoinPanel.transform.GetChild(1).GetChild(1).gameObject.GetComponent <Image>().sprite = coinSprite;

            TimerFunction timerFunction = new TimerFunction();

            timerFunction.SetFunction(1, () =>
            {
                tossCoinPanel.SetActive(false);
                actionTossCoin(coinType, resultCoinType);
            });

            GameManager.AddTimerFunction(timerFunction);
        }
Example #9
0
        public ResponseMessage <string> transfer(string orderId, BigDecimal amount, CoinType coinType, string subCoinType, string address, string memo)
        {
            string callbackUrl = host + "/bipay/notify";

            try
            {
                ResponseMessage <string> resp = biPayClient.transfer(orderId, amount, coinType.getCode(), subCoinType, address, callbackUrl, memo);
                return(resp);
            }
            catch (Exception e)
            {
                e.printStackTrace();
            }
            return(ResponseMessage.error("提交转币失败"));
        }
Example #10
0
        public CoinInfo GetCoinInfo(IDbConnection con, CoinType coinType)
        {
            logger.LogInvoke();

            var query   = "SELECT * FROM coin_info WHERE cointype = @coin ";
            var results = con.Query <Entities.CoinInfo>(query, new { coin = coinType.ToString() })
                          .Select(mapper.Map <CoinInfo>)
                          .ToArray();

            if (results == null || results.Length == 0)
            {
                return(null);
            }
            return(results[0]);
        }
Example #11
0
        /**
         * 创建币种地址
         * @param coinType
         * @return
         */
        public Address CreateCoinAddress(CoinType coinType)
        {
            string callbackUrl = host + "/bipay/notify";

            try
            {
                ResponseMessage <Address> resp = udunClient.CreateCoinAddress(coinType.code, callbackUrl);
                return(resp.data);
            }
            catch (Exception e)
            {
                e.printStackTrace();
            }
            return(null);
        }
Example #12
0
 private void InsertCoin(CoinType coinType)
 {
     if (coinType == CoinType.Dime)
     {
         _amountInDollars += 0.1M;
     }
     else if (coinType == CoinType.Quarter)
     {
         _amountInDollars += 0.25M;
     }
     else if (coinType == CoinType.Nickel)
     {
         _amountInDollars += 0.05M;
     }
 }
Example #13
0
        private static void Main(string[] args)
        {
            CoinType coinType = GetCoinType(args);

            Console.WindowWidth = 150;

            Console.WriteLine("Bitcoin Address Generator");
            Console.WriteLine("=========================");
            Console.WriteLine();

            GenerateAddress(coinType);

            Console.WriteLine("Press any key to quit...");
            Console.ReadKey(true);
        }
Example #14
0
        private static (decimal rest, int coinAmount) GetCoinChange(
            this decimal val,
            CoinType coinType)
        {
            var coinTypeVal = coinType.ToDecimal();
            var coins       = 0;


            while (val >= coinTypeVal)
            {
                coins = coins + 1;
                val   = val - coinTypeVal;
            }

            return(val, coins);
        }
 public WalletTransactionHandler(
     ILoggerFactory loggerFactory,
     IWalletManager walletManager,
     IWalletFeePolicy walletFeePolicy,
     Network network)
 {
     this.Network         = network;
     this.walletManager   = walletManager;
     this.walletFeePolicy = walletFeePolicy;
     this.coinType        = (CoinType)network.Consensus.CoinType;
     this.logger          = loggerFactory.CreateLogger(this.GetType().FullName);
     this.privateKeyCache = new MemoryCache(new MemoryCacheOptions()
     {
         ExpirationScanFrequency = new TimeSpan(0, 1, 0)
     });
 }
Example #16
0
        private CoinInfo GetCoinInfoFromCryptoCompare(CoinType coinType)
        {
            var url      = "https://min-api.cryptocompare.com/data/price?fsym=" + coinType.ToString() + "&tsyms=BTC,USD";
            var json     = new WebClient().DownloadString(url);
            var response = JsonConvert.DeserializeObject <CryoptoCompareResponse>(json);

            return(new CoinInfo
            {
                CoinType = coinType,
                Name = coinType.ToString(),
                CoinMarketCapId = 0,
                PriceUSD = response.USD,
                PriceBTC = response.BTC,
                Updated = DateTime.Now
            });
        }
 public SmartContractTransactionService(
     Network network,
     IWalletManager walletManager,
     IWalletTransactionHandler walletTransactionHandler,
     IMethodParameterStringSerializer methodParameterStringSerializer,
     ICallDataSerializer callDataSerializer,
     IAddressGenerator addressGenerator)
 {
     this.network                         = network;
     this.walletManager                   = walletManager;
     this.walletTransactionHandler        = walletTransactionHandler;
     this.methodParameterStringSerializer = methodParameterStringSerializer;
     this.callDataSerializer              = callDataSerializer;
     this.coinType                        = (CoinType)network.Consensus.CoinType;
     this.addressGenerator                = addressGenerator;
 }
        public WalletManager(ILoggerFactory loggerFactory, ConnectionManager connectionManager, Network network, ConcurrentChain chain,
                             NodeSettings settings, DataFolder dataFolder)
        {
            this.logger  = loggerFactory.CreateLogger(this.GetType().FullName);
            this.Wallets = new List <Wallet>();

            this.connectionManager = connectionManager;
            this.network           = network;
            this.coinType          = (CoinType)network.Consensus.CoinType;
            this.chain             = chain;
            this.settings          = settings;
            this.dataFolder        = dataFolder;

            // register events
            this.TransactionFound += this.OnTransactionFound;
        }
Example #19
0
        private void SetActualPlayer()
        {
            switch (actualPlayer)
            {
            case CoinType.NoOne:
            case CoinType.X:
                actualPlayer = CoinType.O;
                break;

            case CoinType.O:
                actualPlayer = CoinType.X;
                break;
            }

            Console.WriteLine($"E' il turno del giocatore {actualPlayer.ToString()}");
        }
Example #20
0
    private void SpawnCoins(ChunkDesign _chunkDesign, Transform _chunkParent)
    {
        List <Vector3>  _coinLocalPositions = _chunkDesign.GetCoinLocalPositions();
        List <CoinType> _coinTypes          = CoinSpawnChancesByTimeLibrary.Instance.GetCoinTypesToSpawn(_coinLocalPositions.Count, Progression.Timer);

        for (int i = 0; i < _coinTypes.Count; i++)
        {
            CoinType _coinType      = _coinTypes[i];
            Vector3  _localPosition = _coinLocalPositions[i];

            GameObject _coinPrefab     = CoinPrefabByCoinTypeLibrary.Instance.GetCoinPrefab(_coinType);
            GameObject _coinGameObject = ObjectPool.Instance.GetObjectForType(_coinPrefab.name, false);
            _coinGameObject.transform.parent   = _chunkParent.transform;
            _coinGameObject.transform.position = new Vector3(_localPosition.x, _localPosition.y, _localPosition.z + _chunkParent.transform.position.z);
        }
    }
Example #21
0
        public static (double?coin, double?USD, double?RUB) GetProfit(CoinType ct)
        {
            string name = ct switch
            {
                CoinType.ETC => "EthereumClassic",
                CoinType.ETH => "Ethereum",
                CoinType.RVN => "Ravencoin",
                _ => ""
            };

            RootObject ro = null;

            try { ro = Profits.Where(x => x.name == name).First(); } catch { return(null, null, null); }

            return(ro.rewardsInDay, ro.revenueInDayUSD, ro.revenueInDayUSD *USDcost);
        }
Example #22
0
        public string SendRequest(CoinType coin, string fullAddress)
        {
            string data = String.Empty;

            byte[]         postData = Encoding.ASCII.GetBytes(data);
            HttpWebRequest request  = GetRequest(coin, postData, fullAddress);

            using (var stream = request.GetRequestStream())
            {
                stream.Write(postData, 0, postData.Length);
            }
            var response       = (HttpWebResponse)request.GetResponse();
            var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();

            return(responseString);
        }
Example #23
0
 public FederationWalletController(
     ILoggerFactory loggerFactory,
     IFederationWalletManager walletManager,
     IFederationWalletSyncManager walletSyncManager,
     IConnectionManager connectionManager,
     Network network,
     ConcurrentChain chain,
     IDateTimeProvider dateTimeProvider)
 {
     this.walletManager     = walletManager;
     this.walletSyncManager = walletSyncManager;
     this.connectionManager = connectionManager;
     this.coinType          = (CoinType)network.Consensus.CoinType;
     this.chain             = chain;
     this.logger            = loggerFactory.CreateLogger(this.GetType().FullName);
 }
Example #24
0
        /// <summary>
        /// Call API and GET list of account wallet addresses
        /// </summary>
        /// <returns></returns>
        public List <AccountWallet> GetAccountWalletList()
        {
            NameValueCollection nameValueCollection = new NameValueCollection();
            string apiURL = "";

            try
            {
                nameValueCollection.Add("AccountGuid", Application.Current.Properties["AccountID"].ToString());

                apiURL = APIConstants.APIURL + APIEndpoints.GetAccountWallet;
                List <AccountWallet> accountWalletList          = DownloadSerializedJSONData <List <AccountWallet> >(apiURL, nameValueCollection);
                List <AccountWallet> accountWalletListSupported = new List <AccountWallet>();

                // Update all AccountGuid properties in case they are returned null when there is no pre-existing wallet addresses saved for this account
                accountWalletList = accountWalletList.Select(c => { c.AccountGuid = (Guid)Application.Current.Properties["AccountID"]; return(c); }).ToList();

                // Update coin logo and build supported wallet list
                foreach (AccountWallet accountWallet in accountWalletList)
                {
                    // Skip unsupported coin types
                    if (Enum.IsDefined(typeof(CoinType), accountWallet.CoinType) == false)
                    {
                        continue;
                    }

                    CoinType coinType = CoinType.UNDEFINED;
                    Enum.TryParse(accountWallet.CoinType, out coinType);

                    CoinLogos.CoinLogoDictionary.TryGetValue(coinType, out string logoSourceLocation);
                    string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, logoSourceLocation);
                    if (accountWallet.WalletAddress == null)
                    {
                        accountWallet.WalletAddress = "";
                    }
                    accountWallet.CoinLogo = path;

                    accountWalletListSupported.Add(accountWallet);
                }

                return(accountWalletListSupported);
            }
            catch (Exception e)
            {
                logger.Error(e, $"Unable to retrieve the account wallet list for '{Application.Current.Properties["AccountID"].ToString()}' from '{apiURL}'");
                return(new List <AccountWallet>());
            }
        }
Example #25
0
        /// <summary>
        /// Creates a new coin, dropping reference to the previouse and showing it on the canvas.
        /// </summary>
        /// <param name="coinType">Type of coin to use.</param>
        /// <param name="gridSize">The size of one grid.</param>
        public void Create(CoinType coinType, Size gridSize)
        {
            CoinType = coinType;
            switch (coinType)
            {
            case CoinType.None:
            case CoinType.Red:
                Coin = new Image()
                {
                    Width  = gridSize.Width,
                    Height = gridSize.Height,
                    Source = redCoin
                };
                break;

            case CoinType.Blue:
                Coin = new Image()
                {
                    Width  = gridSize.Width,
                    Height = gridSize.Height,
                    Source = blueCoin
                };
                break;
            }
            canvas.Children.Add(Coin);
            location = new Point(location.X, 0);
            Move(location, gridSize, TimeSpan.FromMilliseconds(1));

            if (coinType == CoinType.None || deleteNext)
            {
                deleteNext = false;
                Delete();
            }
            else
            {
                switch (coinType)
                {
                case CoinType.Red:
                    RedTurn?.Invoke(this, null);
                    break;

                case CoinType.Blue:
                    BlueTurn?.Invoke(this, null);
                    break;
                }
            }
        }
        private void buttonGenerateAddress_Click(object sender, EventArgs e)
        {
            BitcoinAddressGenerator addressGenerator = new BitcoinAddressGenerator();
            CoinType    coinType    = (CoinType)Enum.Parse(typeof(CoinType), (string)this.comboBoxCoinTypeGenerate.SelectedItem);
            AddressInfo addressInfo = addressGenerator.GenerateAddress(coinType);

            this.textBoxPrivateKeyHex.Text = addressInfo.PrivateKeyHex;
            this.textBoxPrivateKeyWif.Text = addressInfo.PrivateKeyWif;
            this.textBoxPublicKeyHex.Text  = addressInfo.PublicKeyHex;
            this.textBoxPublicKeyHash.Text = addressInfo.PublicKeyHash;
            this.textBoxAddress.Text       = addressInfo.Address;
            this.labelAddress.Text         = $@"Address ({coinType:G})";

            this.comboBoxCoinTypeBlockExplorer.SelectedIndex = this.comboBoxCoinTypeGenerate.SelectedIndex;
            this.labelStatus.ForeColor = Color.Green;
            this.labelStatus.Text      = @"Address generation successful!";
        }
Example #27
0
        /// <summary>
        /// Lets the game engine communicate an end result to the user via the game chat.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GameMessage_Recieved(object sender, CoinType e)
        {
            switch (e)
            {
            case CoinType.None:
                Application.Current.Dispatcher.Invoke((Action <object>)AddMessage, new Message($"The Game has ended in a tie!", "Server"));
                break;

            case CoinType.Red:
                Application.Current.Dispatcher.Invoke((Action <object>)AddMessage, new Message($"You have won!", "Server"));
                break;

            case CoinType.Blue:
                Application.Current.Dispatcher.Invoke((Action <object>)AddMessage, new Message($"Your opponent has won!", "Server"));
                break;
            }
        }
Example #28
0
        public ATransaction CreateTransaction(decimal amount, CoinType coinType, Party toParty, int?index = null)
        {
            ATransaction tx;

            if (index != null)
            {
                tx = new ATransaction(amount, toParty, Transactions[0]);
            }
            else
            {
                tx = new ATransaction(amount, toParty);
            }
            tx.Amount   = amount;
            tx.CoinType = coinType;
            Transactions.Add(tx);
            return(tx);
        }
        public async Task <CoinPriceResponse> FetchCoinPriceAsync()
        {
            // Fetch preferred coin from in-memory cache
            CoinType preferredCoin = _userRepository.FetchPreferredCoin();

            // Fetch price data from coin
            PriceResponse response = await _coinPriceGateway.FetchCoinPriceAsync(preferredCoin).ConfigureAwait(false);

            // Map and return response
            return(new CoinPriceResponse
            {
                CoinType = preferredCoin,
                Rate = response.Rate,
                Bid = response.Bid,
                Ask = response.Ask
            });
        }
        /// <summary>
        /// Gets the first account that contains no transaction.
        /// </summary>
        /// <returns>An unused account.</returns>
        public HdAccount GetFirstUnusedAccount(CoinType coinType)
        {
            // Get the accounts root for this type of coin.
            AccountRoot accountsRoot = this.AccountsRoot.Single(a => a.CoinType == coinType);

            if (accountsRoot.Accounts.Any())
            {
                // Get an unused account.
                HdAccount firstUnusedAccount = accountsRoot.GetFirstUnusedAccount();
                if (firstUnusedAccount != null)
                {
                    return(firstUnusedAccount);
                }
            }

            return(null);
        }
        public FederationWalletManager(
            ILoggerFactory loggerFactory,
            Network network,
            ChainIndexer chainIndexer,
            DataFolder dataFolder,
            IWalletFeePolicy walletFeePolicy,
            IAsyncLoopFactory asyncLoopFactory,
            INodeLifetime nodeLifetime,
            IDateTimeProvider dateTimeProvider,
            IFederationGatewaySettings federationGatewaySettings,
            IWithdrawalExtractor withdrawalExtractor,
            IBroadcasterManager broadcasterManager = null) // no need to know about transactions the node broadcasted
        {
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(network, nameof(network));
            Guard.NotNull(chainIndexer, nameof(chainIndexer));
            Guard.NotNull(dataFolder, nameof(dataFolder));
            Guard.NotNull(walletFeePolicy, nameof(walletFeePolicy));
            Guard.NotNull(asyncLoopFactory, nameof(asyncLoopFactory));
            Guard.NotNull(nodeLifetime, nameof(nodeLifetime));
            Guard.NotNull(federationGatewaySettings, nameof(federationGatewaySettings));
            Guard.NotNull(withdrawalExtractor, nameof(withdrawalExtractor));

            this.lockObject = new object();

            this.logger = loggerFactory.CreateLogger(this.GetType().FullName);

            this.network                   = network;
            this.coinType                  = (CoinType)network.Consensus.CoinType;
            this.chainIndexer              = chainIndexer;
            this.asyncLoopFactory          = asyncLoopFactory;
            this.nodeLifetime              = nodeLifetime;
            this.fileStorage               = new FileStorage <FederationWallet>(dataFolder.WalletPath);
            this.broadcasterManager        = broadcasterManager;
            this.dateTimeProvider          = dateTimeProvider;
            this.federationGatewaySettings = federationGatewaySettings;
            this.withdrawalExtractor       = withdrawalExtractor;
            this.outpointLookup            = new Dictionary <OutPoint, TransactionData>();
            this.isFederationActive        = false;

            // register events
            if (this.broadcasterManager != null)
            {
                this.broadcasterManager.TransactionStateChanged += this.BroadcasterManager_TransactionStateChanged;
            }
        }
Example #32
0
        public Coin(float x, float y, int coinValue, CoinType coinType, float targetX = 0, float targetY = 0)
            : base(x, y)
        {
            this.CoinType = coinType;
            this.ScaleX = 0.7f;
            this.ScaleY = 0.7f;
            this.CoinValue = coinValue;

            if (targetX != 0 && targetY != 0)
            {
                SpawnTarget = new Vector2(targetX, targetY);
                CoinState = State.Spawning;
            }
            else
            {
                CoinState = State.Active;
            }
        }
Example #33
0
 public void AddCoin(CoinType coinType)
 {
     switch (coinType)
     {
         case CoinType.One:
             CoinsInBox.CoinsOne.Add(1);
             break;
         case CoinType.Two:
             CoinsInBox.CoinsTwo.Add(1);
             break;
         case CoinType.Five:
             CoinsInBox.CoinsFive.Add(1);
             break;
         case CoinType.Ten:
             CoinsInBox.CoinsTen.Add(1);
             break;
     }
 }
Example #34
0
    public void TakeCoin(CoinType coinType)
    {
        //coinBronzeAmount += (int)coinType;

        switch (coinType)
        {
            case CoinType.Gold:
                coinGoldAmount++;
                break;

            case CoinType.Silver:
                coinSilverAmount++;
                break;

            case CoinType.Bronze:
            default:
                coinBronzeAmount++;
                break;
        }
    }
Example #35
0
 public void SetCurrencyValue(CoinType coinType, ExchangeType exchangeType, Currency currency)
 {
     currenciesDictionary[coinType][exchangeType] = currency;
 }
 public void CustomerPayment(CoinType c, int quantity)
 {
     if (_customerWallet.Coins[c] <= 0) return;
     lock (_syncRoot)
     {
         _vmWallet.Coins[c] += quantity;
         _customerWallet.Coins[c] -= quantity;
         _customerBalance = _customerBalance + quantity * (int)c;
     }
 }
Example #37
0
 /// <summary>
 /// Deposits the amount of the coin type provided into the bank. Optional third parameter will
 /// move the coin from the regular bank to the shared bank if true.
 /// </summary>
 /// <param name="type">coin type</param>
 /// <param name="amount">coin amount</param>
 /// <param name="useBank">use bank as source</param>
 /// <returns></returns>
 public bool SharedBankDeposit(CoinType type, int amount, bool useBank = false)
 {
     Trace.WriteLine(String.Format("Character:BankDeposit({0}, {1}, {2})", type,
         amount.ToString(CultureInfo.InvariantCulture), useBank));
     return !useBank ? this.ExecuteMethod("BankDeposit", type.ToString()[0].ToString(CultureInfo.InvariantCulture),
         amount.ToString(CultureInfo.InvariantCulture)) : this.ExecuteMethod("BankDeposit",
         type.ToString()[0].ToString(CultureInfo.InvariantCulture), amount.ToString(CultureInfo.InvariantCulture), "FromBank");
 }
Example #38
0
 /// <summary>
 /// Withdraws the specified coin type and amount from the shared bank.
 /// </summary>
 /// <param name="type">coin type</param>
 /// <param name="amount">coin amount</param>
 /// <returns>call success</returns>
 public bool SharedBankWithdraw(CoinType type, int amount)
 {
     Trace.WriteLine(String.Format("Character:SharedBankWithdraw({0}, {1})", type,
        amount.ToString(CultureInfo.InvariantCulture)));
     return this.ExecuteMethod("SharedBankWithdraw", type.ToString()[0].ToString(CultureInfo.InvariantCulture),
         amount.ToString(CultureInfo.InvariantCulture));
 }
Example #39
0
 void Construct(float x=0, float y=0, CoinType coinType=CoinType.Copper, int coinValue=0)
 {
     this.Pos = new Vector2(x, y);
     this.CoinType = coinType;
     this.ScaleX = 0.7f;
     this.ScaleY = 0.7f;
     this.CoinValue = coinValue;
     this.EntityCollisionEnabled = false;
     this.CollisionGroup = "Shadow";
 }
Example #40
0
 public Coin(float x, float y, int coinValue, CoinType coinType)
 {
     Construct(x, y, coinType, coinValue);
 }
Example #41
0
 public Currency GetCurrencyValue(CoinType coinType, ExchangeType exchangeType)
 {
     return currenciesDictionary[coinType][exchangeType];
 }
Example #42
0
 public Coins(CoinType coinType, int amount)
     : base(coinType)
 {
     Amount = amount;
 }
Example #43
0
 public Coin(CoinType type)
 {
     CoinType = type;
 }