protected virtual void AddRewardCurrency(Table table, CurrencyCount cc) { var prefab = GetRewardCurrencyPrefab(cc.Currency); if (!prefab) { return; } var aiObj = table.AddItem(prefab); if (aiObj.ItemName) { aiObj.ItemName.text = cc.Currency; } aiObj.Count.text = string.Format("{0}", cc.Count); /* * TODO: dynamic lookup of currency * if (collectible.ImageUrl != null) * { * ThreadHelper.Instance.StartCoroutine(ImageLoader.LoadImage(collectible.ImageUrl, aiObj.Image)); * }*/ }
protected virtual void AddGiveCurrency(Table table, CurrencyCount cc) { var prefab = GetGiveCurrencyPrefab(cc.Currency); if (!prefab) { return; } var aiObj = table.AddItem(prefab); var invCount = Wallet.Instance.GetCount(cc.Currency); if (aiObj.ItemName) { aiObj.ItemName.text = cc.Currency; } aiObj.Count.text = StringFormatter.GetGiveCountString(invCount, cc.Count, NeedsMoreTextColor); /* * TODO: dynamic lookup of currency * if (collectible.ImageUrl != null) * { * ThreadHelper.Instance.StartCoroutine(ImageLoader.LoadImage(collectible.ImageUrl, aiObj.Image)); * }*/ if (aiObj.SatisfiedObject) { aiObj.SatisfiedObject.SetActive(invCount >= cc.Count); } }
/// <summary> /// gets a currencyCOunt of the provided ID from the database /// </summary> /// <param name="currencyCountId">ID of the count to fetch</param> /// <returns>instance of the CurrencyCount class matching the database</returns> public static CurrencyCount GetCurrencyCount(long currencyCountId) { Debug.WriteLine("I'm fetching the currency count with the ID of " + currencyCountId + " from CurrencyCount table"); CurrencyCount currencyCount = null; SqlConnection sql = DatabaseService.GetSqlConnection(); //fetch the row string fetch = "SELECT * FROM dbo.CurrencyCountTable WHERE Id =@Id;"; SqlCommand command = new SqlCommand(fetch, sql); command.Parameters.AddWithValue("@Id", currencyCountId); using (SqlDataReader reader = command.ExecuteReader()) { if (reader.Read()) { currencyCount = new CurrencyCount((long)reader["Id"], (long)reader["WalletId"], CurrencyService.GetCurrency((long)reader["CurrencyId"]), (int)reader["Quantity"]); } } sql.Close(); return(currencyCount); }
public void Add(CurrencyCount currencyCount, bool commit = true) { if (currencyCount == null) { return; } Add(currencyCount.Currency, currencyCount.Count, commit); }
/// <summary> /// Saves the provided instance of CurrencyCount class to database /// </summary> /// <param name="currencyCount">Instance of CurrencyCount class to save</param> public static void Save(CurrencyCount currencyCount) { Debug.WriteLine("I'm writing to the currency count table w/ sql"); SqlConnection sql = DatabaseService.GetSqlConnection(); try { //update string update = "UPDATE dbo.CurrencyCountTable WHERE Id=@id SET WalletId=@walletId, CurrencyId=@curencyId, Quantity=@quantity;"; SqlCommand command = new SqlCommand(update, sql); command.Parameters.AddWithValue("@id", currencyCount.Id); command.Parameters.AddWithValue("@walletId", currencyCount.WalletId); command.Parameters.AddWithValue("@currencyId", currencyCount.Currency.Id); command.Parameters.AddWithValue("@quantity", currencyCount.Quantity); command.ExecuteNonQuery(); } catch (Exception ex) { if (ex.HResult == ErrorCodes.RowDoesntExist) { //add instead string add = "INSERT dbo.CurrencyCountTable WHERE Id=@id SET WalletId=@walletId, CurrencyId=@curencyId, Quantity=@quantity;"; SqlCommand command = new SqlCommand(add, sql); command.Parameters.AddWithValue("@id", currencyCount.Id); command.Parameters.AddWithValue("@walletId", currencyCount.WalletId); command.Parameters.AddWithValue("@currencyId", currencyCount.Currency.Id); command.Parameters.AddWithValue("@quantity", currencyCount.Quantity); command.ExecuteNonQuery(); } else { throw new Exception(ex.Message); } } finally { sql.Close(); } }
public ActionResult Home(CurrencyCount currencyCount) { return(View()); }