//trigger detection for enemy ships and coins.
 void OnTriggerEnter2D(Collider2D col)
 {
     if (col.tag == "UpgradeCoin")
     {
         //Debug.Log ("Trigger Collision: " + col.tag);
         CoinValue value = col.gameObject.GetComponent <CoinValue> ();
         PlayerStatsManager.SetPlayerScore(value.GetCoinValue());
         value.PassUpgradeValue();
         Destroy(col.gameObject);
     }
     if (col.tag == "Enemy Ship" || col.tag == "EliteEnemyShip")
     {
         PlayerStatsManager.SetPlayerHealth(-enemyCollisionDamage);
         EnemyAI collide = col.gameObject.GetComponent <EnemyAI> ();
         if (col.tag == "EliteEnemyShip")
         {
             collide.SetDamage(5f);
         }
         else
         {
             collide.SetDamage(100f);
         }
         hurtSound.Play();
     }
 }
Exemplo n.º 2
0
        public void UpdateMyCoins()
        {
            MyCoinsValues2.Clear();


            CoinValue CV = new CoinValue();

            CoinButton.Clicked += async(s, e) => {
                for (int i = 0; i < myCoins.Length; i++)
                {
                    TheCoinJson = await GetCoinsAsync(myCoins[i]);

                    CoinValue theCoin = JsonConvert.DeserializeObject <CoinValue>(TheCoinJson);

                    //Array
                    MyCoinsValues[i] = String.Format("Coin Name: {0} USD: {1}", myCoins[i], theCoin.USD);

                    //List
                    MyCoinsValues2.Add(String.Format("Coin: {0}\t USD: {1} $\t DKK: {2} Kr.", myCoins[i], theCoin.USD, (theCoin.USD * USDkurs).ToString("0.##")));

                    //Add to property array
                    CV = new CoinValue {
                        CoinName = myCoins[i], BTC = theCoin.BTC, USD = theCoin.USD
                    };

                    CoinInfo.Text += String.Format("Coin Name: {0} USD: {1}", myCoins[i], theCoin.USD);
                }


                MineCoinsArray.ItemsSource = MyCoinsValues2;
            };
        }
 public async Task<UserCoinLink> GetUserCoin(Guid userId, CoinValue coinValue)
 {
     var repository = UnitOfWork.GetRepository<UserCoinLink>();
     return await repository.Select()
         .FilterByUserId(userId)
         .FilterByCoinValue(coinValue)
         .FirstOrDefaultAsync();
 }
        public async Task<VendingMachineCoinLink> GetVendingMachineCoin(
            int vendingMachineId, CoinValue coinValue)
        {
            var repository = UnitOfWork.GetRepository<VendingMachineCoinLink>();

            return await repository.Select()
                .FilterByVendingMachineId(vendingMachineId)
                .FilterByCoinValue(coinValue)
                .FirstOrDefaultAsync();
        }
Exemplo n.º 5
0
 public void Draw(SpriteBatch spriteBatch)
 {
     if (IsVisible)
     {
         spriteBatch.Begin();
         spriteBatch.Draw(TextureManager.AllTextures[SpriteTextureKey], SpritePosition, Color.White);
         spriteBatch.DrawString(Helper.SpriteFont, CoinValue.ToString(), SpritePosition, Color.White);
         spriteBatch.End();
     }
 }
Exemplo n.º 6
0
        private double getSlope(string coin, List <CoinValue> history)
        {
            if (history.Count <= 1)
            {
                return(0);
            }
            CoinValue Current = history.Last();

            history.Remove(history.Last());
            CoinValue Previous = history.Last();

            return(0.1 * ((Current.CoinValueId - Previous.CoinValueId) / (Current.date - Previous.date).TotalDays) + 0.9 * getSlope(coin, history));
        }
Exemplo n.º 7
0
        // This method "flips" the given instance of Coin
        // (i.e. randomly assign a value of "HEADS" or "TAILS" to the "Value" field)
        public void Flip()
        {
            Random rand    = new Random();
            double randVar = rand.NextDouble();

            if (randVar < 0.5)
            {
                Value = CoinValue.HEADS;
            }
            else
            {
                Value = CoinValue.TAILS;
            }
        }
