// TODO: slight bug with mobile; after building tower, can't select a tower to see upgrades / deets UI
    // Issue seems to stem from TD_SBF_Node.cs
    public void SelectNode(TD_SBF_Node node)
    {
        // Controller Support
        if (buildDescBarSel.bIsNowBuildDescMode)
        {
            return;
        }

        if (selectedNode == node)
        {
            DeselectNode();
            return;
        }

        if (buildDescriptionBar.gameObject.activeSelf)
        {
            cMan.DisableBuildDescriptionBar();
        }

        selectedNode  = node;
        turretToBuild = null;

        if (Screen.width >= Screen.height)
        {
            nodeUI_H.SetTarget(node);
        }
        else
        {
            nodeUI_V.SetTarget(node);
        }
    }
Exemple #2
0
    public void SellTurret()
    {
        if (turret)
        {
            // TODO: if upgraded, give 1/2 upgraded price
            // TODO: after X seconds, set sell price to half
            TD_SBF_PlayerStatistics.ThoughtsPrayers += turretBlueprint.GetSellAmount(towerLevel);

            // Spawn a cool effect
            GameObject effect = Instantiate(
                TD_SBF_BuildManager.td_sbf_instance.sellEffect,
                GetBuildPosition(),
                Quaternion.identity);
            Destroy(effect, 1f);

            // Destroy turret
            Destroy(turret);
            turretBlueprint = null;

            // TODO: Follow up eventually; VS say "meh" but it's needed and works
            if (TD_SBF_WaveSpawner.enemiesAlive > 0)
            {
                AstarPath.active.Scan();
            }

            // Remove from grid array
            TD_SBF_TowerPlacer.nodeArray.Remove(transform.position);

            // Destroy self
            Destroy(gameObject);
        }
    }
    public void SelectTurretToBuild(TD_SBF_TurretBlueprint turret)
    {
        turretToBuild = turret;
        selectedNode  = null;

        if (Screen.width >= Screen.height)
        {
            nodeUI_H.Hide();
        }
        else
        {
            nodeUI_V.Hide();
        }
    }
Exemple #4
0
    public void BuildTurret(TD_SBF_TurretBlueprint blueprint)
    {
        if (TD_SBF_PlayerStatistics.ThoughtsPrayers < blueprint.cost)
        {
            Debug.Log("Need more vespian gas.");
            return;
        }

        TD_SBF_PlayerStatistics.ThoughtsPrayers -= blueprint.cost;

        GameObject _turret = Instantiate(blueprint.lvl1_prefab, GetBuildPosition(), Quaternion.identity);

        turret = _turret;

        turretBlueprint = blueprint;

        // Set sorting order
        _turret.transform.GetChild(0).transform.GetChild(0).GetComponent <SpriteRenderer>()
        .sortingOrder = 100 + Mathf.Abs(Mathf.RoundToInt(_turret.transform.position.y));
        // Set hitbox z position
        Vector3 hitboxPos = _turret.transform.GetChild(3).GetComponent <Transform>().position;

        hitboxPos = new Vector3(hitboxPos.x, hitboxPos.y, hitboxPos.z + (hitboxPos.y / 10000));
        _turret.transform.GetChild(3).GetComponent <Transform>().position = hitboxPos;

        if (heroAni)
        {
            heroAni.GetComponent <Animator>().Play("Hero_Build");
            Invoke("RestoreHeroMovementAnimation", 1f);
        }

        GameObject effect = Instantiate(TD_SBF_BuildManager.td_sbf_instance.buildEffect, GetBuildPosition(), Quaternion.identity);

        Destroy(effect, 0.75f);

        // TODO: Follow up eventually; VS say "meh" but it's needed and works
        if (TD_SBF_WaveSpawner.enemiesAlive > 0)
        {
            AstarPath.active.Scan();
        }
    }