Ejemplo n.º 1
0
    public static Tower Create(string type, TowerSpawnPoint spawn)
    {
        GameObject tower;

        if (GameSession.Instance.isNetworkGame)
        {
            tower = (GameObject)Network.Instantiate(PrefabManager.PrefabTowers[type], spawn.transform.parent.position, Quaternion.identity, 0);
        }
        else
        {
            tower = (GameObject)Instantiate(PrefabManager.PrefabTowers[type], spawn.transform.parent.position, Quaternion.identity);
        }
        Tower towerData = tower.GetComponentInChildren <Tower>();

        towerData.Init(spawn.firingRadius);
        if (spawn.ring != null)
        {
            spawn.ring.obj    = towerData;
            spawn.ring.toInit = true;
        }
        if (GameSession.Instance.isNetworkGame)
        {
            Network.Destroy(spawn.transform.parent.gameObject);
        }
        else
        {
            Destroy(spawn.transform.parent.gameObject);
        }
        GameSession.Instance.credits -= Constants.TowerBuildCosts[type];
        UIScreenTextController.MakeGoldText(0, "-$" + Constants.TowerBuildCosts[type], spawn.transform.position);
        return(towerData);
    }
Ejemplo n.º 2
0
    public void Sell()
    {
        GameObject obj;

        if (GameSession.Instance.isNetworkGame)
        {
            obj = (GameObject)Network.Instantiate(PrefabManager.PrefabTowerSpawnPoint, transform.parent.position, Quaternion.identity, 0);
        }
        else
        {
            obj = (GameObject)Instantiate(PrefabManager.PrefabTowerSpawnPoint, transform.parent.position, Quaternion.identity);
        }
        TowerSpawnPoint spawn = obj.GetComponentInChildren <TowerSpawnPoint>();

        spawn.toInit                  = false;
        spawn.firingRadius            = firingRadius;
        ring.obj                      = spawn;
        ring.toInit                   = true;
        GameSession.Instance.credits += SellingCost;
        UIScreenTextController.MakeGoldText(0, "+$" + SellingCost, transform.position);
        if (GameSession.Instance.isNetworkGame)
        {
            Network.Destroy(transform.parent.gameObject);
        }
        else
        {
            Destroy(transform.parent.gameObject);
        }
    }
Ejemplo n.º 3
0
    protected void showGoldGain(int val)
    {
        if (val == 0)
        {
            return;
        }
        GameSession session = GameSession.Instance;

        session.credits += val;
        UIScreenTextController.MakeGoldText(iconHeightOffset, "+$" + val, transform.position);
    }
Ejemplo n.º 4
0
    void showDamageIcon(int val, bool poison)
    {
        string prefix = "";

        if (poison)
        {
            prefix = "#";
        }
        if (val > 0)
        {
            UIScreenTextController.MakeHealText(iconHeightOffset, val.ToString(), transform.position);
        }
        else if (val < 0)
        {
            UIScreenTextController.MakeDamageText(iconHeightOffset, prefix + Mathf.Abs(val).ToString(), transform.position);
        }
    }
Ejemplo n.º 5
0
    public bool Upgrade()
    {
        GameSession session = GameSession.Instance;

        if (Level > 2)
        {
            return(false);
        }
        int cost = UpgradeCost;

        if (cost <= session.credits)
        {
            Level++;
            swapTowerSkin();
            updateFiringRadius();
            session.credits -= cost;
            UIScreenTextController.MakeGoldText(0, "-$" + cost, transform.position);
            return(true);
        }
        return(false);
    }
Ejemplo n.º 6
0
    public static void MakeGoldText(float upOff, string inText, Vector3 pos)
    {
        UIScreenTextController obj = Create();

        obj.Init(upOff, inText, pos, yellow);
    }
Ejemplo n.º 7
0
    public static void MakeDamageText(float upOff, string inText, Vector3 pos)
    {
        UIScreenTextController obj = Create();

        obj.Init(upOff, inText, pos, red);
    }