Exemplo n.º 1
0
    public void BuyConstruction()
    {
        WorldController wc           = worldController.GetComponent <WorldController>();
        TP_Status       tpStatus     = wc.PlayerObj.GetComponent <TP_Status>();
        Construction    construction = wc.PlayerObj.GetComponent <BuilderManager>().dropPrefabs[constructionIndex].GetComponent <Construction>();

        if (wc.money >= construction.upgradeCost)
        {
            wc.SubtractMoney(construction.upgradeCost);
            BuilderManager bm = worldController.GetComponent <WorldController>().PlayerObj.GetComponent <BuilderManager>();
            bm.pickupItem(constructionIndex);

            tpStatus.interactionState = InteractionState.Construct;
            SetInteractText(true);
            SetShopText(false);

            if (buySound != null)
            {
                audioSource.PlayOneShot(buySound, 1.0f);
            }
        }
        else
        {
            if (denySound != null)
            {
                audioSource.PlayOneShot(denySound, 0.4f);
            }
        }
    }
Exemplo n.º 2
0
    public void BuySpell()
    {
        WorldController wc       = worldController.GetComponent <WorldController>();
        TP_Status       tpStatus = wc.PlayerObj.GetComponent <TP_Status>();
        //TP_Status tpStatus = worldController.GetComponent<WorldController>().PlayerObj.GetComponent<TP_Status>();
        //Attack spell = tpStatus.flamethrowerObj.GetComponent<Attack>();

        Attack spell = spellObj.GetComponent <Attack>();

        if (wc.money >= spell.upgradeCost)
        {
            int newLevel = spell.level + 1;

            wc.SubtractMoney(spell.upgradeCost);
            spell.Upgrade(newLevel);

            // Update TextMesh
            spellText        = "(X) " + spell.myName + " Lv" + (newLevel + 1) + " $" + spell.upgradeCost;
            shopText         = spellText + constructionText;
            shopTextObj.text = shopText;

            tpStatus.interactionState = InteractionState.Default;
            SetInteractText(true);
            SetShopText(false);

            if (buySound != null)
            {
                audioSource.PlayOneShot(buySound, 1.0f);
            }
        }
        else
        {
            if (denySound != null)
            {
                audioSource.PlayOneShot(denySound, 0.4f);
            }
        }
    }
Exemplo n.º 3
0
 void Awake()
 {
     _instance        = this;
     interactionState = InteractionState.Default;
 }
Exemplo n.º 4
0
 void Awake()
 {
     Instance = this;
 }