예제 #1
0
        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");
                }
            }
        }
예제 #2
0
        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!");
            }
        }
예제 #3
0
 public void ChooseTurret(TurretAsset asset)
 {
     if (asset.Price > m_Money)
     {
         return;
     }
     m_ChosenTurret = asset;
 }
예제 #4
0
 public void BuyTurret(TurretAsset turretAsset)
 {
     if (turretAsset.Price > m_Money)
     {
         Debug.LogError("Not enough money!");
         return;
     }
     m_Money -= turretAsset.Price;
     MoneyChanged?.Invoke(m_Money);
 }
예제 #5
0
        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;
        }
예제 #6
0
        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();
        }
예제 #7
0
        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);
            }
        }
예제 #8
0
        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();
        }
예제 #9
0
        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);
        }
예제 #10
0
 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!");
         }
     }
 }
예제 #11
0
        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!");
                }
            }
        }