Inheritance: MonoBehaviour
 public void AddCoin(CoinCollection coinObj)
 {
     if (!coinList.Contains(coinObj))
     {
         coinList.Add(coinObj);
     }
 }
Ejemplo n.º 2
0
 void Start()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Ejemplo n.º 3
0
 // Use this for initialization
 void Start()
 {
     resetSpeedSqr  = resetSpeed * resetSpeed;
     spring         = projectile.GetComponent <SpringJoint2D> ();
     targetDamage   = targetDamageObj.GetComponent <TargetDamage>();
     coinCollection = collectCoinObj.GetComponent <CoinCollection> ();
     scoreNo        = targetDamage.score + coinCollection.collect;
 }
Ejemplo n.º 4
0
    void Start()
    {
        CC = CoinColletor.GetComponent <CoinCollection> ();
        AS = GetComponent <AudioSource> ();

        GameStateObject = GameObject.Find("GameState");
        GS = GameStateObject.GetComponent <GameState> ();
    }
Ejemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        Coins       = new List <GameObject>(GameObject.FindGameObjectsWithTag("Coin"));
        MemoryCoins = Coins;

        CC = CoinColletor.GetComponent <CoinCollection> ();

        SetCoins();
    }
Ejemplo n.º 6
0
 public void OnCoinCollectionChanged(CoinCollection collection)
 {
     if (collection.NumCoins > 0)
     {
         StartCoroutine(PopUp(collection.NumCoins, collection.MaxCoins));
     }
     else
     {
         levelCompleteMenu.Show();
     }
 }
Ejemplo n.º 7
0
        public void GivenNoCoinsHaveBeenInserted_WhenUpdate_ThenInsertCoinShouldBeDisplayed()
        {
            IVendingMachineDisplay vendingMachineDisplay = Mocker.CreateInstance <VendingMachineDisplay>();
            ICoinCollection        coinCollection        = new CoinCollection();
            var expectedString = Resources.Strings.InsertCoin;

            vendingMachineDisplay.Update(coinCollection);

            vendingMachineDisplay.Display.Should().Be(expectedString);
            Mocker.Verify <IDisplayWriter>(d => d.Write(expectedString), Times.Once);
        }
Ejemplo n.º 8
0
        public void GivenANickelHasBeenInserted_WhenUpdate_Then5CentsShouldBeDisplayed()
        {
            IVendingMachineDisplay vendingMachineDisplay = Mocker.CreateInstance <VendingMachineDisplay>();
            ICoinCollection        coinCollection        = new CoinCollection()
            {
                new Nickle()
            };
            var expectedString = string.Format(Resources.Strings.DisplayCoinTotal, 0.05);

            vendingMachineDisplay.Update(coinCollection);

            vendingMachineDisplay.Display.Should().Be(expectedString);
            Mocker.Verify <IDisplayWriter>(d => d.Write(expectedString), Times.Once);
        }
Ejemplo n.º 9
0
    public Game1()
    {
        graphics = new GraphicsDeviceManager(this);
        graphics.PreferredBackBufferWidth  = 768;
        graphics.PreferredBackBufferHeight = 576;
        Content.RootDirectory = "Content";

        // The InputHandler class is not part of XNA but has been written by Simon Schofield to help
        // parse user input. The class casn be found in the Solution Explorer
        input           = new InputHandler();
        Knight          = new Character(input);
        groundCollision = new GroundCollision(Knight, myLevel);
        coin            = new CoinCollection(Knight);
        enemy           = new Enemy(Knight);
    }
