コード例 #1
0
        protected int CalculateLocalBaseCurrencyValue()
        {
            int baseCurrencyValue = Mathf.CeilToInt(GlobalProps.BaseCurrencyValue);

            if (SaveState != null && SaveState.Scripts != null)
            {
                var enumerator = this.SaveState.Scripts.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    //Debug.Log("Checking script " + enumerator.Current.Key);
                    Type scriptType = System.Type.GetType("Frontiers.World.WIScripts." + enumerator.Current.Key);
                    if (scriptType == null)
                    {
                        //Debug.Log("Couldn't get script type for name " + enumerator.Current.Key);
                    }
                    else
                    {
                        var calculateLocalPriceMethod = scriptType.GetMethod("CalculateLocalPrice", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic);
                        if (calculateLocalPriceMethod != null)
                        {
                            //Debug.Log("Got calcualate price method from " + enumerator.Current.Key);
                            object stateData         = null;
                            string scriptStateName   = scriptType.FullName + "State";                          //<-this shit is going to get people in trouble, haha
                            string scriptStateString = string.Empty;
                            stateData         = WIScript.XmlDeserializeFromString(enumerator.Current.Value, scriptStateName);
                            baseCurrencyValue = (int)calculateLocalPriceMethod.Invoke(null, new object [] {
                                baseCurrencyValue,
                                this
                            });
                        }
                    }
                }
            }
            else
            {
                Debug.Log("Didn't have states");
            }
            if (Props.Local.CraftedByPlayer)
            {
                baseCurrencyValue = Mathf.CeilToInt(baseCurrencyValue * Globals.BaseValueCraftingBonus);
            }
            //apply wealth level
            baseCurrencyValue = Mathf.Max(baseCurrencyValue, Mathf.CeilToInt(baseCurrencyValue * FlagSet.GetAverageValue(GlobalProps.Flags.Wealth) * 0.25f));
            return(baseCurrencyValue);
        }
コード例 #2
0
        protected int CalculateLocalBaseCurrencyValue()
        {
            //Debug.Log("Calculating base currency for " + name);
            //global base currency value is determined on startup
            int baseCurrencyValue = Mathf.Max(mGlobalBaseCurrencyValue, Mathf.CeilToInt(Props.Global.BaseCurrencyValue));
            var enumerator        = mScripts.GetEnumerator();

            while (enumerator.MoveNext())
            {
                //Debug.Log("Getting local price from " + enumerator.Current.Value.TrueType.Name);
                baseCurrencyValue = enumerator.Current.Value.LocalPrice(baseCurrencyValue);
            }
            if (Props.Local.CraftedByPlayer)
            {
                baseCurrencyValue = Mathf.CeilToInt(baseCurrencyValue * Globals.BaseValueCraftingBonus);
            }
            //apply wealth level
            baseCurrencyValue = Mathf.Max(baseCurrencyValue, Mathf.CeilToInt(baseCurrencyValue * FlagSet.GetAverageValue(Props.Global.Flags.Wealth) * 0.25f));
            return(baseCurrencyValue);
        }