public void Tick() { if (m_Grid.HasSelectedNode() && Input.GetMouseButtonDown(0)) { Node selectedNode = m_Grid.GetSelectedNode(); bool canOccupy = false; m_Grid.TryOccupyNode(selectedNode, ref canOccupy); if (!canOccupy) { return; } TurretAsset asset = m_Market.ChosenTurret; if (asset != null) { m_Market.BuyTurret(asset); SpawnTurret(asset, selectedNode); m_Grid.UpdatePathFinding(); } else { Debug.Log("Not enough money"); } } }
public void Tick() { if (!m_Grid.HasSelectedNode() || !Input.GetMouseButtonDown(0)) { return; } Node selectedNode = m_Grid.GetSelectedNode(); Vector2Int selectedNodeCoordinate = m_Grid.GetSelectedNodeCoordinate(); if (selectedNode.IsOccupied || !m_Grid.CanOccupyNode(selectedNodeCoordinate)) { return; } TurretAsset asset = m_Market.ChosenTurret; if (asset != null) { m_Market.BuyTurret(asset); SpawnTurret(asset, selectedNodeCoordinate, selectedNode); } else { Debug.Log("Not enough money!"); } }
public void ChooseTurret(TurretAsset asset) { if (asset.Price > m_Money) { return; } m_ChosenTurret = asset; }
public void BuyTurret(TurretAsset turretAsset) { if (turretAsset.Price > m_Money) { Debug.LogError("Not enough money!"); return; } m_Money -= turretAsset.Price; MoneyChanged?.Invoke(m_Money); }
public void SetTurret(TurretAsset asset) { m_Asset = asset; m_Image.sprite = asset.Sprite; m_DescriptionText.text = asset.Description; m_PriceText.text = $"Price: {asset.Price}"; m_ChooseButton.onClick.AddListener(OnClick); Game.Player.TurretMarket.MoneyChanged += CheckAvailability; }
private void SpawnTurret(TurretAsset asset, Node node) { TurretView view = Object.Instantiate(asset.ViewPrefab); TurretData data = new TurretData(asset, node); data.AttachView(view); Game.Player.TurretSpawned(data); node.IsOccupied = true; // TryOccupy() m_Grid.UpdatePathfinding(); }
private void TrySpawnTurret(TurretAsset asset, Node node) { bool wasOccupied = Game.Player.Grid.TryOccupyNode(node); if (wasOccupied) { m_Market.BuyTurret(asset); TurretView view = Object.Instantiate(asset.ViewPrefab); TurretData data = new TurretData(asset, node); data.AttachView(view); Game.Player.TurretSpawned(data); } }
private void SpawnTurret(TurretAsset asset, Vector2Int coordinate, Node selectedNode) { TurretView view = Object.Instantiate(asset.ViewPrefab); TurretData data = new TurretData(asset, selectedNode); data.AttachView(view); Game.Player.TurretSpawned(data); if (!m_Grid.TryOccupyNode(coordinate, true)) { Debug.Log("Something has gone wrong"); } m_Grid.UpdatePathFinding(); }
private void SpawnTurret(TurretAsset asset, Node node) { TurretView view = Object.Instantiate(asset.ViewPrefab); TurretData data = new TurretData(asset, node); data.AttachView(view); if (m_Grid.ChangeNodeOccupationStatus(node, true)) { m_Grid.UpdatePathfinding(); } Game.Player.TurretSpawned(data); }
public void Tick() { if (m_Grid.HasSelectedNode() && Input.GetMouseButtonDown(0)) { TurretAsset asset = m_Market.ChosenTurret; if (asset != null) { Node selectedNode = m_Grid.GetSelectedNode(); TrySpawnTurret(asset, selectedNode); } else { Debug.Log("Not enough money!"); } } }
public void Tick() { if (m_Grid.HasSelectedNode() && Input.GetMouseButtonDown(0)) { Node selectedNode = m_Grid.GetSelectedNode(); if (selectedNode.IsOccupied /* || !m_Grid.CanOccupy(selectedNode)*/) { return; } TurretAsset asset = m_Market.ChosenTurret; if (asset != null) { m_Market.BuyTurret(asset); SpawnTurret(asset, selectedNode); } else { Debug.Log("Not enough money!"); } } }