Esempio n. 1
0
 public void UpgradeCurrentEngine(Defs.EngineUpgrades engineUpgrade)
 {
     currentEngine = engineUpgrade;
     foreach (ActiveNode currentNode in ObjectManager.Instance.globalNodeList)
     {
         GameObject   currentNodeConnectionsGO   = currentNode.connections;
         Connection[] currentNodeConnectionsList = currentNodeConnectionsGO.GetComponentsInChildren <Connection>();
         foreach (Connection currentNodeConnectionScript in currentNodeConnectionsList)
         {
             IEnumerator enumerable = currentNodeConnectionScript.EngineUpgrade(engineUpgrade);
             StartCoroutine(enumerable);
         }
     }
 }
Esempio n. 2
0
    public void UpdateUI(Defs.EngineUpgrades engineUpgrade = Defs.EngineUpgrades.ENGINEUPRADE_DEFAULT)
    {
        float modifer = Defs.Instance.engineUpgradesSpeeds[engineUpgrade];

        currentTravelTime = (int)((float)initialTravelTime * modifer);
        switch (connectionType)
        {
        case Defs.ConnectionTypes.CONNECTIONTYPE_BLUE:
            distanceText.text = currentTravelTime.ToString() + "\n$" + costToJump.ToString();
            break;

        case Defs.ConnectionTypes.CONNECTIONTYPE_RED:
            string piracyChance = (Defs.Instance.engineUpgradesPiracyChance[engineUpgrade] * 100).ToString();
            distanceText.text = currentTravelTime.ToString() + "\n!" + piracyChance + "%!";
            break;

        default:
            distanceText.text = currentTravelTime.ToString();
            break;
        }
    }
Esempio n. 3
0
    // Start is called before the first frame update
    void Start()
    {
        if (myNodeParametersScript == null || myGoodParentObject == null || myGoodUIReferencesList == null || myActiveNodeScript == null)
        {
            Debug.LogError(this.name + " on " + this.gameObject.name + " setup error!");
            this.enabled = false;
            return;
        }

        foreach (GoodUIReferences currentGoodReferenceScript in myGoodUIReferencesList)
        {
            Defs.TradeGoods     good     = currentGoodReferenceScript.myGood;
            Defs.TradeGoodTypes goodType = currentGoodReferenceScript.myGoodType;

            // Set the Good script up
            Good goodScript = Defs.Instance.AddGoodScript(good, myGoodParentObject);
            if (goodScript != null)
            {
                goodScript.myGood           = good;
                goodScript.myGoodType       = goodType;
                goodScript.activeNodeScript = myActiveNodeScript;
                goodScript.myUIReferences   = currentGoodReferenceScript;
                goodScript.enabled          = true;
            }

            Button buyButton  = currentGoodReferenceScript.buyButton;
            Button sellButton = currentGoodReferenceScript.sellButton;

            if (buyButton == null || sellButton == null)
            {
                Debug.LogError("Button setup error on " + gameObject.name);
                this.enabled = false;
                return;
            }

            // Setup the click logic
            buyButton.onClick.AddListener(() => GoodsBuyButtonClicked(goodScript));
            sellButton.onClick.AddListener(() => GoodsSellButtonClicked(goodScript));
        }

        foreach (UpgradeUIReferences currentUpgradeReferencesScript in myUpgradeReferencesList)
        {
            Defs.EngineUpgrades engineUpgrade = currentUpgradeReferencesScript.upgrade;

            // Set the Upgrade script up
            Upgrade upgradeScript = myGoodParentObject.AddComponent <Upgrade>();
            if (upgradeScript != null)
            {
                upgradeScript.upgrade          = engineUpgrade;
                upgradeScript.activeNodeScript = myActiveNodeScript;
                upgradeScript.buyButton        = currentUpgradeReferencesScript.buyButton;
                upgradeScript.buyText          = currentUpgradeReferencesScript.buyText;
                upgradeScript.upgradeNameText  = currentUpgradeReferencesScript.upgradeNameText;
                upgradeScript.enabled          = true;
            }

            Button buyButton = currentUpgradeReferencesScript.buyButton;

            if (buyButton == null)
            {
                Debug.LogError("Button setup error on " + gameObject.name);
                this.enabled = false;
                return;
            }

            // Setup the click logic
            buyButton.onClick.AddListener(() => UpgradeBuyButtonClicked(upgradeScript));
        }
    }
Esempio n. 4
0
 public bool PlayerHasUpgrade(Defs.EngineUpgrades engineUpgrade)
 {
     return(currentEngine == engineUpgrade);
 }
Esempio n. 5
0
 public IEnumerator EngineUpgrade(Defs.EngineUpgrades engineUpgrade)
 {
     UpdateUI(engineUpgrade);
     yield return(null);
 }