public void DoubleARandomRigRack()
    {
        MapController mapController = FindObjectOfType <MapController>();
        int           choice        = Random.Range(0, 1);

        if (choice == 0 && mapController.racksBuilt > 0)
        {
            // Apply to a random rack
            int         rackChoice     = Random.Range(0, mapController.racksBuilt - 1);
            RigScript[] rigsInRack     = mapController.rackSlots[rackChoice].GetComponentsInChildren <RigScript>();
            int         effectOnMining = 0;
            foreach (RigScript script in rigsInRack)
            {
                effectOnMining += script.me.myEffectOnMining;
            }
            Debug.Log("Applying " + effectOnMining + " points to miningPerSec stat through a random doubler");
            IncreaseMinMaxMiningSpeed(effectOnMining);
        }
        else
        {
            int       rigChoice      = Random.Range(0, mapController.rigsBuilt - 1);
            RigScript rig            = mapController.rigSlots[rigChoice].GetComponentInChildren <RigScript>();
            int       effectOnMining = rig.me.myEffectOnMining;
            Debug.Log("Applying " + effectOnMining + " points to miningPerSec stat through a random doubler");
            IncreaseMinMaxMiningSpeed(effectOnMining);
        }
    }
 // Start is called before the first frame update
 void Start()
 {
     orbit1  = orbiters1.GetComponent <OrbitScript>();
     orbit2  = orbiters2.GetComponent <OrbitScript>();
     orbit3  = orbiters3.GetComponent <OrbitScript>();
     orbit4  = orbiters4.GetComponent <OrbitScript>();
     orbit5  = orbiters5.GetComponent <OrbitScript>();
     orbit6  = orbiters6.GetComponent <OrbitScript>();
     orbit7  = orbiters7.GetComponent <OrbitScript>();
     orbit8  = orbiters8.GetComponent <OrbitScript>();
     orbit9  = orbiters9.GetComponent <OrbitScript>();
     orbit10 = orbiters10.GetComponent <OrbitScript>();
     orbit11 = orbiters11.GetComponent <OrbitScript>();
     orbit12 = orbiters12.GetComponent <OrbitScript>();
     orbit13 = orbiters13.GetComponent <OrbitScript>();
     srevo   = sun.GetComponent <SunRevolve>();
     rig     = cam.GetComponent <RigScript>();
 }
Пример #3
0
    public void UpgradeARig(int rigSlot)
    {
        foreach (Transform slot in rigSlots)
        {
            if (slot.GetComponent <Rigslot>().myOrderNumber == rigSlot)
            {
                RigScript rigscript = slot.gameObject.GetComponentInChildren <RigScript>(true);
                // DO THE MONEY CHECK

                if (rigscript.me.priceOfNextUpgradeLvl < miningControllerInstance.myMiningController.currentBalance)
                {
                    miningControllerInstance.myMiningController.currentBalance -= rigscript.me.priceOfNextUpgradeLvl;
                    float thisUpgradePrice = rigscript.me.priceOfNextUpgradeLvl;
                    //Debug.Log(thisUpgradePrice);
                    // TODO: this might break when getting to the last item in the list
                    rigscript.me = itemDatabase.rigTypes[rigscript.me.id + 1];
                    rigscript.RefreshIcon();


                    // Here we calculate the price of the next ugprade after the one we've just installed
                    rigscript.me.priceOfNextUpgradeLvl = CalculatePriceOfNextBuilding(itemDatabase.rigTypes[0].priceOfNextUpgradeLvl, 1.5f, rigscript.me.id + 1);
                    //pricePercentageGrowth -= (pricePercentageGrowth * 20 / 100);
                    Rig currentRig = rigscript.me;

                    // MAKING THE NEW RIG ACTUALLY APPLY AN EFFECT TO THE MINING CONTROLLER
                    miningControllerInstance.IncreaseMinMaxMiningSpeed(currentRig.myEffectOnMining);

                    // Sewnding the info to the UI element responsible for this rig
                    mapDelegateHolder.upgradedRigActions(rigSlot, currentRig);
                    return;
                }
                else
                {
                    Debug.Log("Not enough money for this rig right now!");
                }
            }
        }
    }
