Beispiel #1
0
        void ShowExportIncomeWindow(int windowID)
        {
            var em = ExpmHolder.get();
            SortedDictionary <string, Exportable.Exportable> exportables = em.GetExportables();
            var en          = exportables.GetEnumerator();
            int totalEarned = 0;

            while (en.MoveNext())
            {
                var c = en.Current.Value;
                if (c.GetEnabled())
                {
                    int earned = (int)(c.LastWeeklyEarning / 100.0);
                    totalEarned += earned;

                    GUILayout.BeginHorizontal();
                    GUILayout.Label(en.Current.Value.Description);
                    GUILayout.FlexibleSpace();
                    GUI.contentColor = Color.white;
                    GUILayout.Label(earned.ToString());
                    GUILayout.EndHorizontal();
                }
            }

            GUILayout.BeginHorizontal();
            GUILayout.Label("Total");
            GUILayout.FlexibleSpace();
            GUILayout.Label(totalEarned.ToString());
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Close"))
            {
                button.state  = UIButton.ButtonState.Normal;
                showingWindow = false;
            }
            GUILayout.EndHorizontal();

            GUI.DragWindow();
        }
Beispiel #2
0
        public override long OnUpdateMoneyAmount(long internalMoneyAmount)
        {
            try
            {
                DistrictManager   DMinstance = Singleton <DistrictManager> .instance;
                Array8 <District> dm_array   = DMinstance.m_districts;
                District          d;

                Debugger.Write("\r\n== OnUpdateMoneyAmount ==");

                double sec_per_day     = 75600.0;             // for some reason
                double sec_per_week    = 7 * sec_per_day;
                double week_proportion = 0.0;
                int    export_earnings = 0;
                int    earnings_shown  = 0;

                if (dm_array == null)
                {
                    Debugger.Write("early return, dm_array is null");
                    return(internalMoneyAmount);
                }

                d = dm_array.m_buffer[0];

                if (!updated)
                {
                    updated  = true;
                    prevDate = this.managers.threading.simulationTime;
                    Debugger.Write("first run");
                }
                else
                {
                    System.DateTime newDate  = this.managers.threading.simulationTime;
                    System.TimeSpan timeDiff = newDate.Subtract(prevDate);
                    week_proportion = (((double)timeDiff.TotalSeconds) / sec_per_week);
                    if (week_proportion > 0.0)
                    {
                        Debugger.Write("proportion: " + week_proportion.ToString());
                        EconomyManager EM = Singleton <EconomyManager> .instance;
                        if (EM != null)
                        {
                            // add income
                            export_earnings = (int)ExpmHolder.get().CalculateIncome(d, week_proportion);
                            earnings_shown  = export_earnings / 100;
                            Debugger.Write("Total earnings: " + earnings_shown.ToString());
                            EM.AddResource(EconomyManager.Resource.PublicIncome,
                                           export_earnings,
                                           ItemClass.Service.None,
                                           ItemClass.SubService.None,
                                           ItemClass.Level.None);
                        }
                    }
                    else
                    {
                        Debugger.Write("week_proportion zero");
                    }
                    prevDate = newDate;
                }
            }
            catch (Exception ex)
            {
                // shouldn't happen, but if it does, start logging
                Debugger.Write("Exception " + ex.Message.ToString());
            }
            return(internalMoneyAmount);
        }
Beispiel #3
0
        public void OnSettingsUI(UIHelperBase helper)
        {
            UIHelperBase group = helper.AddGroup("Check to enable income from excess capacity");

            ExpmHolder.get().AddOptions(group);
        }