Exemple #1
0
    void BuildTurret(TurretBlueprint bluePrint)
    {
        //if the player has the money to buy the turret
        if (PlayerStarts.money < bluePrint.GetCostAmount())
        {
            Debug.Log("Not enough money");
            return;
        }

        PlayerStarts.money -= bluePrint.GetCostAmount();
        //should we use the pool here?
        GameObject tmp_turret = (GameObject)Instantiate(bluePrint.GetPrefab(), GetBuildPosition(), Quaternion.identity, objectHolder.transform);

        turretBlueprint = bluePrint;

        turret = tmp_turret;
        Debug.Log("Turret build!! Money left: " + PlayerStarts.money);

        GameObject gobj = ObjectPool_Zaim.current.GetPoolObject(buildManager.buildEffect.name);

        if (gobj == null)
        {
            Debug.LogWarning(buildManager.buildEffect.name + " is NULL");
            return;
        }

        gobj.transform.position = transform.position;
        gobj.transform.rotation = transform.rotation;
        gobj.SetActive(true);

        buildManager.DeselectNode();
    }