Exemplo n.º 8
0
        //Update bruger coins og vis i view
        public async Task UpdateCoinsAsync()
        {
            for (int i = 0; i < myCoins.Count; i++)
            {
                TheCoinJson = await GetCoinsAsync(myCoins[i]);

                CoinValue theCoin = JsonConvert.DeserializeObject <CoinValue>(TheCoinJson);
                CreateCoin(myCoins[i], theCoin.BTC, theCoin.USD, CoinAmounts[i], theCoin.USD * CoinAmounts[i], Math.Round((theCoin.USD * CoinAmounts[i] * USDkurs), 2, MidpointRounding.AwayFromZero), CoinBoughtTo[i], (CoinAmounts[i] * theCoin.USD * USDkurs) - (CoinAmounts[i] * CoinBoughtTo[i] * USDkurs));
            }

            BindingContext         = this;
            MyCoinList.ItemsSource = NewCoins;
            TotalAmountinDKK.Text  = "Total DKK: " + TotalAmountDKK.ToString();
            TotalOutcomeinDKK.Text = "Total Over-/Underskud: " + Math.Round((TotalOutcomeDKK), 2, MidpointRounding.AwayFromZero).ToString();
        }
Exemplo n.º 9
0
        //Opret coins i Newcoin listen
        private void CreateCoin(string coinname, float btc, float usd, double myamount, double amountusd, double amountdkk, double coinboughtto, double coinoutcomedkk)
        {
            CoinValue coin = new CoinValue();

            coin.CoinName       = coinname;
            coin.BTC            = btc;
            coin.USD            = usd;
            coin.MyAmount       = myamount;
            coin.AmountUSD      = amountusd;
            coin.AmountDKK      = amountdkk;
            TotalAmountDKK     += amountdkk;
            TotalOutcomeDKK    += coinoutcomedkk;
            coin.CoinBoughtTo   = coinboughtto;
            coin.CoinOutcomeDKK = coinoutcomedkk;
            NewCoins.Add(coin);
        }
Exemplo n.º 10
0
        public async Task <string> GetCoinsAsync(string code)
        {
            var client = new System.Net.Http.HttpClient();

            client.DefaultRequestHeaders.Add("Accept", "application/json");
            var address = $"https://min-api.cryptocompare.com/data/price?fsym={code}&tsyms=BTC,USD"; //?format=application/json";

            var response = await client.GetAsync(address);

            var CoinJson = response.Content.ReadAsStringAsync().Result;

            CoinValue theCoin = JsonConvert.DeserializeObject <CoinValue>(CoinJson);


            return(CoinJson);
        }
Exemplo n.º 11
0
        public DashPage()
        {
            InitializeComponent();
            UpdateMyCoins();
            //MineCoinsArray.ItemsSource = MyCoinsValues;


            CoinButton.Clicked += async(s, e) => {
                var code = CoinCode.Text;


                //CoinInfo.Text += await GetCoinsAsync(code);
                TheCoinJson = await GetCoinsAsync(code);



                CoinValue theCoin = JsonConvert.DeserializeObject <CoinValue>(TheCoinJson);

                CoinValue c = new CoinValue();

                c = new CoinValue {
                    CoinName = code, USD = theCoin.USD, BTC = theCoin.BTC
                };


                CoinInfo.Text += String.Format("Coin Name: {0} USD: {1} BTC: {2}", code, theCoin.USD, theCoin.BTC);

                //CoinInfo.Text += "Coinname: " + code + " USD: " + theCoin.TRX.USD + " BTC: " + theCoin.TRX.BTC;
            };



            //airportButton.Clicked += async (s, e) =>
            //{
            //    //CoinInfo.Text = await GetCoinsAsync();
            //    TheCoinJson = await GetCoinsAsync();

            //    //Coin.Rootobject theCoin = JsonConvert.DeserializeObject<Coin.Rootobject>(TheCoinJson);
            //    //var Items = JsonConvert.DeserializeObject<List<Coin>>(TheCoinJson);
            //    //ListView1.ItemsSource = Items;

            //    Coin theCoin = JsonConvert.DeserializeObject<Coin>(TheCoinJson);


            //    CoinInfo.Text = "USD: " + theCoin.USD.ToString() + "BTC: " + theCoin.BTC;
            //};
        }