Ejemplo n.º 10
0
 public void Write(CoinCollection data)
 {
     using (var stream = new FileStream(GetFullFilePath(), FileMode.CreateNew))
     {
         using (var writer = new StreamWriter(stream))
         {
             //always write header line
             writer.WriteLine("Name, Id, Tag, Algorithm, Block Time, Block Reward, Block Reward 24, Last Block, Difficulty, Difficulty 24, Net Hash, Exchange Rate, Exchange Rate 24, Exchange Rate Vol, Exchange Rate Curr, Market Cap, Estimated Rewards, Estimated Rewards 24, Btc Revenue, Btc Revenue 24, Profitability, Profitability 24, Lagging, Timestamp");
             foreach (var item in data.coins)
             {
                 writer.WriteLine($"{item.Key}, {item.Value.ToString()}");
             }
         }
     }
 }
 private void UpdateToUncoloredCoins(CoinCollection collection)
 {
     if(collection == null)
         return;
     for(int i = 0; i < collection.Count; i++)
     {
         var coin = collection[i] as ColoredCoin;
         if(coin != null)
             collection[i] = coin.Bearer;
     }
 }
 private void UpdateToColoredCoins(CoinCollection collection, bool input)
 {
     if(collection == null)
         return;
     for(int i = 0; i < collection.Count; i++)
     {
         var coin = collection[i] as Coin;
         if(coin != null)
         {
             if(input)
             {
                 var txinIndex = SpentIndices[i];
                 var asset = ColoredTransaction
                                 .Inputs
                                 .Where(_ => _.Index == (uint)txinIndex)
                                 .Select(_ => _.Asset)
                                 .FirstOrDefault();
                 if(asset != null)
                     collection[i] = coin.ToColoredCoin(asset);
             }
             else
             {
                 var asset = ColoredTransaction.GetColoredEntry(coin.Outpoint.N);
                 if(asset != null)
                     collection[i] = coin.ToColoredCoin(asset.Asset);
             }
         }
     }
 }
        internal OrderedBalanceChange(DynamicTableEntity entity)
        {
            var splitted = entity.RowKey.Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries);
            Height = Helper.StringToHeight(splitted[1]);
            BalanceId = BalanceId.Parse(splitted[0]);

            var locator = BalanceLocator.Parse(string.Join("-", splitted.Skip(1).ToArray()), true);
            var confLocator = locator as ConfirmedBalanceLocator;
            if(confLocator != null)
            {
                Height = confLocator.Height;
                TransactionId = confLocator.TransactionId;
                BlockId = confLocator.BlockHash;
            }

            var unconfLocator = locator as UnconfirmedBalanceLocator;
            if(unconfLocator != null)
            {
                TransactionId = unconfLocator.TransactionId;
            }

            SeenUtc = entity.Properties["s"].DateTime.Value;

            _SpentOutpoints = Helper.DeserializeList<OutPoint>(Helper.GetEntityProperty(entity, "a"));

            if(entity.Properties.ContainsKey("b0"))
                _SpentCoins = new CoinCollection(Helper.DeserializeList<Spendable>(Helper.GetEntityProperty(entity, "b")).Select(s => new Coin()
                {
                    Outpoint = s.OutPoint,
                    TxOut = s.TxOut
                }).ToList());
            else if(_SpentOutpoints.Count == 0)
                _SpentCoins = new CoinCollection();

            _SpentIndices = Helper.DeserializeList<IntCompactVarInt>(Helper.GetEntityProperty(entity, "ss")).Select(i => (uint)i.ToLong()).ToList();

            var receivedIndices = Helper.DeserializeList<IntCompactVarInt>(Helper.GetEntityProperty(entity, "c")).Select(i => (uint)i.ToLong()).ToList();
            var receivedTxOuts = Helper.DeserializeList<TxOut>(Helper.GetEntityProperty(entity, "d"));

            _ReceivedCoins = new CoinCollection();
            for(int i = 0; i < receivedIndices.Count; i++)
            {
                _ReceivedCoins.Add(new Coin()
                {
                    Outpoint = new OutPoint(TransactionId, receivedIndices[i]),
                    TxOut = receivedTxOuts[i]
                });
            }

            var flags = entity.Properties["e"].StringValue;
            HasOpReturn = flags[0] == 'o';
            IsCoinbase = flags[1] == 'o';

            _MatchedRules = Helper.DeserializeObject<List<MatchedRule>>(entity.Properties["f"].StringValue).ToList();

            if(entity.Properties.ContainsKey("g"))
            {
                var ctx = new ColoredTransaction();
                ctx.FromBytes(entity["g"].BinaryValue);
                ColoredTransaction = ctx;
            }

            if(entity.Properties.ContainsKey("h"))
            {
                _ScriptPubKey = new Script(entity.Properties["h"].BinaryValue);
            }

            var data = Helper.GetEntityProperty(entity, "cu");
            if(data != null)
                CustomData = Encoding.UTF8.GetString(data);
        }
 public OrderedBalanceChange()
 {
     _SpentIndices = new List<uint>();
     _SpentOutpoints = new List<OutPoint>();
     _ReceivedCoins = new CoinCollection();
 }
        internal void Merge(OrderedBalanceChange other, WalletRule walletRule)
        {
            if(other.ReceivedCoins.Count != 0)
            {
                ReceivedCoins.AddRange(other.ReceivedCoins);
                ReceivedCoins = new CoinCollection(ReceivedCoins.Distinct<ICoin, OutPoint>(c => c.Outpoint));
                if(walletRule != null)
                    foreach(var c in other.ReceivedCoins)
                    {
                        this.MatchedRules.Add(new MatchedRule()
                        {
                            Index = c.Outpoint.N,
                            Rule = walletRule,
                            MatchType = MatchLocation.Output
                        });
                    }
            }

            if(other.SpentIndices.Count != 0)
            {
                SpentIndices.AddRange(other.SpentIndices);
                SpentIndices = SpentIndices.Distinct().ToList();

                SpentOutpoints.AddRange(other.SpentOutpoints);
                SpentOutpoints = SpentOutpoints.Distinct().ToList();

                //Remove cached value, no longer correct
                UpdateToUncoloredCoins();
                SpentCoins = null;

                if(walletRule != null)
                    foreach(var c in other.SpentIndices)
                    {
                        this.MatchedRules.Add(new MatchedRule()
                        {
                            Index = c,
                            Rule = walletRule,
                            MatchType = MatchLocation.Input
                        });
                    }
            }
        }
