Esempio n. 1
0
        }//end SetChange

        float Exchange(int currencyID, Mnfctr cMan)
        {//go through nm and see if exchange is ok, if is then add to total, if not, return

            float needing = 0;//the cost of all of the items needed
            float making = 0;//the profit from all of the items sold

            for (int nm = 0; nm < cMan.needing.Count; nm++)
            {//go through all needing, getting min cost
                NeedMake currentNM = cMan.needing[nm];

                Goods currentGood = controller.goods[currentNM.groupID].goods[currentNM.itemID];

                float thisNeeding = currentGood.minPrice * currentNM.number * controller.GetExchangeRate(currentGood.currencyID, currencyID);

                if (thisNeeding != 0)//if is a value
                    needing += thisNeeding;//then add to the needing
                else
                    return 0;//else return 0 as currency is invalid
            }//end for needing
            for (int nm = 0; nm < cMan.making.Count; nm++)
            {//go through all making, getting max price
                NeedMake currentNM = cMan.making[nm];

                Goods currentGood = controller.goods[currentNM.groupID].goods[currentNM.itemID];

                float thisMaking = currentGood.maxPrice * currentNM.number * controller.GetExchangeRate(currentGood.currencyID, currencyID);

                if (thisMaking != 0)//if is a value
                    making += thisMaking;//then add to the making
                else
                    return 0;//else return 0 as currency is invalid
            }//end for needing

            return ((making / needing) - 1) * 100;//return the percent profit
        }//end CurrencyExchange
Esempio n. 2
0
        }//end OnGUI

        void CalcInfo()
        {//calculate the information
         //reset some of the information so that it will be correct if the number of items changes
            perItem = new float[controller.goods.Count][];//the change for each item
            info = new string[controller.goods.Count][];//an array containing all of the strings to display
            for (int g = 0; g < controller.goods.Count; g++)
            {
                perItem[g] = new float[controller.goods[g].goods.Count];
                info[g] = new string[controller.allNames[g].Length];
            }
            total = cashChange = 0;//reset the totals
            pricing = new string[controller.manufacture.Count][];

            List<MnfctrTypes> manufacture = controller.manufacture;

            for (int m = 0; m < manufacture.Count; m++)
            {//go through all manufacture groups
                int processCount = manufacture[m].manufacture.Count;
                pricing[m] = new string[processCount];

                for (int p = 0; p < processCount; p++)
                {//go through all processes					
                    #region number change
                    Mnfctr cMan = controller.manufacture[m].manufacture[p];
                    for (int tp = 0; tp < controller.postScripts.Length; tp++)//go through all posts
                        if (controller.postScripts[tp].manufacture[m].enabled)//only count if group enabled
                            NumberChange(controller.postScripts[tp].manufacture[m].manufacture[p], cMan);
                    for (int t = 0; t < controller.traderScripts.Length; t++)//go through all traders
                        if (controller.traderScripts[t].manufacture[m].enabled)//only count if group enabled
                            NumberChange(controller.traderScripts[t].manufacture[m].manufacture[p], cMan);
                    #endregion

                    #region pricing
                    pricing[m][p] = "N/A";

                    for (int c = 0; c < controller.currencies.Count; c++)
                    { //for all currencies

                        float percent = Exchange(c, cMan);//get the percent value

                        if (percent != 0)
                        {//if is a value
                            pricing[m][p] = percent.ToString("n2") + "%";//can set the text
                            break;//and can break as valid excahanges were used
                        }//end if usable
                    }//end for currencies
                    #endregion
                }//end for all processes			
            }//end for manufacture groups

            for (int x = 0; x < info.Length; x++)//go through all goods, saying increase, decrease or stay the same and give a value
                for (int y = 0; y < info[x].Length; y++)
                    info[x][y] = SetChange(perItem[x][y]);
        }//end CalcInfo
Esempio n. 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 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
Esempio n. 4
0
        }//end Manfuacture Check

        bool ResourceCheck(int groupID, int processID)
        {//check that the manufacturing process has enough resources to work, and numbers are not above or below min values if option selected
            Mnfctr cMan = controller.manufacture[groupID].manufacture[processID];

            for (int n = 0; n < cMan.needing.Count; n++)
            {//go through all needing
                NeedMake cCheck = cMan.needing[n];
                int quant = items[cCheck.groupID].items[cCheck.itemID].number;

                if (quant < cCheck.number)//if not enough
                    return false;//then return false as it cannot be made
            }//end for needing

            if ((spaceRemaining + cMan.needingMass - cMan.makingMass) < 0)//check that has enough space to be able to manufacture
                return false;

            //if has managed to pass all of the checks
            return true;//return true as the process can be done
        }//end ResourceCheck
Esempio n. 5
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
Esempio n. 6
0
        }//end ManufactureInfo

        string ManufactureTooltip(bool needing, Controller controller, int m1, int m2) {//get the tooltip for the needing or making
            string tooltip = needing ? "N: " : "M: ";

            Mnfctr currentMnfctr = controller.manufacture[m1].manufacture[m2];
            List<NeedMake> currentNM = needing ? currentMnfctr.needing : currentMnfctr.making;
            NeedMake current;

            for (int n = 0; n < currentNM.Count; n++) {//go through all needing or making
                current = currentNM[n];
                tooltip += current.number + "\u00D7";
                if (current.itemID >= 0)//check item is not undefined
                    tooltip += controller.allNames[current.groupID][current.itemID] + ", ";//get the groupID and itemID to get the name
                else
                    tooltip += "Undefined, ";
            }//end for all needing or making

            if (tooltip.Length > 3)//only remove if things have been added
                tooltip = tooltip.Remove(tooltip.Length - 2);//remove the space and comma
            else
                tooltip += "Nothing";

            return tooltip;
        }//end ManufactureTooltip
Esempio n. 7
0
        }//end ManfuactureCheck

        bool ResourceCheck(int groupID, int processID)
        {//check that the manufacturing process has enough resources to work, and numbers are not above or below min values if option selected
            Mnfctr cProcess = controller.manufacture[groupID].manufacture[processID];
            List<NeedMake> check = cProcess.needing;//check the needing list
            for (int n = 0; n < check.Count; n++)
            {//go through all needing
                NeedMake cCheck = check[n];
                Stock cStock = stock[cCheck.groupID].stock[cCheck.itemID];
                if (cStock.number < cCheck.number || (cStock.minMax && stopProcesses && cStock.number <= cStock.min))//if not enough, or has below minimum with stop processes enabled
                    return false;//then return false as it cannot be made
            }//end for needing

            check = cProcess.making;//check the making list
            for (int m = 0; m < check.Count; m++)
            {//go through all making
                NeedMake cCheck = check[m];
                Stock cStock = stock[cCheck.groupID].stock[cCheck.itemID];
                if (cStock.minMax && stopProcesses && cStock.number >= cStock.max)//if already has too many items, and has stop processes enabled
                    return false;//then return false as it cannot be made
            }//end for making
             //if has managed to pass all of the checks
            return true;//return true as the process can be done
        }//end ResourceCheck
Esempio n. 8
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