[Add] Dice & Refactor private names
This commit is contained in:
@@ -8,28 +8,28 @@ namespace YachtDice.Shop
|
||||
{
|
||||
[SerializeField] private ShopView shopView;
|
||||
|
||||
private ShopCatalog catalog;
|
||||
private CurrencyBank currencyBank;
|
||||
private ShopModel model;
|
||||
private ShopCatalog _catalog;
|
||||
private CurrencyBank _currencyBank;
|
||||
private ShopModel _model;
|
||||
|
||||
public ShopCatalog Catalog => catalog;
|
||||
public ShopCatalog Catalog => _catalog;
|
||||
|
||||
[Inject]
|
||||
public void Construct(ShopCatalog catalog, CurrencyBank currencyBank, ShopModel model)
|
||||
{
|
||||
this.catalog = catalog;
|
||||
this.currencyBank = currencyBank;
|
||||
this.model = model;
|
||||
this._catalog = catalog;
|
||||
this._currencyBank = currencyBank;
|
||||
this._model = model;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
shopView.OnBuyClicked += HandleBuyClicked;
|
||||
currencyBank.OnBalanceChanged += HandleCurrencyChanged;
|
||||
model.OnItemPurchased += HandleItemPurchased;
|
||||
_currencyBank.OnBalanceChanged += HandleCurrencyChanged;
|
||||
_model.OnItemPurchased += HandleItemPurchased;
|
||||
|
||||
shopView.Populate(catalog.All, model);
|
||||
shopView.UpdateCurrencyDisplay(currencyBank.Balance);
|
||||
shopView.Populate(_catalog.All, _model);
|
||||
shopView.UpdateCurrencyDisplay(_currencyBank.Balance);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
@@ -37,11 +37,11 @@ namespace YachtDice.Shop
|
||||
if (shopView != null)
|
||||
shopView.OnBuyClicked -= HandleBuyClicked;
|
||||
|
||||
if (currencyBank != null)
|
||||
currencyBank.OnBalanceChanged -= HandleCurrencyChanged;
|
||||
if (_currencyBank != null)
|
||||
_currencyBank.OnBalanceChanged -= HandleCurrencyChanged;
|
||||
|
||||
if (model != null)
|
||||
model.OnItemPurchased -= HandleItemPurchased;
|
||||
if (_model != null)
|
||||
_model.OnItemPurchased -= HandleItemPurchased;
|
||||
}
|
||||
|
||||
public void ToggleVisibility()
|
||||
@@ -56,18 +56,18 @@ namespace YachtDice.Shop
|
||||
|
||||
private void HandleBuyClicked(IShopItem item)
|
||||
{
|
||||
model.TryPurchase(item);
|
||||
_model.TryPurchase(item);
|
||||
}
|
||||
|
||||
private void HandleCurrencyChanged(int newBalance)
|
||||
{
|
||||
shopView.UpdateCurrencyDisplay(newBalance);
|
||||
shopView.RefreshStates(catalog.All, model);
|
||||
shopView.RefreshStates(_catalog.All, _model);
|
||||
}
|
||||
|
||||
private void HandleItemPurchased(IShopItem item)
|
||||
{
|
||||
shopView.RefreshStates(catalog.All, model);
|
||||
shopView.RefreshStates(_catalog.All, _model);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user