Ejemplo n.º 16
0
 public Recipient(string name)
 {
     Id            = new Id();
     Name          = name.ToUpper();
     ReceivedCoins = new CoinCollection();
 }
Ejemplo n.º 17
0
 public Issuer(string name)
 {
     Id          = new Id();
     Name        = name.ToUpper();
     IssuedCoins = new CoinCollection();
 }
        public async Task<bool> EnsureSpentCoinsLoadedAsync(ITransactionRepository transactions)
        {
            if(SpentCoins != null)
                return true;

            bool cleanSpent = false;
            CoinCollection result = new CoinCollection();
            for(int i = 0; i < SpentOutpoints.Count; i++)
            {
                var outpoint = SpentOutpoints[i];
                if(outpoint.IsNull)
                    continue;
                var prev = await transactions.GetAsync(outpoint.Hash).ConfigureAwait(false);
                if(prev == null)
                    return false;

                var coin = new Coin(outpoint, prev.Outputs[SpentOutpoints[i].N]);
                if(coin.ScriptPubKey != GetScriptPubkey(i))
                {
                    cleanSpent = true;
                    SpentOutpoints[i] = null;
                }
                else
                    result.Add(coin);
            }

            if(cleanSpent)
            {
                List<uint> spentIndices = new List<uint>();
                List<OutPoint> spentOutpoints = new List<OutPoint>();
                List<MatchedRule> matchedRules = new List<MatchedRule>();
                for(int i = 0; i < SpentOutpoints.Count; i++)
                {
                    if(SpentOutpoints[i] != null)
                    {
                        spentIndices.Add(SpentIndices[i]);
                        spentOutpoints.Add(SpentOutpoints[i]);
                        if(MatchedRules != null && MatchedRules.Count != 0)
                            matchedRules.Add(MatchedRules[i]);
                    }
                }
                SpentIndices = spentIndices;
                SpentOutpoints = spentOutpoints;
                MatchedRules = matchedRules;
            }

            SpentCoins = result;
            UpdateToScriptCoins();
            return true;
        }