/// <summary>
    /// Checks if the given wrapped data is a entry in the database
    /// </summary>
    /// <param name="dataWrapper">The wrapped data</param>
    /// <returns>Returns true if the wrapped data corosponds to a entry in the DB, false othwerwise</returns>
    public bool Check(TowerDBEntry dataWrapper)
    {
        if (Check(dataWrapper.name))
        {
            return(towerDB[dataWrapper.name] == dataWrapper.towerGameobject);
        }

        return(false);
    }
 /// <summary>
 /// Creates a new entry in the DB based on given wrapped data
 /// </summary>
 /// <param name="insertionData">The wrapped data to insert</param>
 /// <returns>Returns true if creation and insertion was successful, false otherwise</returns>
 public bool Add(TowerDBEntry insertionData)
 {
     if (Check(name))
     {
         Debug.LogError("TowerDatabase: Detected a duplicate key when attempting to insert!");
         return(false);
     }
     towerDB.Add(insertionData.towerName, insertionData);
     return(true);
 }
    public override IEnumerator Excecute(params string[] args)
    {
        if (args.Length >= 1)
        {
            if (TowerDatabase.instance.Check(args[0]) == false)
            {
                Terminal.PrintToTerminal("Unknown Tower!");
                yield break;
            }

            TowerDBEntry tower = TowerDatabase.instance.Get(args[0]);
            Debug.Log(tower.ToString());
            Terminal.PrintToTerminal(tower.ToString());
        }
        else
        {
            Terminal.PrintToTerminal("Incorrect usage: " + GetUsage());
            yield return(true);
        }

        yield return(true);
    }
    public override IEnumerator Excecute(params string[] args)
    {
        if (NodeManager.instance != null && NodeManager.instance.IsReady())
        {
            if (args.Length >= 3)
            {
                int posX;
                int posY;

                if (int.TryParse(args[1], out posX) == false)
                {
                    Terminal.PrintToTerminal("posX must be a number!");
                    yield break;
                }

                if (int.TryParse(args[2], out posY) == false)
                {
                    Terminal.PrintToTerminal("posY must be a number!");
                    yield break;
                }

                Node placementNode = NodeManager.instance.GetNode(posX, posY);
                if (placementNode == null)
                {
                    Terminal.PrintToTerminal("either posX or posY is not a valid location!");
                    yield break;
                }

                if (placementNode.nodeType == Node.NodeType.PLAYER_TOWER)
                {
                    if (placementNode.HasChild())
                    {
                        Terminal.PrintToTerminal(posX + " " + posY + " already has a tower!");
                        yield break;
                    }
                    if (TowerDatabase.instance.Check(args[0]) == false)
                    {
                        Terminal.PrintToTerminal(args[0] + " is not a valid name!");
                        yield break;
                    }

                    TowerDBEntry tower = TowerDatabase.instance.Get(args[0]);

                    if (tower.stats.cost > ResourceManager.instance.GetPlayerResources())
                    {
                        Terminal.PrintToTerminal("Not enough resources to place " + args[0] + "!");
                        yield break;
                    }

                    //subtract resources
                    ResourceManager.instance.SetResources(ResourceManager.instance.GetPlayerResources() - tower.stats.cost);
                    GameObject obj = Instantiate(tower.towerGameobject, placementNode.gameObject.transform.position, Quaternion.identity, placementNode.transform);
                    //apply stats to tower
                    obj.GetComponent <Tower>().stats = tower.stats;
                }
                else
                {
                    Terminal.PrintToTerminal(posX + " " + posY + " is not a valid tower location!");
                    yield break;
                }

                Terminal.PrintToTerminal(args[0] + " tower placed successfully at " + posX + " " + posY + "!");
            }
            else
            {
                Terminal.PrintToTerminal("Incorrect usage: " + GetUsage());
                yield break;
            }
        }
        else
        {
            Terminal.PrintToTerminal("NodeManager is either not setup or not ready for input!");
            yield break;
        }
    }