Exemplo n.º 1
0
    public override void Update()
    {
        base.Update();

        coinCounter += Time.DeltaTime * CoinPerSec;
        var coinToAdd = (int)Math.Floor(coinCounter);

        if (coinToAdd > 0)
        {
            coinCounter -= coinToAdd;
            Coin.Add(coinToAdd);
        }

        var labelColor = Coin.Value == Coin.Max ? Color.Red : Skin.TextColor;

        coinPerSecLabel.Color = labelColor;
        if (Coin.Value == Coin.Max)
        {
            coinPerSecLabel.Color = new Color(0xBE, 0x26, 0x33);
            coinPerSecLabel.SetText(COIN_PER_SEC_FORMAT, 0);
        }
        else
        {
            coinPerSecLabel.Color = Skin.TextColor;
            coinPerSecLabel.SetText(COIN_PER_SEC_FORMAT, CoinPerSec);
        }
    }
Exemplo n.º 2
0
    public void AddHP(float amt)
    {
        if (hp + amt > maxHP)
        {
            hp = maxHP;
        }
        else if (hp + amt < 0)
        {
            hp = 0;
            StopBattle();
            target.SendMessage("StopBattle");
            if (transform.name == "Enemy")
            {
                Coin.Add(Level.nowLevel * 1000);
            }
            else if (transform.name == "Player")
            {
                PlayerPrefs.SetFloat("FinalATK", atk);
                PlayerPrefs.SetFloat("FinalSPD", spd);
            }
            Destroy(gameObject);
        }
        else
        {
            // under attack
            if (amt < 0)
            {
                Hit();
            }

            hp += amt;
        }
    }
Exemplo n.º 3
0
        public void WhenPutCoinInWalletWithGivenParValue_ThenWalletShouldContainSumForThisParValue(int parValue, int coinCount)
        {
            var coin = new Coin(parValue, coinCount);
            var inWalletCoinCount = new Random().Next(0, 100);
            var inWalletCoin      = new Coin(parValue, inWalletCoinCount);
            var wallet            = new Wallet(new [] { inWalletCoin });

            var walletCoins = wallet
                              .Put(coin)
                              .ShowCoins();

            inWalletCoin = inWalletCoin.Add(coinCount);

            Assert.True(walletCoins.Single().Equals(inWalletCoin));
        }
Exemplo n.º 4
0
    void OnGUI()
    {
        Event e = Event.current;

        if (e.type == EventType.KeyDown)
        {
            int key = (int)e.keyCode - (int)KeyCode.Keypad0;
            if (key == answer)
            {
                Coin.Add(1000);
                correctTyping++;
                RandomNumber();
            }
            else if (key >= 0 && key < 10)
            {
                wrongTyping++;
                Coin.Add(1);
            }
            Event.current.Use();
        }
    }
Exemplo n.º 5
0
        public void WhenPutCoinInWalletWithGivenParValue_ThenWalletShouldContainSumForThisParValue(int parValue, int coinCount)
        {
            var coin = new Coin(parValue, coinCount);
            var inWalletCoinCount = new Random().Next(0, 100);
            var inWalletCoin = new Coin(parValue, inWalletCoinCount);
            var wallet = new Wallet(new [] { inWalletCoin });

            var walletCoins = wallet
                .Put(coin)
                .ShowCoins();
            inWalletCoin = inWalletCoin.Add(coinCount);

            Assert.True(walletCoins.Single().Equals(inWalletCoin));
        }