コード例 #1
0
ファイル: Tower.cs プロジェクト: infernova/Final-Frontier
    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);
    }
コード例 #2
0
ファイル: Tower.cs プロジェクト: infernova/Final-Frontier
    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);
        }
    }
コード例 #3
0
    protected void showGoldGain(int val)
    {
        if (val == 0)
        {
            return;
        }
        GameSession session = GameSession.Instance;

        session.credits += val;
        UIScreenTextController.MakeGoldText(iconHeightOffset, "+$" + val, transform.position);
    }
コード例 #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);
        }
    }
コード例 #5
0
ファイル: Tower.cs プロジェクト: infernova/Final-Frontier
    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);
    }
コード例 #6
0
    public static void MakeGoldText(float upOff, string inText, Vector3 pos)
    {
        UIScreenTextController obj = Create();

        obj.Init(upOff, inText, pos, yellow);
    }
コード例 #7
0
    public static void MakeDamageText(float upOff, string inText, Vector3 pos)
    {
        UIScreenTextController obj = Create();

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