Exemplo n.º 12
0
    public void SpawnCoins(GameObject _coin, Vector3 _pos, float _vel, int _coinValue, int _numCoins)
    {
        for (int i = 0; i < _numCoins; ++i)
        {
            GameObject newCoin = Instantiate(_coin, _pos, Quaternion.identity);
            Vector2    outDir  = new Vector2(Random.Range(-1.0f, 1.0f), Random.Range(-1.0f, 1.0f));
            outDir.Normalize();
            Rigidbody2D rb = newCoin.GetComponent <Rigidbody2D>();
            //rb.AddRelativeForce(new Vector2(outDir.x * coinOutForce, outDir.y * coinOutForce));
            rb.velocity = new Vector2(outDir.x * _vel, outDir.y * _vel);
            CoinValue cv = newCoin.GetComponent <CoinValue>();
            cv.value = _coinValue;

            var go = newCoin;
            NetworkServer.Spawn(go);
        }
    }
Exemplo n.º 13
0
    public void ModifyHp(float value)
    {
        if (isInvincible)
        {
            return;
        }

        //syncing of hp
        if (!isServer)
        {
            return;
        }

        currHp += value;

        if (currHp <= 0)
        {
            if (gameObject.tag.Equals("EnemyBoss"))
            {
                Global.Instance.bossIsDead = true;
                Global.Instance.victory    = true;
            }
            if (!gameObject.tag.Equals("Player"))
            {
                PlayerPrefs.SetInt(PREFTYPE.NUM_OF_KILLS.ToString(), PlayerPrefs.GetInt(PREFTYPE.NUM_OF_KILLS.ToString(), 0) + 1);
                Global.Instance.player.SendMessage("AddScore", 2);

                float chance = Random.Range(0.0f, 1.0f);
                if (chance > 0.75f)
                {
                    if (coinPrefab)
                    {
                        GameObject temp = Instantiate(coinPrefab);
                        temp.transform.position = this.transform.position;
                        CoinValue cvscript = temp.GetComponent <CoinValue>();
                        cvscript.value = Random.Range(10, 30);
                    }
                }

                Destroy(gameObject);
            }
        }
    }
Exemplo n.º 14
0
        protected override void OnPaint(PaintEventArgs eventArgs)
        {
            Rectangle rect = eventArgs.ClipRectangle;

            rect.Inflate(-1, -1);
            if (ProgressBarRenderer.IsSupported && (_controlType == AccountType.Unknown))
            {
                rect.Width = Convert.ToInt32(Math.Round((1.0M * rect.Width * Value) / (Maximum - Minimum)));
                ProgressBarRenderer.DrawHorizontalChunks(eventArgs.Graphics, rect);
            }
            else
            {
                Rectangle r = Rectangle.Empty;
                int       w = ((_controlType == AccountType.VendingMachine ? rect.Height : rect.Width) - 15) / (Maximum - Minimum);
                for (int i = 0; i < Value; i++)
                {
                    r = _controlType == AccountType.VendingMachine ? new Rectangle(0, i * w, rect.Width, 25) : new Rectangle(i * w, 0, 25, rect.Height);
                    eventArgs.Graphics.FillEllipse(new SolidBrush(BackColor), r);
                    eventArgs.Graphics.DrawEllipse(new Pen(ForeColor), r);
                }
                if (!r.IsEmpty)
                {
                    string s = CoinValue.ToString();
                    if (_controlType == AccountType.VendingMachine)
                    {
                        r.Inflate(s.Length > 1 ? -1 : -6, -3);
                    }
                    else
                    {
                        r.Inflate(s.Length > 1 ? 0 : -5, -4);
                    }
                    Font f = Parent == null ? new Font("Microsoft Sans Serif", 12, FontStyle.Bold) : new Font(Parent.Font.FontFamily, 12, Parent.Font.Style | FontStyle.Bold);
                    eventArgs.Graphics.DrawString(s, f, new SolidBrush(ForeColor), r);
                }
            }
        }
