private void GameEnd(bool win) { StopCoroutine("Timer"); GameEndData gameEndData = new GameEndData(); gameEndData.win = win; gameEndData.finalScore = _receivedEnergy; gameEndData.needScore = _needEnergyToCompleteLevel; gameEndData.playerDie = false; if (win) { SaveSystem.SaveLevelStatucByID(GameEconomy.curentLevel.levelSaveLoadID, true); } else { //SaveSystem.SaveLevelStatucByID(GameEconomy.curentLevel.levelSaveLoadID, false); } GameEconomy.AddPlayerMoney(_receivedEnergy); if (GameEconomy.curentItem && GameEconomy.curentItem.itemName != "Empty") { GameEconomy.curentItem.bought = false; } SetPauseEnabled(); GameEconomy.SaveEconomy(); GameEnded(gameEndData); }
public virtual void AddListenerToButton(Action <IGeneratedBy> listener, UnityAction closePanel, UnityAction openConfirmPanel, Action <string> showCommercial, GameEconomy economy, ScoreFormConverter scorreForm) { _scorreForm = scorreForm; _chooseProduct += listener; if (_product.IsOpeningObject && !_isPossibleToUse) { _actionsForOpenedPanels = new UnityAction[2]; _actionsForOpenedPanels[0] = closePanel; _actionsForOpenedPanels[1] = openConfirmPanel; _showCommercial += showCommercial; _productButton.onClick.AddListener(OnShowCommercial); _nameViewer.text = _product.OpeningObjectText.ToUpper(); } else { _productButton.onClick.AddListener(closePanel); _productButton.onClick.AddListener(openConfirmPanel); } _economy = economy; _economy.PurchaseCompleted += ChangePrice; ChangePrice(); }
public override void AddListenerToButton(Action <IGeneratedBy> listener, UnityAction closePanel, UnityAction openConfirmPanel, Action <string> showCommercial, GameEconomy economy, ScoreFormConverter scorreForm) { _economy = economy; _economy.PurchaseCompleted += ChangePrice; _scorreForm = scorreForm; ChangePrice(); }
public void DropEcomomy() { GameEconomy.DropEconomy(); playerMoneyText.text = GameEconomy.GetPlayerMoney().ToString(); itemConfigurations = Resources.LoadAll("Items", typeof(ItemConfiguration)).Cast <ItemConfiguration>().ToList(); for (int i = 0; i < itemConfigurations.Count; i++) { itemConfigurations[i].bought = false; } OnEnable(); }
public void TryBuyItem() { if (GameEconomy.GetPlayerMoney() >= _itemConfiguration.itemCost) { GameEconomy.SpendPlayerMoney(_itemConfiguration.itemCost); _itemConfiguration.bought = true; soldButton.SetActive(false); soldLabel.SetActive(true); moneyInfo.SetActive(false); playerMoney.text = GameEconomy.GetPlayerMoney().ToString(); GameEconomy.curentItem = _itemConfiguration; } else { } }
private void Start() { _confirmPanel.SetConfirmListener(_actionObjectSpawner.ConfirmSetObject, _spawnObjectSpawner.ConfirmSetObject, _confirmPanel.ToggleActiveButtons, _deletedPanel.ClosePanel); _confirmPanel.SetCancelListener(_actionObjectSpawner.EndUse, _spawnObjectSpawner.EndUse, _confirmPanel.ToggleActiveButtons, _deletedPanel.ClosePanel); _economy = _actionObjectSpawner.GetComponent <GameEconomy>(); _productPanels = GetComponentsInChildren <ProductPanel>(); _actionObjectSpawner.DeletingObject += _confirmPanel.ToggleActiveButtons; _actionObjectSpawner.DeletingObject += _deletedPanel.OpenPanel; _actionObjectSpawner.OutOfAnchors += OutOfAnchors; _actionObjectSpawner.AnchorsAppeared += ActionAnchorsAppeared; _spawnObjectSpawner.OutOfAnchors += OutOfAnchors; _spawnObjectSpawner.UsedMaxUpgrade += MaxSpawnUpgrade; foreach (var product in _productPanels) { product.AddListenerToButton(SendObjectToSpawner, ToggleActive, _confirmPanel.ToggleActiveButtons, ShowCommercial, _economy, _scorreForm); } _startButton.onClick.Invoke(); ToggleActive(); }
private void OnEnable() { itemNameText.text = _itemConfiguration.itemName; itemImage.sprite = _itemConfiguration.itemImage; itemDescriptionText.text = _itemConfiguration.itemDescription; ItemCost.text = _itemConfiguration.itemCost.ToString(); playerMoney.text = GameEconomy.GetPlayerMoney().ToString(); if (_itemConfiguration.bought) { moneyInfo.SetActive(false); soldButton.SetActive(false); soldLabel.SetActive(true); } else { moneyInfo.SetActive(true); soldButton.SetActive(true); soldLabel.SetActive(false); } }
private void Awake() { _anchors = _objectTilemap.GetComponentsInChildren <IActionObjectAnchor>(); #region check dubleAnchor List <Vector2> positions = new List <Vector2>(); for (int i = 0; i < _anchors.Length; i++) { if (!positions.Contains(_anchors[i].GetPosition())) { positions.Add(_anchors[i].GetPosition()); } else { Debug.Log(_anchors[i].GetPosition()); } } #endregion _gameEconomy = GetComponent <GameEconomy>(); }
public void OnEnable() { playerMoneyText.text = GameEconomy.GetPlayerMoney().ToString(); for (int i = 0; i < contentTransform.childCount; i++) { Destroy(contentTransform.GetChild(i).gameObject); } itemConfigurations = Resources.LoadAll("Items", typeof(ItemConfiguration)).Cast <ItemConfiguration>().ToList(); buttonLevelPairs.Clear(); GameObject newPanel = Instantiate(buttonsPanelPrefab, contentTransform); for (int i = 0; i < itemConfigurations.Count; i++) { if (i % 3 == 0 && i != 0) { newPanel = Instantiate(buttonsPanelPrefab, contentTransform); } GameObject newButton = Instantiate(buttonPrefab, newPanel.transform); Button newUIButton = newButton.GetComponent <Button>(); if (itemConfigurations[i].bought) { newUIButton.GetComponentsInChildren <Image>().ToList().Last().sprite = itemConfigurations[i].itemBoughtImage; newUIButton.transform.Find("Bought").gameObject.SetActive(true); } else { newUIButton.GetComponentsInChildren <Image>().ToList().Last().sprite = itemConfigurations[i].itemImage; } newUIButton.onClick.AddListener(() => ButtonClicked(newUIButton)); buttonLevelPairs.Add(newUIButton, itemConfigurations[i]); } }
public void GiveMoney() { GameEconomy.AddPlayerMoney(9999); playerMoneyText.text = GameEconomy.GetPlayerMoney().ToString(); }