Пример #1
0
        }//end ResourceCheck

        IEnumerator Create(int groupID, int processID)
        {//follow the manufacturing process
            Mnfctr process = controller.manufacture[groupID].manufacture[processID];//the manufacturing process in the controller
            RunMnfctr postMan = manufacture[groupID].manufacture[processID];//the manufacturing process at the trade post

            currencies[postMan.currencyID] -= postMan.price * (controller.expTraders.enabled ? 0 : 1);//remove the amount of money required to run the process
                                                                            //only need to remove credits if expendable is disabled

            postMan.running = true;//set to true so cannot be called again until done
            AddRemove(process.needing, true);//remove the items needed
            yield return new WaitForSeconds(postMan.create);//pause for the creation time
            AddRemove(process.making, false);//add the items made
            yield return new WaitForSeconds(postMan.cooldown);//pause for the cooldown time
            postMan.running = false;//now set to false because has finished the process
        }//end Create
Пример #2
0
        }//end UpdateSinglePrice

        public void ManufactureCheck()
        {//go through the manufacturing processes, and if not being made, check that can
            if (allowManufacture)
            {//check is allowed to manufacture items
                for (int m1 = 0; m1 < manufacture.Count; m1++)
                {//go through manufacture groups
                    for (int m2 = 0; m2 < manufacture[m1].manufacture.Count; m2++)
                    {//go through manufacture processes
                        RunMnfctr cMan = manufacture[m1].manufacture[m2];
                        if (cMan.enabled && !cMan.running && currencies[cMan.currencyID] - cMan.price > 0)
                        {
                            //check that the process is allowed and not currently running and has enough cash
                            if (ResourceCheck(m1, m2))
                            {//check that has enough resources and check the stock numbers
                             //now needs to follow the process
                                StartCoroutine(Create(m1, m2));//follow the process
                            }//end if enough resources
                        }//end if running
                    }//end for manufacture processes
                }//end for manufacture groups
            }//end manufacture allow check
        }//end ManfuactureCheck
Пример #3
0
        }//end ResourceCheck

        IEnumerator Create(int groupID, int processID)
        {//follow the manufacturing process
            Mnfctr process = controller.manufacture[groupID].manufacture[processID];//the manufacturing process in the controller
            RunMnfctr traderMan = manufacture[groupID].manufacture[processID];//the manufacturing process at the trade post

            currencies[traderMan.currencyID] -= traderMan.price;//remove the amount of money required to run the process

            //needs to pause before removing the items here so that they dont appear later on, potentially after the trader has been to a trade post

            traderMan.running = true;//set to true so cannot be called again until done
            yield return new WaitForSeconds(traderMan.create);//pause for the creation time

            if (onCall && allowGo)
            {//check the trader is moving as it may have arrived at a trade post within the pause time
                AddRemove(process.needing, true);//remove the items needed
                AddRemove(process.making, false);//add the items made
                spaceRemaining += process.needingMass - process.makingMass;
                yield return new WaitForSeconds(traderMan.cooldown);//pause for the cooldown time
            }//end if trader travelling

            traderMan.running = false;//now set to false because has finished the process
        }//end Create
Пример #4
0
        }//end CalcInfo

        void NumberChange(RunMnfctr man, Mnfctr cMan)
        {//calculate the number changes from trade posts and traders
            if (man.enabled)
            {//check that item is enabled
                float toChange = 0;
                float deniminator = man.create + man.cooldown;//get the denominator. This is the minimum time between subsequent manufactures

                cashChange -= man.price / deniminator;//work out how the amount of cash will change

                for (int nm = 0; nm < cMan.needing.Count; nm++)
                {//go through needing, reducing perItem
                    toChange = cMan.needing[nm].number / deniminator;
                    total -= toChange;
                    perItem[cMan.needing[nm].groupID][cMan.needing[nm].itemID] -= toChange;
                }//end for needing

                for (int nm = 0; nm < cMan.making.Count; nm++)
                {//go through making, increasing perItem
                    toChange = cMan.making[nm].number / deniminator;
                    total += toChange;
                    perItem[cMan.making[nm].groupID][cMan.making[nm].itemID] += toChange;
                }//end for needing
            }//end enabled check
        }//end NumberChange