예제 #1
0
    //Helper function for building turret. First checks to see that player has enough money to build or not. If it does, subtracts that from the player's currency, and then
    //creates the object on the position returned by the GetPosition() function. Also instantiates the build turret effect.
    void BuildTurret(TurretBlueprintScript blueprint)
    {
        if (PlayerInfoScript.currency < blueprint.cost)
        {
            Debug.Log("Not enough currency!");
            return;
        }

        //Laser turret needs a different offset than the other turrets, due to it being slightly larger.
        if (blueprint.turretPrefab.name == "LaserTurret")
        {
            offset = altOffset;
        }
        else
        {
            offset = defaultOffset;
        }

        PlayerInfoScript.currency -= blueprint.cost;

        GameObject turret = (GameObject)Instantiate(blueprint.turretPrefab, GetPosition(), Quaternion.identity);

        currentTurret          = turret;
        currentTurretBlueprint = blueprint;
        GameObject buildEffect = (GameObject)Instantiate(buildManager.turretBuildEffect, GetPosition(), Quaternion.identity);

        Destroy(buildEffect, 4f);
        Debug.Log("Turret Built! Remaining Currency: ");
    }
예제 #2
0
    //Adds a set amount of currency to the player's currency and destroys the turret at the selected node. Also displays the sell particle effect.
    public void SellTurret()
    {
        PlayerInfoScript.currency += currentTurretBlueprint.GetSellAmount();

        GameObject sellEffect = (GameObject)Instantiate(buildManager.turretSellEffect, GetPosition(), Quaternion.identity);

        Destroy(sellEffect, 4f);
        Destroy(currentTurret);
        currentTurretBlueprint = null;
    }
예제 #3
0
 //Selects the node clicked. If already selected, deselects the node.
 public void SelectNode(NodeScript node)
 {
     if (selectedNode == node)
     {
         DeselectNode();
         return;
     }
     selectedNode       = node;
     selectedTurretType = null;
     nodeUI.SetTarget(node);
 }
예제 #4
0
    // ************ HELPER FUNCTIONS ************

    //Changes the turret that will be built when the player clicks on a node. Activated by clicking shop icons, which deselects any node if it is already selected
    public void SelectTurretToBuild(TurretBlueprintScript turretToBuild)
    {
        selectedTurretType = turretToBuild;
        DeselectNode();
    }