Пример #4
0
    public void UpgradeARackOfRigs(int rackSlot, Rack rackToUpgrade = null)
    {
        // TODO: figure out whether this actually does anything
        if (!rackToUpgrade)
        {
            foreach (Transform slot in rackSlots)
            {
                //Checking my rack ID to find the one we want to upgrade
                if (slot.GetComponent <RackSlot>().myOrderNumber == rackSlot)
                {
                    //Debug.Log("About to upgrade this rack!");
                    RigScript[] rigslotsInThisRackGroup;
                    // Collecting all the RIGSCRIPTS inside this RACKSLOT to the update them
                    rigslotsInThisRackGroup = slot.GetComponentsInChildren <RigScript>(true);

                    // Find out if we have enough money to upgrade all the rigs in this group
                    if (rigslotsInThisRackGroup[0].me.priceOfNextUpgradeLvl * rigslotsInThisRackGroup.Length < miningControllerInstance.myMiningController.currentBalance)
                    {
                        // Charge me the money for the upgrade of the 3 rigs in the group
                        miningControllerInstance.myMiningController.currentBalance -= rigslotsInThisRackGroup[0].me.priceOfNextUpgradeLvl * rigslotsInThisRackGroup.Length;
                        //Debug.Log("Charged you " + rigslotsInThisRackGroup[0].me.priceOfNextUpgradeLvl * rigslotsInThisRackGroup.Length + " for the upgrades on the rack");

                        // The actual rig upgrade process
                        foreach (RigScript rig in rigslotsInThisRackGroup)
                        {
                            //Debug.Log(rig.me);
                            //Debug.Log("My rig id is now " + rig.me.id);
                            rig.me = itemDatabase.rigTypes[rig.me.id + 1];
                            //Debug.Log("My rig id is now " + rig.me.id);
                            rig.RefreshIcon();
                        }
                        // Getting info from one of the rigs in the bunch
                        RigScript rigSample = rigslotsInThisRackGroup[0];
                        // APPLYING THE UPGRADE'S EFFECTS (this will be multiplied by 3, because there are 3 rigs in each rack
                        miningControllerInstance.IncreaseMinMaxMiningSpeed(rigSample.me.myEffectOnMining * 3);

                        //Send in the info to the UI so it can be udpated with the newly updated rig info for this rag
                        Debug.Log("Spawning a " + rigslotsInThisRackGroup[0].me);
                        mapDelegateHolder.upgradedRackActions(rigslotsInThisRackGroup[0].me, rackSlot);


                        return;
                    }
                    Debug.Log("Not enough money to upgrade all the rigs in this group!");
                    return;
                }
            }
        }
        else
        {
            Debug.Log("About to upgrade a specific rack!");
            RigScript[] rigslotsInThisRackGroup;
            // Collecting all the RIGSCRIPTS inside this RACKSLOT to the update them
            rigslotsInThisRackGroup = rackToUpgrade.GetComponentsInChildren <RigScript>(true);

            if (rigslotsInThisRackGroup[0].me.priceOfNextUpgradeLvl * rigslotsInThisRackGroup.Length < miningControllerInstance.myMiningController.currentBalance)
            {
                // Charge me the money for the upgrade
                miningControllerInstance.myMiningController.currentBalance -= rigslotsInThisRackGroup[0].me.priceOfNextUpgradeLvl * rigslotsInThisRackGroup.Length;
                //Debug.Log("Charged you " + rigslotsInThisRackGroup[0].me.priceOfNextUpgradeLvl * rigslotsInThisRackGroup.Length + " for the upgrades on the rack");

                foreach (RigScript rig in rigslotsInThisRackGroup)
                {
                    Debug.Log(rig.me);
                    //Debug.Log("My rig id is now " + rig.me.id);
                    rig.me = itemDatabase.rigTypes[rig.me.id + 1];
                    //Debug.Log("My rig id is now " + rig.me.id);
                    rig.RefreshIcon();

                    miningControllerInstance.IncreaseMinMaxMiningSpeed(rig.me.myEffectOnMining);
                }
                Debug.Log("Spawning a " + rigslotsInThisRackGroup[0].me);
                mapDelegateHolder.upgradedRackActions(rigslotsInThisRackGroup[0].me, rackSlot);

                //Debug.Log("I've upgraded all the rigs in this group!");
                return;
            }
            Debug.Log("Not enough money to upgrade all the rigs in this group!");
            return;
        }
    }