Exemplo n.º 15
0
        public void activate(Vector2 position, DropItemType drop_type, int drop_value)
        {
            if (state == DropState.Active)
            {
                return;
            }

            state = DropState.Active;

            this.position = position;

            if (drop_type == DropItemType.CoinDrop)
            {
                dropItem = DropItemType.CoinDrop;

                if (Enum.IsDefined(typeof(CoinValue), drop_value))
                {
                    this.value = (CoinValue)drop_value;
                }
                else
                {
                    throw new System.InvalidOperationException("value is not specified in Coin Value");
                }

                isKnockedBack = false;
                float randDir = (float)(Game1.rand.NextDouble() * 3.14 * 2);
                knockBack(new Vector2((float)Math.Cos(randDir), (float)Math.Sin(randDir)), 0.0f, 0);

                switch (value)
                {
                case CoinValue.Loonie:
                    image_size = 0.75f;
                    break;

                case CoinValue.Twoonie:
                    image_size = 0.75f;
                    break;

                case CoinValue.Laurier:
                    image_size = 0.75f;
                    break;

                case CoinValue.MacDonald:
                    image_size = 0.90f;
                    break;

                case CoinValue.Elizabeth:
                    image_size = 0.90f;
                    break;

                case CoinValue.Mackenzie:
                    image_size = 0.90f;
                    break;

                case CoinValue.Borden:
                    image_size = 1.0f;
                    break;

                default:
                    image_size = 0.75f;
                    value      = CoinValue.Loonie;
                    break;
                }
            }
            else if (drop_type == DropItemType.MedDrop)
            {
                dropItem = DropItemType.MedDrop;

                if (Enum.IsDefined(typeof(MedValue), drop_value))
                {
                    this.med_value = (MedValue)drop_value;
                }
                else
                {
                    throw new System.InvalidOperationException("value is not specified in Coin Value");
                }

                isKnockedBack = false;
                float randDir = (float)(Game1.rand.NextDouble() * 3.14 * 2);
                knockBack(new Vector2((float)Math.Cos(randDir), (float)Math.Sin(randDir)), 0.0f, 0);

                switch (med_value)
                {
                case MedValue.smallPack:
                    image_size = 0.65f;
                    break;

                case MedValue.mediumPack:
                    image_size = 0.80f;
                    break;

                case MedValue.largePack:
                    image_size = 0.90f;
                    break;

                case MedValue.fullPack:
                    image_size = 1.0f;
                    break;

                default:
                    image_size = 0.65f;
                    med_value  = MedValue.smallPack;
                    break;
                }
            }
            else if (drop_type == DropItemType.AmmoDrop)
            {
                dropItem = DropItemType.AmmoDrop;

                if (Enum.IsDefined(typeof(AmmoValue), drop_value))
                {
                    this.ammo_value = (AmmoValue)drop_value;
                }
                else
                {
                    throw new System.InvalidOperationException("value is not specified in Coin Value");
                }

                isKnockedBack = false;
                float randDir = (float)(Game1.rand.NextDouble() * 3.14 * 2);
                knockBack(new Vector2((float)Math.Cos(randDir), (float)Math.Sin(randDir)), 0.0f, 0);
                switch (ammo_value)
                {
                case AmmoValue.smallAmmo:
                    image_size = 0.65f;
                    break;

                case AmmoValue.mediumAmmo:
                    image_size = 0.80f;
                    break;

                case AmmoValue.largeAmmo:
                    image_size = 1.0f;
                    break;

                case AmmoValue.fullAmmo:
                    image_size = 1.0f;
                    break;

                default:
                    image_size = 0.65f;
                    med_value  = MedValue.smallPack;
                    break;
                }
            }
            else
            {
                throw new System.InvalidOperationException("not a valid dropItem");
            }
        }
 /// <summary>Фильтрует монеты пользователя по их достоинству</summary>
 /// <param name="value">CoinValue</param>
 internal static IQueryable<UserCoinLink> FilterByCoinValue(this IQueryable<UserCoinLink> query, CoinValue value)
 {
     return query.Where(x => x.Coin.CoinValue == value);
 }
Exemplo n.º 17
0
 public Coin(CoinValue value, CoinSide side)
 {
   Value = value;
   Side = side;
 }
 public static IQueryable<VendingMachineCoinLink> FilterByCoinValue(
     this IQueryable<VendingMachineCoinLink> query, CoinValue value)
 {
     return query.Where(x => x.Coin.CoinValue == value);
 }
Exemplo n.º 19
0
        public void CoinReturnsValueForValidCoid(double diameter, double width, double weight, CoinValue coinValue)
        {
            var coin = new Coin(diameter, width, weight);

            coin.Value.ShouldBe(coinValue);
        }
Exemplo n.º 20
0
 public CoinDetailViewModel(CoinValue coin = null)
 {
     Coin = coin;
 }