Пример #1
0
        public ulong GetMaxExpForLevel(byte pLevel)
        {
            ulong ret = 0;

            if (!ExpTable.TryGetValue(pLevel, out ret))
            {
                Log.WriteLine(LogLevel.Warn, "Something tried to get the amount of EXP for level {0} (which is higher than it's max, {1}). Please backtrace the calls to this function!", pLevel, ExpTable.Count);
                Log.WriteLine(LogLevel.Warn, Environment.StackTrace);
            }
            return(ret);
        }
Пример #2
0
        public void Init(int N)
        {
            NN = N;

            NCheck.Check(ref NN, ref Npow2);

            RevInd = RevIndex.Create(NN, Npow2);

            ExpTbl = ExpTable.Create(NN);

            tmp1 = new Complex[NN];
            tmp2 = new Complex[NN];
        }
Пример #3
0
    public void Exp_KillEnemy_ExpUp()
    {
        var table = 100;

        ExpTable expTable    = new ExpTable();
        var      expectskill = Mathf.Floor(player.skill + (statusbug.exp / table));
        var      expectlevel = player.exp + statusbug.exp;

        expTable.Exp(player, statusbug);

        Assert.AreEqual(expectskill, player.skill);
        Assert.AreEqual(expectlevel, statusbug.exp);
    }
Пример #4
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return(null);
            }
            long exp   = 0;
            int  level = 0;

            for (int i = 0; i < ExpTable.Count(); i++)
            {
                if ((long)value < exp)
                {
                    break;
                }
                exp  += ExpTable[i];
                level = i;
            }
            return(level);
        }
        public void Init(int N)
        {
            NN = N;

            NCheck.Check(ref NN, ref Npow2);

            RevInd = RevIndex.Create(NN, Npow2);

            ExpTbl = ExpTable.Create(NN);

            int Nd2 = NN >> 1;

            ExpTblRev = new Complex[Nd2];
            for (int i = 0; i < Nd2; i++)
            {
                ExpTblRev[i] = ExpTbl[RevInd[i] >> 1];
            }

            tmp1 = new Complex[NN];
            tmp2 = new Complex[NN];
        }
Пример #6
0
        public static void LoadAll()
        {
            var sw = System.Diagnostics.Stopwatch.StartNew();

            Translation.Load();
            SoundInfo.Load();
            SoundEnvironment.Load();
            ObjectInfo.Load();
            BodyLoc.Load();
            ExpTable.Load();
            LevelType.Load();
            LevelWarpInfo.Load();
            LevelPreset.Load();
            LevelMazeInfo.Load();
            LevelInfo.Load();
            OverlayInfo.Load();
            MissileInfo.Load();
            ItemStat.Load();
            ItemRatio.Load();
            ItemType.Load();
            ItemPropertyInfo.Load();
            ItemSet.Load();
            UniqueItem.Load();
            SetItem.Load();
            TreasureClass.Load();
            MagicAffix.Load();
            CharStatsInfo.Load();
            MonLvl.Load();
            MonPreset.Load();
            MonSound.Load();
            MonStatsExtended.Load();
            MonStat.Load();
            SuperUnique.Load();
            SkillDescription.Load();
            SkillInfo.Load();
            SpawnPreset.Load();
            StateInfo.Load();
            Debug.Log("All txt files loaded in " + sw.ElapsedMilliseconds + " ms");
        }
Пример #7
0
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var st = value.ToString();

            if (string.IsNullOrEmpty(st))
            {
                st = "0";
            }
            int lvl = Int32.Parse(st);

            if (lvl > ExpTable.Count())
            {
                lvl = ExpTable.Count();
            }
            long exp = 0;

            for (int i = 0; i < lvl; i++)
            {
                exp += ExpTable[i];
            }
            return(exp);
        }
Пример #8
0
        void Awake()
        {
                        #if UNITY_IOS
            Application.targetFrameRate = 60;
                        #endif

            ExpTable expTable = new ExpTable();
            if (User.Instance.RunCount < 1)
            {
                InitGame();
            }
            else
            {
                User.Instance.RunCount++;
            }
            Analytics.CustomEvent("gameOver", new Dictionary <string, object>
            {
                { "equip", User.Instance.EquipIndex },
                { "levelequip" + User.Instance.EquipIndex.ToString(), User.Instance.GetFidgetSpinnerLevel(User.Instance.EquipIndex) },
                { "coin", User.Instance.Coin },
                { "exp", expTable.GetLevel(User.Instance.Exp) }
            });
        }
            public void Update(int shipMasterID)
            {
                KCDatabase db   = KCDatabase.Instance;
                ShipData   ship = db.Ships[shipMasterID];

                if (ship != null)
                {
                    bool isEscaped = KCDatabase.Instance.Fleet[Parent.FleetID].EscapedShipList.Contains(shipMasterID);


                    Name.Text = ship.MasterShip.NameWithClass;
                    Name.Tag  = ship.ShipID;
                    ToolTipInfo.SetToolTip(Name,
                                           string.Format(
                                               "{0} {1}\n火力: {2}/{3}\n雷装: {4}/{5}\n対空: {6}/{7}\n装甲: {8}/{9}\n対潜: {10}/{11}\n回避: {12}/{13}\n索敵: {14}/{15}\n運: {16}\n射程: {17} / 速力: {18}\n(右クリックで図鑑)\n",
                                               ship.MasterShip.ShipTypeName, ship.NameWithLevel,
                                               ship.FirepowerBase, ship.FirepowerTotal,
                                               ship.TorpedoBase, ship.TorpedoTotal,
                                               ship.AABase, ship.AATotal,
                                               ship.ArmorBase, ship.ArmorTotal,
                                               ship.ASWBase, ship.ASWTotal,
                                               ship.EvasionBase, ship.EvasionTotal,
                                               ship.LOSBase, ship.LOSTotal,
                                               ship.LuckTotal,
                                               Constants.GetRange(ship.Range),
                                               Constants.GetSpeed(ship.MasterShip.Speed)
                                               ));


                    Level.Value     = ship.Level;
                    Level.ValueNext = ship.ExpNext;

                    {
                        StringBuilder tip = new StringBuilder();
                        tip.AppendFormat("Total: {0} exp.\r\n", ship.ExpTotal);

                        if (!Utility.Configuration.Config.FormFleet.ShowNextExp)
                        {
                            tip.AppendFormat("次のレベルまで: {0} exp.\r\n", ship.ExpNext);
                        }

                        if (ship.MasterShip.RemodelAfterShipID != 0 && ship.Level < ship.MasterShip.RemodelAfterLevel)
                        {
                            tip.AppendFormat("改装まで: Lv. {0} / {1} exp.\r\n", ship.MasterShip.RemodelAfterLevel - ship.Level, ship.ExpNextRemodel);
                        }
                        else if (ship.Level <= 99)
                        {
                            tip.AppendFormat("Lv99まで: {0} exp.\r\n", Math.Max(ExpTable.GetExpToLevelShip(ship.ExpTotal, 99), 0));
                        }
                        else
                        {
                            tip.AppendFormat("Lv{0}まで: {1} exp.\r\n", ExpTable.ShipMaximumLevel, Math.Max(ExpTable.GetExpToLevelShip(ship.ExpTotal, ExpTable.ShipMaximumLevel), 0));
                        }

                        ToolTipInfo.SetToolTip(Level, tip.ToString());
                    }


                    HP.Value        = ship.HPCurrent;
                    HP.MaximumValue = ship.HPMax;
                    {
                        int dockID = ship.RepairingDockID;

                        HP.RepairTime = null;
                        if (dockID != -1)
                        {
                            HP.RepairTime = db.Docks[dockID].CompletionTime;
                        }
                    }
                    if (isEscaped)
                    {
                        HP.BackColor = Color.Silver;
                    }
                    else
                    {
                        HP.BackColor = SystemColors.Control;
                    }
                    {
                        StringBuilder sb     = new StringBuilder();
                        double        hprate = (double)ship.HPCurrent / ship.HPMax;

                        sb.AppendFormat("HP: {0:0.0}% [{1}]\n", hprate * 100, Constants.GetDamageState(hprate));
                        if (isEscaped)
                        {
                            sb.AppendLine("退避中");
                        }
                        else if (hprate > 0.50)
                        {
                            sb.AppendFormat("中破まで: {0} / 大破まで: {1}\n", ship.HPCurrent - ship.HPMax / 2, ship.HPCurrent - ship.HPMax / 4);
                        }
                        else if (hprate > 0.25)
                        {
                            sb.AppendFormat("大破まで: {0}\n", ship.HPCurrent - ship.HPMax / 4);
                        }
                        else
                        {
                            sb.AppendLine("大破しています!");
                        }

                        if (ship.RepairTime > 0)
                        {
                            var span = DateTimeHelper.FromAPITimeSpan(ship.RepairTime);
                            sb.AppendFormat("入渠時間: {0} @ {1}",
                                            DateTimeHelper.ToTimeRemainString(span),
                                            DateTimeHelper.ToTimeRemainString(new TimeSpan(span.Add(new TimeSpan(0, 0, -30)).Ticks / (ship.HPMax - ship.HPCurrent))));
                        }

                        ToolTipInfo.SetToolTip(HP, sb.ToString());
                    }



                    Condition.Text = ship.Condition.ToString();
                    Condition.Tag  = ship.Condition;
                    SetConditionDesign(ship.Condition);

                    if (ship.Condition < 49)
                    {
                        TimeSpan ts = new TimeSpan(0, (int)Math.Ceiling((49 - ship.Condition) / 3.0) * 3, 0);
                        ToolTipInfo.SetToolTip(Condition, string.Format("完全回復まで 約 {0:D2}:{1:D2}", (int)ts.TotalMinutes, (int)ts.Seconds));
                    }
                    else
                    {
                        ToolTipInfo.SetToolTip(Condition, string.Format("あと {0} 回遠征可能", (int)Math.Ceiling((ship.Condition - 49) / 3.0)));
                    }

                    ShipResource.SetResources(ship.Fuel, ship.FuelMax, ship.Ammo, ship.AmmoMax);


                    Equipments.SetSlotList(ship);
                    ToolTipInfo.SetToolTip(Equipments, GetEquipmentString(ship));
                }
                else
                {
                    Name.Tag = -1;
                }


                Name.Visible                           =
                    Level.Visible                      =
                        HP.Visible                     =
                            Condition.Visible          =
                                ShipResource.Visible   =
                                    Equipments.Visible = shipMasterID != -1;
            }
Пример #10
0
            public void Update(int shipMasterID)
            {
                KCDatabase db   = KCDatabase.Instance;
                ShipData   ship = db.Ships[shipMasterID];

                if (ship != null)
                {
                    bool isEscaped = KCDatabase.Instance.Fleet[Parent.FleetID].EscapedShipList.Contains(shipMasterID);


                    Name.Text = ship.MasterShip.NameWithClass;
                    Name.Tag  = ship.ShipID;
                    ToolTipInfo.SetToolTip(Name,
                                           string.Format(
                                               GeneralRes.ShipTooltip,
                                               ship.MasterShip.ShipTypeName, ship.NameWithLevel,
                                               ship.FirepowerBase, ship.FirepowerTotal,
                                               ship.TorpedoBase, ship.TorpedoTotal,
                                               ship.AABase, ship.AATotal,
                                               ship.ArmorBase, ship.ArmorTotal,
                                               ship.ASWBase, ship.ASWTotal,
                                               ship.EvasionBase, ship.EvasionTotal,
                                               ship.LOSBase, ship.LOSTotal,
                                               ship.LuckTotal,
                                               Constants.GetRange(ship.Range),
                                               Constants.GetSpeed(ship.MasterShip.Speed)
                                               ));


                    Level.Value     = ship.Level;
                    Level.ValueNext = ship.ExpNext;

                    {
                        StringBuilder tip = new StringBuilder();
                        if (!Utility.Configuration.Config.FormFleet.ShowNextExp)
                        {
                            tip.AppendFormat(GeneralRes.ToNextLevel + "\r\n", ship.ExpNext);
                        }

                        if (ship.MasterShip.RemodelAfterShipID != 0 && ship.Level < ship.MasterShip.RemodelAfterLevel)
                        {
                            tip.AppendFormat(GeneralRes.ToRemodel, ship.MasterShip.RemodelAfterLevel - ship.Level, ship.ExpNextRemodel);
                        }
                        else if (ship.Level <= 99)
                        {
                            tip.AppendFormat(GeneralRes.To99, Math.Max(ExpTable.GetExpToLevelShip(ship.ExpTotal, 99), 0));
                        }
                        else
                        {
                            tip.AppendFormat(GeneralRes.To150, Math.Max(ExpTable.GetExpToLevelShip(ship.ExpTotal, 150), 0));
                        }

                        ToolTipInfo.SetToolTip(Level, tip.ToString());
                    }


                    HP.Value        = ship.HPCurrent;
                    HP.MaximumValue = ship.HPMax;
                    {
                        int dockID = ship.RepairingDockID;

                        HP.RepairTime = null;
                        if (dockID != -1)
                        {
                            HP.RepairTime = db.Docks[dockID].CompletionTime;
                        }
                    }
                    if (isEscaped)
                    {
                        HP.BackColor = Color.Silver;
                    }
                    else
                    {
                        HP.BackColor = SystemColors.Control;
                    }
                    {
                        StringBuilder sb     = new StringBuilder();
                        double        hprate = (double)ship.HPCurrent / ship.HPMax;

                        sb.AppendFormat("HP: {0:0.0}% [{1}]\n", hprate * 100, Constants.GetDamageState(hprate));
                        if (isEscaped)
                        {
                            sb.AppendLine(GeneralRes.Retreating);
                        }
                        else if (hprate > 0.50)
                        {
                            sb.AppendFormat(GeneralRes.ToMidAndHeavy + "\r\n", ship.HPCurrent - ship.HPMax / 2, ship.HPCurrent - ship.HPMax / 4);
                        }
                        else if (hprate > 0.25)
                        {
                            sb.AppendFormat(GeneralRes.ToHeavy + "\r\n", ship.HPCurrent - ship.HPMax / 4);
                        }
                        else
                        {
                            sb.AppendLine(GeneralRes.IsTaiha);
                        }

                        if (ship.RepairTime > 0)
                        {
                            var span = DateTimeHelper.FromAPITimeSpan(ship.RepairTime);
                            sb.AppendFormat(GeneralRes.DockTime + ": {0}\n",
                                            DateTimeHelper.ToTimeRemainString(span));

                            /*/
                             * sb.AppendFormat( "( @ 1HP: {0} )\n",
                             *      DateTimeHelper.ToTimeRemainString( new TimeSpan( span.Ticks / ( ship.HPMax - ship.HPCurrent ) ) ) );
                             * //*/
                        }

                        ToolTipInfo.SetToolTip(HP, sb.ToString());
                    }



                    Condition.Text = ship.Condition.ToString();
                    if (ship.Condition < 20)
                    {
                        Condition.ImageIndex = (int)ResourceManager.IconContent.ConditionVeryTired;
                    }
                    else if (ship.Condition < 30)
                    {
                        Condition.ImageIndex = (int)ResourceManager.IconContent.ConditionTired;
                    }
                    else if (ship.Condition < 40)
                    {
                        Condition.ImageIndex = (int)ResourceManager.IconContent.ConditionLittleTired;
                    }
                    else if (ship.Condition < 50)
                    {
                        Condition.ImageIndex = (int)ResourceManager.IconContent.ConditionNormal;
                    }
                    else
                    {
                        Condition.ImageIndex = (int)ResourceManager.IconContent.ConditionSparkle;
                    }
                    if (ship.Condition < 49)
                    {
                        TimeSpan ts = new TimeSpan(0, (int)Math.Ceiling((49 - ship.Condition) / 3.0) * 3, 0);
                        ToolTipInfo.SetToolTip(Condition, string.Format(GeneralRes.FatigueRestoreTime, (int)ts.TotalMinutes, (int)ts.Seconds));
                    }
                    else
                    {
                        ToolTipInfo.SetToolTip(Condition, string.Format(GeneralRes.RemainingExpeds, (int)Math.Ceiling((ship.Condition - 49) / 3.0)));
                    }

                    ShipResource.SetResources(ship.Fuel, ship.MasterShip.Fuel, ship.Ammo, ship.MasterShip.Ammo);


                    Equipments.SetSlotList(ship);
                    ToolTipInfo.SetToolTip(Equipments, GetEquipmentString(ship));
                }
                else
                {
                    Name.Tag = -1;
                }


                Name.Visible                           =
                    Level.Visible                      =
                        HP.Visible                     =
                            Condition.Visible          =
                                ShipResource.Visible   =
                                    Equipments.Visible = shipMasterID != -1;
            }
        void Updated(string apiname, dynamic data)
        {
            KCDatabase db = KCDatabase.Instance;


            FlowPanelMaster.SuspendLayout();

            //Admiral
            FlowPanelAdmiral.SuspendLayout();
            AdmiralName.Text    = string.Format("{0} {1}", db.Admiral.AdmiralName, Constants.GetAdmiralRank(db.Admiral.Rank));
            AdmiralComment.Text = db.Admiral.Comment;
            FlowPanelAdmiral.ResumeLayout();

            //HQ Level
            HQLevel.Value = db.Admiral.Level;
            {
                StringBuilder tooltip = new StringBuilder();
                if (db.Admiral.Level < ExpTable.AdmiralExp.Max(e => e.Key))
                {
                    HQLevel.TextNext  = "next:";
                    HQLevel.ValueNext = ExpTable.GetNextExpAdmiral(db.Admiral.Exp);
                    tooltip.AppendFormat("{0} / {1}\r\n", db.Admiral.Exp, ExpTable.AdmiralExp[db.Admiral.Level + 1].Total);
                }
                else
                {
                    HQLevel.TextNext  = "exp:";
                    HQLevel.ValueNext = db.Admiral.Exp;
                }

                //戦果ツールチップ
                //fixme: もっとましな書き方はなかっただろうか
                {
                    var res = RecordManager.Instance.Resource.GetRecordPrevious();
                    if (res != null)
                    {
                        int diff = db.Admiral.Exp - res.HQExp;
                        tooltip.AppendFormat(GeneralRes.ThisTime + ": +{0} exp. / " + GeneralRes.RankPoints + " {1:n2}\r\n", diff, diff * 7 / 10000.0);
                    }
                }
                {
                    var res = RecordManager.Instance.Resource.GetRecordDay();
                    if (res != null)
                    {
                        int diff = db.Admiral.Exp - res.HQExp;
                        tooltip.AppendFormat(GeneralRes.Today + ": +{0} exp. / " + GeneralRes.RankPoints + " {1:n2}\r\n", diff, diff * 7 / 10000.0);
                    }
                }
                {
                    var res = RecordManager.Instance.Resource.GetRecordMonth();
                    if (res != null)
                    {
                        int diff = db.Admiral.Exp - res.HQExp;
                        tooltip.AppendFormat(GeneralRes.ThisMonth + ": +{0} exp. / " + GeneralRes.RankPoints + " {1:n2}\r\n", diff, diff * 7 / 10000.0);
                    }
                }

                ToolTipInfo.SetToolTip(HQLevel, tooltip.ToString());
            }

            //Fleet
            FlowPanelFleet.SuspendLayout();
            {
                ShipCount.Text = string.Format("{0}/{1}", RealShipCount, db.Admiral.MaxShipCount);
                if (RealShipCount > db.Admiral.MaxShipCount - 5)
                {
                    ShipCount.BackColor = Utility.ThemeManager.GetColor(Utility.Configuration.Config.UI.Theme, Utility.ThemeColors.RedHighlight);
                }
                else
                {
                    ShipCount.BackColor = Color.Transparent;
                }
                ShipCount.Tag = RealShipCount >= db.Admiral.MaxShipCount;

                EquipmentCount.Text = string.Format("{0}/{1}", RealEquipmentCount, db.Admiral.MaxEquipmentCount);
                if (RealEquipmentCount > db.Admiral.MaxEquipmentCount + 3 - 20)
                {
                    EquipmentCount.BackColor = Utility.ThemeManager.GetColor(Utility.Configuration.Config.UI.Theme, Utility.ThemeColors.RedHighlight);
                }
                else
                {
                    EquipmentCount.BackColor = Color.Transparent;
                }
                EquipmentCount.Tag = RealEquipmentCount >= db.Admiral.MaxEquipmentCount;
            }
            FlowPanelFleet.ResumeLayout();



            var resday   = RecordManager.Instance.Resource.GetRecord(DateTime.Now.AddHours(-5).Date.AddHours(5));
            var resweek  = RecordManager.Instance.Resource.GetRecord(DateTime.Now.AddHours(-5).Date.AddDays(-(((int)DateTime.Now.AddHours(-5).DayOfWeek + 6) % 7)).AddHours(5));                                //月曜日起点
            var resmonth = RecordManager.Instance.Resource.GetRecord(new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddHours(5));


            //UseItems
            FlowPanelUseItem.SuspendLayout();

            InstantRepair.Text = db.Material.InstantRepair.ToString();
            ToolTipInfo.SetToolTip(InstantRepair, string.Format(GeneralRes.ChangeTooltip,
                                                                resday == null ? 0 : (db.Material.InstantRepair - resday.InstantRepair),
                                                                resweek == null ? 0 : (db.Material.InstantRepair - resweek.InstantRepair),
                                                                resmonth == null ? 0 : (db.Material.InstantRepair - resmonth.InstantRepair)));

            InstantConstruction.Text = db.Material.InstantConstruction.ToString();
            ToolTipInfo.SetToolTip(InstantConstruction, string.Format(GeneralRes.ChangeTooltip,
                                                                      resday == null ? 0 : (db.Material.InstantConstruction - resday.InstantConstruction),
                                                                      resweek == null ? 0 : (db.Material.InstantConstruction - resweek.InstantConstruction),
                                                                      resmonth == null ? 0 : (db.Material.InstantConstruction - resmonth.InstantConstruction)));

            DevelopmentMaterial.Text = db.Material.DevelopmentMaterial.ToString();
            ToolTipInfo.SetToolTip(DevelopmentMaterial, string.Format(GeneralRes.ChangeTooltip,
                                                                      resday == null ? 0 : (db.Material.DevelopmentMaterial - resday.DevelopmentMaterial),
                                                                      resweek == null ? 0 : (db.Material.DevelopmentMaterial - resweek.DevelopmentMaterial),
                                                                      resmonth == null ? 0 : (db.Material.DevelopmentMaterial - resmonth.DevelopmentMaterial)));

            ModdingMaterial.Text = db.Material.ModdingMaterial.ToString();
            ToolTipInfo.SetToolTip(ModdingMaterial, string.Format(GeneralRes.ChangeTooltip,
                                                                  resday == null ? 0 : (db.Material.ModdingMaterial - resday.ModdingMaterial),
                                                                  resweek == null ? 0 : (db.Material.ModdingMaterial - resweek.ModdingMaterial),
                                                                  resmonth == null ? 0 : (db.Material.ModdingMaterial - resmonth.ModdingMaterial)));

            FurnitureCoin.Text = db.Admiral.FurnitureCoin.ToString();
            {
                int small  = db.UseItems[10] != null ? db.UseItems[10].Count : 0;
                int medium = db.UseItems[11] != null ? db.UseItems[11].Count : 0;
                int large  = db.UseItems[12] != null ? db.UseItems[12].Count : 0;

                ToolTipInfo.SetToolTip(FurnitureCoin,
                                       string.Format("(" + GeneralRes.Small + ") x {0} ( +{1} )\r\n(" + GeneralRes.Medium + ") x {2} ( +{3} )\r\n(" + GeneralRes.Large + ") x {4} ( +{5} )\r\n",
                                                     small, small * 200,
                                                     medium, medium * 400,
                                                     large, large * 700));
            }
            FlowPanelUseItem.ResumeLayout();


            //Resources
            FlowPanelResource.SuspendLayout();
            {
                Color overcolor = Utility.ThemeManager.GetColor(Utility.Configuration.Config.UI.Theme, Utility.ThemeColors.OrangeHighlight);

                Fuel.Text      = db.Material.Fuel.ToString();
                Fuel.BackColor = db.Material.Fuel < db.Admiral.MaxResourceRegenerationAmount ? Color.Transparent : overcolor;
                ToolTipInfo.SetToolTip(Fuel, string.Format(GeneralRes.ChangeTooltip,
                                                           resday == null ? 0 : (db.Material.Fuel - resday.Fuel),
                                                           resweek == null ? 0 : (db.Material.Fuel - resweek.Fuel),
                                                           resmonth == null ? 0 : (db.Material.Fuel - resmonth.Fuel)));

                Ammo.Text      = db.Material.Ammo.ToString();
                Ammo.BackColor = db.Material.Ammo < db.Admiral.MaxResourceRegenerationAmount ? Color.Transparent : overcolor;
                ToolTipInfo.SetToolTip(Ammo, string.Format(GeneralRes.ChangeTooltip,
                                                           resday == null ? 0 : (db.Material.Ammo - resday.Ammo),
                                                           resweek == null ? 0 : (db.Material.Ammo - resweek.Ammo),
                                                           resmonth == null ? 0 : (db.Material.Ammo - resmonth.Ammo)));

                Steel.Text      = db.Material.Steel.ToString();
                Steel.BackColor = db.Material.Steel < db.Admiral.MaxResourceRegenerationAmount ? Color.Transparent : overcolor;
                ToolTipInfo.SetToolTip(Steel, string.Format(GeneralRes.ChangeTooltip,
                                                            resday == null ? 0 : (db.Material.Steel - resday.Steel),
                                                            resweek == null ? 0 : (db.Material.Steel - resweek.Steel),
                                                            resmonth == null ? 0 : (db.Material.Steel - resmonth.Steel)));

                Bauxite.Text      = db.Material.Bauxite.ToString();
                Bauxite.BackColor = db.Material.Bauxite < db.Admiral.MaxResourceRegenerationAmount ? Color.Transparent : overcolor;
                ToolTipInfo.SetToolTip(Bauxite, string.Format(GeneralRes.ChangeTooltip,
                                                              resday == null ? 0 : (db.Material.Bauxite - resday.Bauxite),
                                                              resweek == null ? 0 : (db.Material.Bauxite - resweek.Bauxite),
                                                              resmonth == null ? 0 : (db.Material.Bauxite - resmonth.Bauxite)));
            }
            FlowPanelResource.ResumeLayout();

            FlowPanelMaster.ResumeLayout();
            if (!FlowPanelMaster.Visible)
            {
                FlowPanelMaster.Visible = true;
            }
            AdmiralName.Refresh();
            AdmiralComment.Refresh();
        }
Пример #12
0
        void Updated(string apiname, dynamic data)
        {
            KCDatabase db = KCDatabase.Instance;

            var configUI = Utility.Configuration.Config.UI;

            if (!db.Admiral.IsAvailable)
            {
                return;
            }

            FlowPanelMaster.SuspendLayout();

            //Admiral
            FlowPanelAdmiral.SuspendLayout();
            AdmiralName.Text = string.Format("{0} {1}", db.Admiral.AdmiralName, Constants.GetAdmiralRank(db.Admiral.Rank));
            {
                StringBuilder tooltip = new StringBuilder();

                var sortieCount = db.Admiral.SortieWin + db.Admiral.SortieLose;
                tooltip.AppendFormat("Sorties: {0} / Win: {1} ({2:p2}) / Lose: {3}\r\n",
                                     sortieCount, db.Admiral.SortieWin, db.Admiral.SortieWin / Math.Max(sortieCount, 1.0), db.Admiral.SortieLose);

                tooltip.AppendFormat("Avg exp per sortie: {0:n2} / per victory: {1:n2}\r\n",
                                     db.Admiral.Exp / Math.Max(sortieCount, 1.0),
                                     db.Admiral.Exp / Math.Max(db.Admiral.SortieWin, 1.0));

                tooltip.AppendFormat("Expeditions: {0} / Success: {1} ({2:p2}) / Failed: {3}\r\n",
                                     db.Admiral.MissionCount, db.Admiral.MissionSuccess, db.Admiral.MissionSuccess / Math.Max(db.Admiral.MissionCount, 1.0), db.Admiral.MissionCount - db.Admiral.MissionSuccess);

                var practiceCount = db.Admiral.PracticeWin + db.Admiral.PracticeLose;
                tooltip.AppendFormat("Naval Exercises: {0} / Win: {1} ({2:p2}) / Lose: {3}\r\n",
                                     practiceCount, db.Admiral.PracticeWin, db.Admiral.PracticeWin / Math.Max(practiceCount, 1.0), db.Admiral.PracticeLose);

                tooltip.AppendFormat("Memedals: {0}\r\n", db.Admiral.Medals);

                ToolTipInfo.SetToolTip(AdmiralName, tooltip.ToString());
            }
            AdmiralComment.Text = db.Admiral.Comment;
            FlowPanelAdmiral.ResumeLayout();

            //HQ Level
            HQLevel.Value = db.Admiral.Level;
            {
                StringBuilder tooltip = new StringBuilder();
                if (db.Admiral.Level < ExpTable.AdmiralExp.Max(e => e.Key))
                {
                    HQLevel.TextNext  = "next:";
                    HQLevel.ValueNext = ExpTable.GetNextExpAdmiral(db.Admiral.Exp);
                    tooltip.AppendFormat("{0} / {1}\r\n", db.Admiral.Exp, ExpTable.AdmiralExp[db.Admiral.Level + 1].Total);
                }
                else
                {
                    HQLevel.TextNext  = "exp:";
                    HQLevel.ValueNext = db.Admiral.Exp;
                }

                //戦果ツールチップ
                //fixme: もっとましな書き方はなかっただろうか
                {
                    var res = RecordManager.Instance.Resource.GetRecordPrevious();
                    if (res != null)
                    {
                        int diff = db.Admiral.Exp - res.HQExp;
                        tooltip.AppendFormat("Session: +{0} exp / {1:n2} pt\r\n", diff, diff * 7 / 10000.0);
                    }
                }
                {
                    var res = RecordManager.Instance.Resource.GetRecordDay();
                    if (res != null)
                    {
                        int diff = db.Admiral.Exp - res.HQExp;
                        tooltip.AppendFormat("Daily: +{0} exp / {1:n2} pt\r\n", diff, diff * 7 / 10000.0);
                    }
                }
                {
                    var res = RecordManager.Instance.Resource.GetRecordMonth();
                    if (res != null)
                    {
                        int diff = db.Admiral.Exp - res.HQExp;
                        tooltip.AppendFormat("Monthly: +{0} exp / {1:n2} pt\r\n", diff, diff * 7 / 10000.0);
                    }
                }

                ToolTipInfo.SetToolTip(HQLevel, tooltip.ToString());
            }

            //Fleet
            FlowPanelFleet.SuspendLayout();
            {
                ShipCount.Text = string.Format("{0}/{1}", RealShipCount, db.Admiral.MaxShipCount);
                if (RealShipCount > db.Admiral.MaxShipCount - 5)
                {
                    ShipCount.BackColor = Utility.Configuration.Config.UI.Headquarters_ShipCountOverBG;
                    ShipCount.ForeColor = Utility.Configuration.Config.UI.Headquarters_ShipCountOverFG;
                }
                else
                {
                    ShipCount.BackColor = Color.Transparent;
                    ShipCount.ForeColor = Utility.Configuration.Config.UI.ForeColor;
                }
                ShipCount.Tag = RealShipCount >= db.Admiral.MaxShipCount;

                EquipmentCount.Text = string.Format("{0}/{1}", RealEquipmentCount, db.Admiral.MaxEquipmentCount);
                if (RealEquipmentCount > db.Admiral.MaxEquipmentCount + 3 - 20)
                {
                    EquipmentCount.BackColor = Utility.Configuration.Config.UI.Headquarters_ShipCountOverBG;
                    EquipmentCount.ForeColor = Utility.Configuration.Config.UI.Headquarters_ShipCountOverFG;
                }
                else
                {
                    EquipmentCount.BackColor = Color.Transparent;
                    EquipmentCount.ForeColor = Utility.Configuration.Config.UI.ForeColor;
                }
                EquipmentCount.Tag = RealEquipmentCount >= db.Admiral.MaxEquipmentCount;
            }
            FlowPanelFleet.ResumeLayout();



            var resday   = RecordManager.Instance.Resource.GetRecord(DateTime.Now.AddHours(-5).Date.AddHours(5));
            var resweek  = RecordManager.Instance.Resource.GetRecord(DateTime.Now.AddHours(-5).Date.AddDays(-(((int)DateTime.Now.AddHours(-5).DayOfWeek + 6) % 7)).AddHours(5));            //月曜日起点
            var resmonth = RecordManager.Instance.Resource.GetRecord(new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddHours(5));


            //UseItems
            FlowPanelUseItem.SuspendLayout();

            InstantRepair.Text = db.Material.InstantRepair.ToString();
            if (db.Material.InstantRepair >= 3000)
            {
                InstantRepair.ForeColor = configUI.Headquarters_MaterialMaxFG;
                InstantRepair.BackColor = configUI.Headquarters_MaterialMaxBG;
            }
            else if (db.Material.InstantRepair < (configUI.HqResLowAlertBucket == -1 ? db.Admiral.MaxResourceRegenerationAmount : configUI.HqResLowAlertBucket))
            {
                InstantRepair.ForeColor = configUI.Headquarters_ResourceLowFG;
                InstantRepair.BackColor = configUI.Headquarters_ResourceLowBG;
            }
            else
            {
                InstantRepair.ForeColor = configUI.ForeColor;
                InstantRepair.BackColor = Color.Transparent;
            }
            ToolTipInfo.SetToolTip(InstantRepair, string.Format("Daily: {0:+##;-##;±0}\nWeekly: {1:+##;-##;±0}\nMonthly: {2:+##;-##;±0}",
                                                                resday == null ? 0 : (db.Material.InstantRepair - resday.InstantRepair),
                                                                resweek == null ? 0 : (db.Material.InstantRepair - resweek.InstantRepair),
                                                                resmonth == null ? 0 : (db.Material.InstantRepair - resmonth.InstantRepair)));

            InstantConstruction.Text = db.Material.InstantConstruction.ToString();
            if (db.Material.InstantConstruction >= 3000)
            {
                InstantConstruction.ForeColor = configUI.Headquarters_MaterialMaxFG;
                InstantConstruction.BackColor = configUI.Headquarters_MaterialMaxBG;
            }
            else
            {
                InstantConstruction.ForeColor = configUI.ForeColor;
                InstantConstruction.BackColor = Color.Transparent;
            }
            ToolTipInfo.SetToolTip(InstantConstruction, string.Format("Daily: {0:+##;-##;±0}\nWeekly: {1:+##;-##;±0}\nMonthly: {2:+##;-##;±0}",
                                                                      resday == null ? 0 : (db.Material.InstantConstruction - resday.InstantConstruction),
                                                                      resweek == null ? 0 : (db.Material.InstantConstruction - resweek.InstantConstruction),
                                                                      resmonth == null ? 0 : (db.Material.InstantConstruction - resmonth.InstantConstruction)));

            DevelopmentMaterial.Text = db.Material.DevelopmentMaterial.ToString();
            if (db.Material.DevelopmentMaterial >= 3000)
            {
                DevelopmentMaterial.ForeColor = configUI.Headquarters_MaterialMaxFG;
                DevelopmentMaterial.BackColor = configUI.Headquarters_MaterialMaxBG;
            }
            else
            {
                DevelopmentMaterial.ForeColor = configUI.ForeColor;
                DevelopmentMaterial.BackColor = Color.Transparent;
            }
            ToolTipInfo.SetToolTip(DevelopmentMaterial, string.Format("Daily: {0:+##;-##;±0}\nWeekly: {1:+##;-##;±0}\nMonthly: {2:+##;-##;±0}",
                                                                      resday == null ? 0 : (db.Material.DevelopmentMaterial - resday.DevelopmentMaterial),
                                                                      resweek == null ? 0 : (db.Material.DevelopmentMaterial - resweek.DevelopmentMaterial),
                                                                      resmonth == null ? 0 : (db.Material.DevelopmentMaterial - resmonth.DevelopmentMaterial)));

            ModdingMaterial.Text = db.Material.ModdingMaterial.ToString();
            if (db.Material.ModdingMaterial >= 3000)
            {
                ModdingMaterial.ForeColor = configUI.Headquarters_MaterialMaxFG;
                ModdingMaterial.BackColor = configUI.Headquarters_MaterialMaxBG;
            }
            else
            {
                ModdingMaterial.ForeColor = configUI.ForeColor;
                ModdingMaterial.BackColor = Color.Transparent;
            }
            ToolTipInfo.SetToolTip(ModdingMaterial, string.Format("Daily: {0:+##;-##;±0}\nWeekly: {1:+##;-##;±0}\nMonthly: {2:+##;-##;±0}",
                                                                  resday == null ? 0 : (db.Material.ModdingMaterial - resday.ModdingMaterial),
                                                                  resweek == null ? 0 : (db.Material.ModdingMaterial - resweek.ModdingMaterial),
                                                                  resmonth == null ? 0 : (db.Material.ModdingMaterial - resmonth.ModdingMaterial)));

            FurnitureCoin.Text = db.Admiral.FurnitureCoin.ToString();
            if (db.Admiral.FurnitureCoin >= 200000)
            {
                FurnitureCoin.ForeColor = configUI.Headquarters_CoinMaxFG;
                FurnitureCoin.BackColor = configUI.Headquarters_CoinMaxBG;
            }
            else
            {
                FurnitureCoin.ForeColor = configUI.ForeColor;
                FurnitureCoin.BackColor = Color.Transparent;
            }
            {
                int small  = db.UseItems[10]?.Count ?? 0;
                int medium = db.UseItems[11]?.Count ?? 0;
                int large  = db.UseItems[12]?.Count ?? 0;

                ToolTipInfo.SetToolTip(FurnitureCoin,
                                       string.Format("(S) x {0} ( +{1} )\r\n(M) x {2} ( +{3} )\r\n(L) x {4} ( +{5} )\r\n",
                                                     small, small * 200,
                                                     medium, medium * 400,
                                                     large, large * 700));
            }
            UpdateDisplayUseItem();
            FlowPanelUseItem.ResumeLayout();


            //Resources
            FlowPanelResource.SuspendLayout();
            {
                Fuel.Text = db.Material.Fuel.ToString();

                if (db.Material.Fuel >= 300000)
                {
                    Fuel.ForeColor = configUI.Headquarters_ResourceMaxFG;
                    Fuel.BackColor = configUI.Headquarters_ResourceMaxBG;
                }
                else if (db.Material.Fuel < (configUI.HqResLowAlertFuel == -1 ? db.Admiral.MaxResourceRegenerationAmount : configUI.HqResLowAlertFuel))
                {
                    Fuel.ForeColor = configUI.Headquarters_ResourceLowFG;
                    Fuel.BackColor = configUI.Headquarters_ResourceLowBG;
                }
                else if (db.Material.Fuel > db.Admiral.MaxResourceRegenerationAmount)
                {
                    Fuel.ForeColor = configUI.Headquarters_ResourceOverFG;
                    Fuel.BackColor = configUI.Headquarters_ResourceOverBG;
                }
                else
                {
                    Fuel.ForeColor = configUI.ForeColor;
                    Fuel.BackColor = Color.Transparent;
                }
                ToolTipInfo.SetToolTip(Fuel, string.Format("Daily: {0:+##;-##;±0}\nWeekly: {1:+##;-##;±0}\nMonthly: {2:+##;-##;±0}",
                                                           resday == null ? 0 : (db.Material.Fuel - resday.Fuel),
                                                           resweek == null ? 0 : (db.Material.Fuel - resweek.Fuel),
                                                           resmonth == null ? 0 : (db.Material.Fuel - resmonth.Fuel)));

                Ammo.Text = db.Material.Ammo.ToString();
                if (db.Material.Ammo >= 300000)
                {
                    Ammo.ForeColor = configUI.Headquarters_ResourceMaxFG;
                    Ammo.BackColor = configUI.Headquarters_ResourceMaxBG;
                }
                else if (db.Material.Ammo < (configUI.HqResLowAlertAmmo == -1 ? db.Admiral.MaxResourceRegenerationAmount : configUI.HqResLowAlertAmmo))
                {
                    Ammo.ForeColor = configUI.Headquarters_ResourceLowFG;
                    Ammo.BackColor = configUI.Headquarters_ResourceLowBG;
                }
                else if (db.Material.Ammo > db.Admiral.MaxResourceRegenerationAmount)
                {
                    Ammo.ForeColor = configUI.Headquarters_ResourceOverFG;
                    Ammo.BackColor = configUI.Headquarters_ResourceOverBG;
                }
                else
                {
                    Ammo.ForeColor = configUI.ForeColor;
                    Ammo.BackColor = Color.Transparent;
                }
                ToolTipInfo.SetToolTip(Ammo, string.Format("Daily: {0:+##;-##;±0}\nWeekly: {1:+##;-##;±0}\nMonthly: {2:+##;-##;±0}",
                                                           resday == null ? 0 : (db.Material.Ammo - resday.Ammo),
                                                           resweek == null ? 0 : (db.Material.Ammo - resweek.Ammo),
                                                           resmonth == null ? 0 : (db.Material.Ammo - resmonth.Ammo)));

                Steel.Text = db.Material.Steel.ToString();
                if (db.Material.Steel >= 300000)
                {
                    Steel.ForeColor = configUI.Headquarters_ResourceMaxFG;
                    Steel.BackColor = configUI.Headquarters_ResourceMaxBG;
                }
                else if (db.Material.Steel < (configUI.HqResLowAlertSteel == -1 ? db.Admiral.MaxResourceRegenerationAmount : configUI.HqResLowAlertSteel))
                {
                    Steel.ForeColor = configUI.Headquarters_ResourceLowFG;
                    Steel.BackColor = configUI.Headquarters_ResourceLowBG;
                }
                else if (db.Material.Steel > db.Admiral.MaxResourceRegenerationAmount)
                {
                    Steel.ForeColor = configUI.Headquarters_ResourceOverFG;
                    Steel.BackColor = configUI.Headquarters_ResourceOverBG;
                }
                else
                {
                    Steel.ForeColor = configUI.ForeColor;
                    Steel.BackColor = Color.Transparent;
                }
                ToolTipInfo.SetToolTip(Steel, string.Format("Daily: {0:+##;-##;±0}\nWeekly: {1:+##;-##;±0}\nMonthly: {2:+##;-##;±0}",
                                                            resday == null ? 0 : (db.Material.Steel - resday.Steel),
                                                            resweek == null ? 0 : (db.Material.Steel - resweek.Steel),
                                                            resmonth == null ? 0 : (db.Material.Steel - resmonth.Steel)));

                Bauxite.Text = db.Material.Bauxite.ToString();
                if (db.Material.Bauxite >= 300000)
                {
                    Bauxite.ForeColor = configUI.Headquarters_ResourceMaxFG;
                    Bauxite.BackColor = configUI.Headquarters_ResourceMaxBG;
                }
                else if (db.Material.Bauxite < (configUI.HqResLowAlertBauxite == -1 ? db.Admiral.MaxResourceRegenerationAmount : configUI.HqResLowAlertBauxite))
                {
                    Bauxite.ForeColor = configUI.Headquarters_ResourceLowFG;
                    Bauxite.BackColor = configUI.Headquarters_ResourceLowBG;
                }
                else if (db.Material.Bauxite > db.Admiral.MaxResourceRegenerationAmount)
                {
                    Bauxite.ForeColor = configUI.Headquarters_ResourceOverFG;
                    Bauxite.BackColor = configUI.Headquarters_ResourceOverBG;
                }
                else
                {
                    Bauxite.ForeColor = configUI.ForeColor;
                    Bauxite.BackColor = Color.Transparent;
                }
                ToolTipInfo.SetToolTip(Bauxite, string.Format("Daily: {0:+##;-##;±0}\nWeekly: {1:+##;-##;±0}\nMonthly: {2:+##;-##;±0}",
                                                              resday == null ? 0 : (db.Material.Bauxite - resday.Bauxite),
                                                              resweek == null ? 0 : (db.Material.Bauxite - resweek.Bauxite),
                                                              resmonth == null ? 0 : (db.Material.Bauxite - resmonth.Bauxite)));
            }
            FlowPanelResource.ResumeLayout();

            FlowPanelMaster.ResumeLayout();
            if (!FlowPanelMaster.Visible)
            {
                FlowPanelMaster.Visible = true;
            }
            AdmiralName.Refresh();
            AdmiralComment.Refresh();
        }
        void Updated(string apiname, dynamic data)
        {
            KCDatabase db = KCDatabase.Instance;


            if (!db.Admiral.IsAvailable)
            {
                return;
            }


            // 資源上限超過時の色
            Color overcolor = Color.Moccasin;



            FlowPanelMaster.SuspendLayout();

            //Admiral
            FlowPanelAdmiral.SuspendLayout();
            AdmiralName.Text = string.Format("{0} {1}", db.Admiral.AdmiralName, Constants.GetAdmiralRank(db.Admiral.Rank));
            {
                StringBuilder tooltip = new StringBuilder();

                var sortieCount = db.Admiral.SortieWin + db.Admiral.SortieLose;
                tooltip.AppendFormat("出撃回数: {0} / 出撃勝利: {1} ({2:p2}) / 出撃敗北: {3}\r\n",
                                     sortieCount, db.Admiral.SortieWin, db.Admiral.SortieWin / Math.Max(sortieCount, 1.0), db.Admiral.SortieLose);

                tooltip.AppendFormat("出撃あたりの平均獲得Exp: {0:n2} / 勝利時 {1:n2}\r\n",
                                     db.Admiral.Exp / Math.Max(sortieCount, 1.0),
                                     db.Admiral.Exp / Math.Max(db.Admiral.SortieWin, 1.0));

                tooltip.AppendFormat("遠征回数: {0} / 遠征成功: {1} ({2:p2}) / 遠征失敗: {3}\r\n",
                                     db.Admiral.MissionCount, db.Admiral.MissionSuccess, db.Admiral.MissionSuccess / Math.Max(db.Admiral.MissionCount, 1.0), db.Admiral.MissionCount - db.Admiral.MissionSuccess);

                var practiceCount = db.Admiral.PracticeWin + db.Admiral.PracticeLose;
                tooltip.AppendFormat("演習回数: {0} / 演習勝利: {1} ({2:p2}) / 演習敗北: {3}\r\n",
                                     practiceCount, db.Admiral.PracticeWin, db.Admiral.PracticeWin / Math.Max(practiceCount, 1.0), db.Admiral.PracticeLose);

                tooltip.AppendFormat("甲種勲章保有数: {0}\r\n", db.Admiral.Medals);

                ToolTipInfo.SetToolTip(AdmiralName, tooltip.ToString());
            }
            AdmiralComment.Text = db.Admiral.Comment;
            FlowPanelAdmiral.ResumeLayout();

            //HQ Level
            HQLevel.Value = db.Admiral.Level;
            {
                StringBuilder tooltip = new StringBuilder();
                if (db.Admiral.Level < ExpTable.AdmiralExp.Max(e => e.Key))
                {
                    HQLevel.TextNext  = "next:";
                    HQLevel.ValueNext = ExpTable.GetNextExpAdmiral(db.Admiral.Exp);
                    tooltip.AppendFormat("{0} / {1}\r\n", db.Admiral.Exp, ExpTable.AdmiralExp[db.Admiral.Level + 1].Total);
                }
                else
                {
                    HQLevel.TextNext  = "exp:";
                    HQLevel.ValueNext = db.Admiral.Exp;
                }

                //戦果ツールチップ
                //fixme: もっとましな書き方はなかっただろうか
                {
                    var res = RecordManager.Instance.Resource.GetRecordPrevious();
                    if (res != null)
                    {
                        int diff = db.Admiral.Exp - res.HQExp;
                        tooltip.AppendFormat("今回: +{0} exp. / 戦果 {1:n2}\r\n", diff, diff * 7 / 10000.0);
                    }
                }
                {
                    var res = RecordManager.Instance.Resource.GetRecordDay();
                    if (res != null)
                    {
                        int diff = db.Admiral.Exp - res.HQExp;
                        tooltip.AppendFormat("今日: +{0} exp. / 戦果 {1:n2}\r\n", diff, diff * 7 / 10000.0);
                    }
                }
                {
                    var res = RecordManager.Instance.Resource.GetRecordMonth();
                    if (res != null)
                    {
                        int diff = db.Admiral.Exp - res.HQExp;
                        tooltip.AppendFormat("今月: +{0} exp. / 戦果 {1:n2}\r\n", diff, diff * 7 / 10000.0);
                    }
                }

                ToolTipInfo.SetToolTip(HQLevel, tooltip.ToString());
            }

            //Fleet
            FlowPanelFleet.SuspendLayout();
            {
                ShipCount.Text = string.Format("{0}/{1}", RealShipCount, db.Admiral.MaxShipCount);
                if (RealShipCount > db.Admiral.MaxShipCount - 5)
                {
                    ShipCount.BackColor = Color.LightCoral;
                }
                else
                {
                    ShipCount.BackColor = Color.Transparent;
                }
                ShipCount.Tag = RealShipCount >= db.Admiral.MaxShipCount;

                EquipmentCount.Text = string.Format("{0}/{1}", RealEquipmentCount, db.Admiral.MaxEquipmentCount);
                if (RealEquipmentCount > db.Admiral.MaxEquipmentCount + 3 - 20)
                {
                    EquipmentCount.BackColor = Color.LightCoral;
                }
                else
                {
                    EquipmentCount.BackColor = Color.Transparent;
                }
                EquipmentCount.Tag = RealEquipmentCount >= db.Admiral.MaxEquipmentCount;
            }
            FlowPanelFleet.ResumeLayout();



            var resday   = RecordManager.Instance.Resource.GetRecord(DateTime.Now.AddHours(-5).Date.AddHours(5));
            var resweek  = RecordManager.Instance.Resource.GetRecord(DateTime.Now.AddHours(-5).Date.AddDays(-(((int)DateTime.Now.AddHours(-5).DayOfWeek + 6) % 7)).AddHours(5));            //月曜日起点
            var resmonth = RecordManager.Instance.Resource.GetRecord(new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddHours(5));


            //UseItems
            FlowPanelUseItem.SuspendLayout();

            InstantRepair.Text      = db.Material.InstantRepair.ToString();
            InstantRepair.BackColor = db.Material.InstantRepair >= 3000 ? overcolor : Color.Transparent;
            ToolTipInfo.SetToolTip(InstantRepair, string.Format("今日: {0:+##;-##;±0}\n今週: {1:+##;-##;±0}\n今月: {2:+##;-##;±0}",
                                                                resday == null ? 0 : (db.Material.InstantRepair - resday.InstantRepair),
                                                                resweek == null ? 0 : (db.Material.InstantRepair - resweek.InstantRepair),
                                                                resmonth == null ? 0 : (db.Material.InstantRepair - resmonth.InstantRepair)));

            InstantConstruction.Text      = db.Material.InstantConstruction.ToString();
            InstantConstruction.BackColor = db.Material.InstantConstruction >= 3000 ? overcolor : Color.Transparent;
            ToolTipInfo.SetToolTip(InstantConstruction, string.Format("今日: {0:+##;-##;±0}\n今週: {1:+##;-##;±0}\n今月: {2:+##;-##;±0}",
                                                                      resday == null ? 0 : (db.Material.InstantConstruction - resday.InstantConstruction),
                                                                      resweek == null ? 0 : (db.Material.InstantConstruction - resweek.InstantConstruction),
                                                                      resmonth == null ? 0 : (db.Material.InstantConstruction - resmonth.InstantConstruction)));

            DevelopmentMaterial.Text      = db.Material.DevelopmentMaterial.ToString();
            DevelopmentMaterial.BackColor = db.Material.DevelopmentMaterial >= 3000 ? overcolor : Color.Transparent;
            ToolTipInfo.SetToolTip(DevelopmentMaterial, string.Format("今日: {0:+##;-##;±0}\n今週: {1:+##;-##;±0}\n今月: {2:+##;-##;±0}",
                                                                      resday == null ? 0 : (db.Material.DevelopmentMaterial - resday.DevelopmentMaterial),
                                                                      resweek == null ? 0 : (db.Material.DevelopmentMaterial - resweek.DevelopmentMaterial),
                                                                      resmonth == null ? 0 : (db.Material.DevelopmentMaterial - resmonth.DevelopmentMaterial)));

            ModdingMaterial.Text      = db.Material.ModdingMaterial.ToString();
            ModdingMaterial.BackColor = db.Material.ModdingMaterial >= 3000 ? overcolor : Color.Transparent;
            ToolTipInfo.SetToolTip(ModdingMaterial, string.Format("今日: {0:+##;-##;±0}\n今週: {1:+##;-##;±0}\n今月: {2:+##;-##;±0}",
                                                                  resday == null ? 0 : (db.Material.ModdingMaterial - resday.ModdingMaterial),
                                                                  resweek == null ? 0 : (db.Material.ModdingMaterial - resweek.ModdingMaterial),
                                                                  resmonth == null ? 0 : (db.Material.ModdingMaterial - resmonth.ModdingMaterial)));

            FurnitureCoin.Text      = db.Admiral.FurnitureCoin.ToString();
            FurnitureCoin.BackColor = db.Admiral.FurnitureCoin >= 200000 ? overcolor : Color.Transparent;
            {
                int small  = db.UseItems[10]?.Count ?? 0;
                int medium = db.UseItems[11]?.Count ?? 0;
                int large  = db.UseItems[12]?.Count ?? 0;

                ToolTipInfo.SetToolTip(FurnitureCoin,
                                       string.Format("(小) x {0} ( +{1} )\r\n(中) x {2} ( +{3} )\r\n(大) x {4} ( +{5} )\r\n",
                                                     small, small * 200,
                                                     medium, medium * 400,
                                                     large, large * 700));
            }
            UpdateDisplayUseItem();
            FlowPanelUseItem.ResumeLayout();


            //Resources
            FlowPanelResource.SuspendLayout();
            {
                Fuel.Text      = db.Material.Fuel.ToString();
                Fuel.BackColor = db.Material.Fuel < db.Admiral.MaxResourceRegenerationAmount ? Color.Transparent : overcolor;
                ToolTipInfo.SetToolTip(Fuel, string.Format("今日: {0:+##;-##;±0}\n今週: {1:+##;-##;±0}\n今月: {2:+##;-##;±0}",
                                                           resday == null ? 0 : (db.Material.Fuel - resday.Fuel),
                                                           resweek == null ? 0 : (db.Material.Fuel - resweek.Fuel),
                                                           resmonth == null ? 0 : (db.Material.Fuel - resmonth.Fuel)));

                Ammo.Text      = db.Material.Ammo.ToString();
                Ammo.BackColor = db.Material.Ammo < db.Admiral.MaxResourceRegenerationAmount ? Color.Transparent : overcolor;
                ToolTipInfo.SetToolTip(Ammo, string.Format("今日: {0:+##;-##;±0}\n今週: {1:+##;-##;±0}\n今月: {2:+##;-##;±0}",
                                                           resday == null ? 0 : (db.Material.Ammo - resday.Ammo),
                                                           resweek == null ? 0 : (db.Material.Ammo - resweek.Ammo),
                                                           resmonth == null ? 0 : (db.Material.Ammo - resmonth.Ammo)));

                Steel.Text      = db.Material.Steel.ToString();
                Steel.BackColor = db.Material.Steel < db.Admiral.MaxResourceRegenerationAmount ? Color.Transparent : overcolor;
                ToolTipInfo.SetToolTip(Steel, string.Format("今日: {0:+##;-##;±0}\n今週: {1:+##;-##;±0}\n今月: {2:+##;-##;±0}",
                                                            resday == null ? 0 : (db.Material.Steel - resday.Steel),
                                                            resweek == null ? 0 : (db.Material.Steel - resweek.Steel),
                                                            resmonth == null ? 0 : (db.Material.Steel - resmonth.Steel)));

                Bauxite.Text      = db.Material.Bauxite.ToString();
                Bauxite.BackColor = db.Material.Bauxite < db.Admiral.MaxResourceRegenerationAmount ? Color.Transparent : overcolor;
                ToolTipInfo.SetToolTip(Bauxite, string.Format("今日: {0:+##;-##;±0}\n今週: {1:+##;-##;±0}\n今月: {2:+##;-##;±0}",
                                                              resday == null ? 0 : (db.Material.Bauxite - resday.Bauxite),
                                                              resweek == null ? 0 : (db.Material.Bauxite - resweek.Bauxite),
                                                              resmonth == null ? 0 : (db.Material.Bauxite - resmonth.Bauxite)));
            }
            FlowPanelResource.ResumeLayout();

            FlowPanelMaster.ResumeLayout();
            if (!FlowPanelMaster.Visible)
            {
                FlowPanelMaster.Visible = true;
            }
            AdmiralName.Refresh();
            AdmiralComment.Refresh();
        }
Пример #14
0
        void Updated(string apiname, dynamic data)
        {
            KCDatabase db = KCDatabase.Instance;


            FlowPanelMaster.SuspendLayout();

            //Admiral
            FlowPanelAdmiral.SuspendLayout();
            AdmiralName.Text    = string.Format("{0} {1}", db.Admiral.AdmiralName, Constants.GetAdmiralRank(db.Admiral.Rank));
            AdmiralComment.Text = db.Admiral.Comment;
            FlowPanelAdmiral.ResumeLayout();

            //HQ Level
            HQLevel.Value = db.Admiral.Level;
            {
                StringBuilder tooltip = new StringBuilder();
                if (db.Admiral.Level < ExpTable.AdmiralExp.Max(e => e.Key))
                {
                    HQLevel.TextNext  = "next:";
                    HQLevel.ValueNext = ExpTable.GetNextExpAdmiral(db.Admiral.Exp);
                    tooltip.AppendFormat("{0} / {1}\r\n", db.Admiral.Exp, ExpTable.AdmiralExp[db.Admiral.Level + 1].Total);
                }
                else
                {
                    HQLevel.TextNext  = "exp:";
                    HQLevel.ValueNext = db.Admiral.Exp;
                }

                //戦果ツールチップ
                //fixme: もっとましな書き方はなかっただろうか
                {
                    var res = RecordManager.Instance.Resource.GetRecordPrevious();
                    if (res != null)
                    {
                        int diff = db.Admiral.Exp - res.HQExp;
                        tooltip.AppendFormat("前回: +{0} exp. / 戦果 {1:n2}\r\n", diff, diff * 7 / 10000.0);
                    }
                }
                {
                    var res = RecordManager.Instance.Resource.GetRecordDay();
                    if (res != null)
                    {
                        int diff = db.Admiral.Exp - res.HQExp;
                        tooltip.AppendFormat("今日: +{0} exp. / 戦果 {1:n2}\r\n", diff, diff * 7 / 10000.0);
                    }
                }
                {
                    var res = RecordManager.Instance.Resource.GetRecordMonth();
                    if (res != null)
                    {
                        int diff = db.Admiral.Exp - res.HQExp;
                        tooltip.AppendFormat("今月: +{0} exp. / 戦果 {1:n2}\r\n", diff, diff * 7 / 10000.0);
                    }
                }

                ToolTipInfo.SetToolTip(HQLevel, tooltip.ToString());
            }

            //Fleet
            FlowPanelFleet.SuspendLayout();
            ShipCount.Text = string.Format("{0}/{1}", db.Ships.Count, db.Admiral.MaxShipCount);
            if (db.Ships.Count > db.Admiral.MaxShipCount - 5)
            {
                ShipCount.BackColor = Color.LightCoral;
            }
            else
            {
                ShipCount.BackColor = Color.Transparent;
            }

            EquipmentCount.Text = string.Format("{0}/{1}", db.Equipments.Count, db.Admiral.MaxEquipmentCount);
            if (db.Equipments.Count > db.Admiral.MaxEquipmentCount + 3 - 20)
            {
                EquipmentCount.BackColor = Color.LightCoral;
            }
            else
            {
                EquipmentCount.BackColor = Color.Transparent;
            }
            FlowPanelFleet.ResumeLayout();

            //UseItems
            FlowPanelUseItem.SuspendLayout();
            InstantRepair.Text       = db.Material.InstantRepair.ToString();
            InstantConstruction.Text = db.Material.InstantConstruction.ToString();
            DevelopmentMaterial.Text = db.Material.DevelopmentMaterial.ToString();
            ModdingMaterial.Text     = db.Material.ModdingMaterial.ToString();
            FurnitureCoin.Text       = db.Admiral.FurnitureCoin.ToString();
            FlowPanelUseItem.ResumeLayout();


            //Resources
            FlowPanelResource.SuspendLayout();
            {
                Color overcolor = Color.Moccasin;
                Fuel.Text      = db.Material.Fuel.ToString();
                Fuel.BackColor = db.Material.Fuel < db.Admiral.MaxResourceRegenerationAmount ? Color.Transparent : overcolor;

                Ammo.Text      = db.Material.Ammo.ToString();
                Ammo.BackColor = db.Material.Ammo < db.Admiral.MaxResourceRegenerationAmount ? Color.Transparent : overcolor;

                Steel.Text      = db.Material.Steel.ToString();
                Steel.BackColor = db.Material.Steel < db.Admiral.MaxResourceRegenerationAmount ? Color.Transparent : overcolor;

                Bauxite.Text      = db.Material.Bauxite.ToString();
                Bauxite.BackColor = db.Material.Bauxite < db.Admiral.MaxResourceRegenerationAmount ? Color.Transparent : overcolor;
            }
            FlowPanelResource.ResumeLayout();

            FlowPanelMaster.ResumeLayout();
            if (!FlowPanelMaster.Visible)
            {
                FlowPanelMaster.Visible = true;
            }
            AdmiralName.Refresh();
            AdmiralComment.Refresh();
        }
Пример #15
0
        void Updated(string apiname, dynamic data)
        {
            KCDatabase db = KCDatabase.Instance;

            var configUI = Utility.Configuration.Config.UI;

            if (!db.Admiral.IsAvailable)
            {
                return;
            }

            FlowPanelMaster.SuspendLayout();

            //Admiral
            FlowPanelAdmiral.SuspendLayout();
            AdmiralName.Text    = string.Format("{0} {1}", db.Admiral.AdmiralName, Constants.GetAdmiralRank(db.Admiral.Rank));
            AdmiralComment.Text = db.Admiral.Comment;
            FlowPanelAdmiral.ResumeLayout();

            //HQ Level
            DateTime nowJST = DateTime.UtcNow.AddHours(9);

            HQLevel.Value = db.Admiral.Level;
            {
                StringBuilder tooltip = new StringBuilder();
                bool          showRankingPointsTooltip = true;
                if (Utility.Configuration.Config.UI.ShowGrowthInsteadOfNextInHQ)
                {
                    HQLevel.TextNext = "Growth:";
                    int exp1 = RecordManager.Instance.Resource.GetExpHalfDay(nowJST);
                    if (exp1 == -2013)                       // 年末战果黑洞期,显示全年
                    {
                        HQLevel.TextNext      = string.Format("{0} :", nowJST.Year);
                        HQLevel.TextValueNext = String.Format("{0:n2}", RecordManager.Instance.Resource.GetExpYear(nowJST.Year) * 7 / 10000.0);
                        goto BuildToolTip;
                    }
                    int exp2 = RecordManager.Instance.Resource.GetExpDay(nowJST);
                    if (exp1 >= 0 && exp2 >= 0)
                    {
                        HQLevel.TextValueNext = String.Format(
                            "{0:n2} / {1:n2}",
                            exp1 * 7 / 10000.0,
                            exp2 * 7 / 10000.0
                            );
                    }
                    else
                    {
                        HQLevel.TextValueNext    = "N/A";
                        showRankingPointsTooltip = false;
                    }
                }
                else
                {
                    if (db.Admiral.Level < ExpTable.AdmiralExp.Max(e => e.Key))
                    {
                        HQLevel.TextNext  = "next:";
                        HQLevel.ValueNext = ExpTable.GetNextExpAdmiral(db.Admiral.Exp);
                    }
                    else
                    {
                        HQLevel.TextNext  = "exp:";
                        HQLevel.ValueNext = db.Admiral.Exp;
                    }
                }

                //戦果ツールチップ
BuildToolTip:
                StringBuilder tooltipAppend = new StringBuilder();

                tooltip.AppendFormat("提督经验 : {0:n0}\r\n", db.Admiral.Exp);
                if (db.Admiral.Level < ExpTable.AdmiralExp.Max(e => e.Key))
                {
                    tooltip.AppendFormat("距离升级 : {0:n0} ( 进度 {1:0.00%} )\r\n", ExpTable.GetNextExpAdmiral(db.Admiral.Exp), db.Admiral.Exp / (float)ExpTable.AdmiralExp[db.Admiral.Level + 1].Total);
                }
                else if (db.Admiral.Exp < 180000000)
                {
                    tooltip.AppendFormat("距离上限 : {0:n0} ( 进度 {1:0.00%} )\r\n", 180000000 - db.Admiral.Exp, db.Admiral.Exp / 180000000f);
                }
                else
                {
                    tooltip.AppendFormat("( 已达到经验值上限 )\r\n");
                    showRankingPointsTooltip = false;
                }

                if (showRankingPointsTooltip)
                {
                    int    diff = RecordManager.Instance.Resource.GetExpHalfDay(nowJST, true);
                    double rankingPointsPreviousHalfDay = diff * 7 / 10000.0;
                    tooltipAppend.AppendFormat("半日 : {0:n2}\t( {1} )\r\n", rankingPointsPreviousHalfDay, RecordManager.Instance.Resource.RankingPeriodString);
                    diff = RecordManager.Instance.Resource.GetExpDay(nowJST, true);
                    double rankingPointsPreviousDay = diff * 7 / 10000.0;
                    tooltipAppend.AppendFormat("单日 : {0:n2}\t( {1} )\r\n", rankingPointsPreviousDay, RecordManager.Instance.Resource.RankingPeriodString);
                    diff = RecordManager.Instance.Resource.GetExpMonth(nowJST, true);
                    double rankingPointsPreviousMonth = diff * 7 / 10000.0;
                    tooltipAppend.AppendFormat("单月 : {0:n2}\t( {1} )\r\n", rankingPointsPreviousMonth, RecordManager.Instance.Resource.RankingPeriodString);

                    diff = RecordManager.Instance.Resource.GetExpHalfDay(nowJST);
                    if (diff == -2013)
                    {
                        TimeSpan timeZoneOffset = DateTimeOffset.Now.Offset - new TimeSpan(9, 0, 0);
                        DateTime ends           = new DateTime(nowJST.Year, 12, 31, 0, 0, 0).AddDays(1) + timeZoneOffset;
                        tooltip.AppendFormat("\r\n{0} 年末战果黑洞期 ( ~ {1} )\r\n", nowJST.Year, ends.ToString("yyyy'/'M'/'d HH':'mm"));
                        tooltip.Append(tooltipAppend.ToString());
                        diff = RecordManager.Instance.Resource.GetExpYear(nowJST.Year);
                        double rankingPointsYear = diff * 7 / 10000.0;
                        tooltip.AppendFormat("全年 : {0:n2}\t( {1} )\r\n", rankingPointsYear, RecordManager.Instance.Resource.RankingPeriodString);
                    }
                    else
                    {
                        tooltip.AppendFormat("\r\n{0}\r\n", RecordManager.Instance.Resource.MonthString);
                        double rankingPointsHalfDay = diff * 7 / 10000.0;
                        tooltip.AppendFormat("半日 : {0:n2}\t( {1} )\r\n", rankingPointsHalfDay, RecordManager.Instance.Resource.RankingPeriodString, rankingPointsHalfDay - rankingPointsPreviousHalfDay);
                        diff = RecordManager.Instance.Resource.GetExpDay(nowJST);
                        double rankingPointsDay = diff * 7 / 10000.0;
                        tooltip.AppendFormat("今日 : {0:n2}\t( {1} )\r\n", rankingPointsDay, RecordManager.Instance.Resource.RankingPeriodString, rankingPointsDay - rankingPointsPreviousDay);
                        diff = RecordManager.Instance.Resource.GetExpMonth(nowJST);
                        double rankingPointsMonth = diff * 7 / 10000.0;
                        tooltip.AppendFormat("本月 : {0:n2}\t( {1} )\r\n", rankingPointsMonth, RecordManager.Instance.Resource.RankingPeriodString, rankingPointsMonth - rankingPointsPreviousMonth);

                        tooltip.Append("\r\n上次结算战果\r\n");
                        tooltip.Append(tooltipAppend.ToString());
                    }
                }

                ToolTipInfo.SetToolTip(HQLevel, tooltip.ToString());
            }

            //Fleet
            FlowPanelFleet.SuspendLayout();
            {
                ShipCount.Text = string.Format("{0}/{1}", RealShipCount, db.Admiral.MaxShipCount);
                if (RealShipCount > db.Admiral.MaxShipCount - 5)
                {
                    ShipCount.BackColor = Utility.Configuration.Config.UI.Headquarters_ShipCountOverBG;
                    ShipCount.ForeColor = Utility.Configuration.Config.UI.Headquarters_ShipCountOverFG;
                }
                else
                {
                    ShipCount.BackColor = Color.Transparent;
                    ShipCount.ForeColor = Utility.Configuration.Config.UI.ForeColor;
                }
                ShipCount.Tag = RealShipCount >= db.Admiral.MaxShipCount;

                EquipmentCount.Text = string.Format("{0}/{1}", RealEquipmentCount, db.Admiral.MaxEquipmentCount);
                if (RealEquipmentCount > db.Admiral.MaxEquipmentCount + 3 - 20)
                {
                    EquipmentCount.BackColor = Utility.Configuration.Config.UI.Headquarters_ShipCountOverBG;
                    EquipmentCount.ForeColor = Utility.Configuration.Config.UI.Headquarters_ShipCountOverFG;
                }
                else
                {
                    EquipmentCount.BackColor = Color.Transparent;
                    EquipmentCount.ForeColor = Utility.Configuration.Config.UI.ForeColor;
                }
                EquipmentCount.Tag = RealEquipmentCount >= db.Admiral.MaxEquipmentCount;
            }
            FlowPanelFleet.ResumeLayout();



            var resday   = RecordManager.Instance.Resource.GetRecord(DateTime.Now.AddHours(-5).Date.AddHours(5));
            var resweek  = RecordManager.Instance.Resource.GetRecord(DateTime.Now.AddHours(-5).Date.AddDays(-(((int)DateTime.Now.AddHours(-5).DayOfWeek + 6) % 7)).AddHours(5));            //月曜日起点
            var resmonth = RecordManager.Instance.Resource.GetRecord(new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddHours(5));


            //UseItems
            FlowPanelUseItem.SuspendLayout();

            InstantRepair.Text = db.Material.InstantRepair.ToString();
            if (db.Material.InstantRepair >= 3000)
            {
                InstantRepair.ForeColor = configUI.Headquarters_MaterialMaxFG;
                InstantRepair.BackColor = configUI.Headquarters_MaterialMaxBG;
            }
            else if (db.Material.InstantRepair < (configUI.HqResLowAlertBucket == -1 ? db.Admiral.MaxResourceRegenerationAmount : configUI.HqResLowAlertBucket))
            {
                InstantRepair.ForeColor = configUI.Headquarters_ResourceLowFG;
                InstantRepair.BackColor = configUI.Headquarters_ResourceLowBG;
            }
            else
            {
                InstantRepair.ForeColor = configUI.ForeColor;
                InstantRepair.BackColor = Color.Transparent;
            }
            ToolTipInfo.SetToolTip(InstantRepair, string.Format("今日 : {0:+##;-##;±0}\n本周 : {1:+##;-##;±0}\n本月 : {2:+##;-##;±0}",
                                                                resday == null ? 0 : (db.Material.InstantRepair - resday.InstantRepair),
                                                                resweek == null ? 0 : (db.Material.InstantRepair - resweek.InstantRepair),
                                                                resmonth == null ? 0 : (db.Material.InstantRepair - resmonth.InstantRepair)));

            InstantConstruction.Text = db.Material.InstantConstruction.ToString();
            if (db.Material.InstantConstruction >= 3000)
            {
                InstantConstruction.ForeColor = configUI.Headquarters_MaterialMaxFG;
                InstantConstruction.BackColor = configUI.Headquarters_MaterialMaxBG;
            }
            else
            {
                InstantConstruction.ForeColor = configUI.ForeColor;
                InstantConstruction.BackColor = Color.Transparent;
            }
            ToolTipInfo.SetToolTip(InstantConstruction, string.Format("今日 : {0:+##;-##;±0}\n本周 : {1:+##;-##;±0}\n本月 : {2:+##;-##;±0}",
                                                                      resday == null ? 0 : (db.Material.InstantConstruction - resday.InstantConstruction),
                                                                      resweek == null ? 0 : (db.Material.InstantConstruction - resweek.InstantConstruction),
                                                                      resmonth == null ? 0 : (db.Material.InstantConstruction - resmonth.InstantConstruction)));

            DevelopmentMaterial.Text = db.Material.DevelopmentMaterial.ToString();
            if (db.Material.DevelopmentMaterial >= 3000)
            {
                DevelopmentMaterial.ForeColor = configUI.Headquarters_MaterialMaxFG;
                DevelopmentMaterial.BackColor = configUI.Headquarters_MaterialMaxBG;
            }
            else
            {
                DevelopmentMaterial.ForeColor = configUI.ForeColor;
                DevelopmentMaterial.BackColor = Color.Transparent;
            }
            ToolTipInfo.SetToolTip(DevelopmentMaterial, string.Format("今日 : {0:+##;-##;±0}\n本周 : {1:+##;-##;±0}\n本月 : {2:+##;-##;±0}",
                                                                      resday == null ? 0 : (db.Material.DevelopmentMaterial - resday.DevelopmentMaterial),
                                                                      resweek == null ? 0 : (db.Material.DevelopmentMaterial - resweek.DevelopmentMaterial),
                                                                      resmonth == null ? 0 : (db.Material.DevelopmentMaterial - resmonth.DevelopmentMaterial)));

            ModdingMaterial.Text = db.Material.ModdingMaterial.ToString();
            if (db.Material.ModdingMaterial >= 3000)
            {
                ModdingMaterial.ForeColor = configUI.Headquarters_MaterialMaxFG;
                ModdingMaterial.BackColor = configUI.Headquarters_MaterialMaxBG;
            }
            else
            {
                ModdingMaterial.ForeColor = configUI.ForeColor;
                ModdingMaterial.BackColor = Color.Transparent;
            }
            ToolTipInfo.SetToolTip(ModdingMaterial, string.Format("今日 : {0:+##;-##;±0}\n本周 : {1:+##;-##;±0}\n本月 : {2:+##;-##;±0}",
                                                                  resday == null ? 0 : (db.Material.ModdingMaterial - resday.ModdingMaterial),
                                                                  resweek == null ? 0 : (db.Material.ModdingMaterial - resweek.ModdingMaterial),
                                                                  resmonth == null ? 0 : (db.Material.ModdingMaterial - resmonth.ModdingMaterial)));

            FurnitureCoin.Text = db.Admiral.FurnitureCoin.ToString();
            if (db.Admiral.FurnitureCoin >= 200000)
            {
                FurnitureCoin.ForeColor = configUI.Headquarters_CoinMaxFG;
                FurnitureCoin.BackColor = configUI.Headquarters_CoinMaxBG;
            }
            else
            {
                FurnitureCoin.ForeColor = configUI.ForeColor;
                FurnitureCoin.BackColor = Color.Transparent;
            }
            {
                int small  = db.UseItems[10]?.Count ?? 0;
                int medium = db.UseItems[11]?.Count ?? 0;
                int large  = db.UseItems[12]?.Count ?? 0;

                ToolTipInfo.SetToolTip(FurnitureCoin,
                                       string.Format("(小) x {0} ( +{1} )\r\n(中) x {2} ( +{3} )\r\n(大) x {4} ( +{5} )\r\n",
                                                     small, small * 200,
                                                     medium, medium * 400,
                                                     large, large * 700));
            }
            UpdateDisplayUseItem();
            FlowPanelUseItem.ResumeLayout();


            //Resources
            FlowPanelResource.SuspendLayout();
            {
                Fuel.Text = db.Material.Fuel.ToString();

                if (db.Material.Fuel >= 300000)
                {
                    Fuel.ForeColor = configUI.Headquarters_ResourceMaxFG;
                    Fuel.BackColor = configUI.Headquarters_ResourceMaxBG;
                }
                else if (db.Material.Fuel < (configUI.HqResLowAlertFuel == -1 ? db.Admiral.MaxResourceRegenerationAmount : configUI.HqResLowAlertFuel))
                {
                    Fuel.ForeColor = configUI.Headquarters_ResourceLowFG;
                    Fuel.BackColor = configUI.Headquarters_ResourceLowBG;
                }
                else if (db.Material.Fuel > db.Admiral.MaxResourceRegenerationAmount)
                {
                    Fuel.ForeColor = configUI.Headquarters_ResourceOverFG;
                    Fuel.BackColor = configUI.Headquarters_ResourceOverBG;
                }
                else
                {
                    Fuel.ForeColor = configUI.ForeColor;
                    Fuel.BackColor = Color.Transparent;
                }
                ToolTipInfo.SetToolTip(Fuel, string.Format("今日 : {0:+##;-##;±0}\n本周 : {1:+##;-##;±0}\n本月 : {2:+##;-##;±0}",
                                                           resday == null ? 0 : (db.Material.Fuel - resday.Fuel),
                                                           resweek == null ? 0 : (db.Material.Fuel - resweek.Fuel),
                                                           resmonth == null ? 0 : (db.Material.Fuel - resmonth.Fuel)));

                Ammo.Text = db.Material.Ammo.ToString();
                if (db.Material.Ammo >= 300000)
                {
                    Ammo.ForeColor = configUI.Headquarters_ResourceMaxFG;
                    Ammo.BackColor = configUI.Headquarters_ResourceMaxBG;
                }
                else if (db.Material.Ammo < (configUI.HqResLowAlertAmmo == -1 ? db.Admiral.MaxResourceRegenerationAmount : configUI.HqResLowAlertAmmo))
                {
                    Ammo.ForeColor = configUI.Headquarters_ResourceLowFG;
                    Ammo.BackColor = configUI.Headquarters_ResourceLowBG;
                }
                else if (db.Material.Ammo > db.Admiral.MaxResourceRegenerationAmount)
                {
                    Ammo.ForeColor = configUI.Headquarters_ResourceOverFG;
                    Ammo.BackColor = configUI.Headquarters_ResourceOverBG;
                }
                else
                {
                    Ammo.ForeColor = configUI.ForeColor;
                    Ammo.BackColor = Color.Transparent;
                }
                ToolTipInfo.SetToolTip(Ammo, string.Format("今日 : {0:+##;-##;±0}\n本周 : {1:+##;-##;±0}\n本月 : {2:+##;-##;±0}",
                                                           resday == null ? 0 : (db.Material.Ammo - resday.Ammo),
                                                           resweek == null ? 0 : (db.Material.Ammo - resweek.Ammo),
                                                           resmonth == null ? 0 : (db.Material.Ammo - resmonth.Ammo)));

                Steel.Text = db.Material.Steel.ToString();
                if (db.Material.Steel >= 300000)
                {
                    Steel.ForeColor = configUI.Headquarters_ResourceMaxFG;
                    Steel.BackColor = configUI.Headquarters_ResourceMaxBG;
                }
                else if (db.Material.Steel < (configUI.HqResLowAlertSteel == -1 ? db.Admiral.MaxResourceRegenerationAmount : configUI.HqResLowAlertSteel))
                {
                    Steel.ForeColor = configUI.Headquarters_ResourceLowFG;
                    Steel.BackColor = configUI.Headquarters_ResourceLowBG;
                }
                else if (db.Material.Steel > db.Admiral.MaxResourceRegenerationAmount)
                {
                    Steel.ForeColor = configUI.Headquarters_ResourceOverFG;
                    Steel.BackColor = configUI.Headquarters_ResourceOverBG;
                }
                else
                {
                    Steel.ForeColor = configUI.ForeColor;
                    Steel.BackColor = Color.Transparent;
                }
                ToolTipInfo.SetToolTip(Steel, string.Format("今日 : {0:+##;-##;±0}\n本周 : {1:+##;-##;±0}\n本月 : {2:+##;-##;±0}",
                                                            resday == null ? 0 : (db.Material.Steel - resday.Steel),
                                                            resweek == null ? 0 : (db.Material.Steel - resweek.Steel),
                                                            resmonth == null ? 0 : (db.Material.Steel - resmonth.Steel)));

                Bauxite.Text = db.Material.Bauxite.ToString();
                if (db.Material.Bauxite >= 300000)
                {
                    Bauxite.ForeColor = configUI.Headquarters_ResourceMaxFG;
                    Bauxite.BackColor = configUI.Headquarters_ResourceMaxBG;
                }
                else if (db.Material.Bauxite < (configUI.HqResLowAlertBauxite == -1 ? db.Admiral.MaxResourceRegenerationAmount : configUI.HqResLowAlertBauxite))
                {
                    Bauxite.ForeColor = configUI.Headquarters_ResourceLowFG;
                    Bauxite.BackColor = configUI.Headquarters_ResourceLowBG;
                }
                else if (db.Material.Bauxite > db.Admiral.MaxResourceRegenerationAmount)
                {
                    Bauxite.ForeColor = configUI.Headquarters_ResourceOverFG;
                    Bauxite.BackColor = configUI.Headquarters_ResourceOverBG;
                }
                else
                {
                    Bauxite.ForeColor = configUI.ForeColor;
                    Bauxite.BackColor = Color.Transparent;
                }
                ToolTipInfo.SetToolTip(Bauxite, string.Format("今日 : {0:+##;-##;±0}\n本周 : {1:+##;-##;±0}\n本月 : {2:+##;-##;±0}",
                                                              resday == null ? 0 : (db.Material.Bauxite - resday.Bauxite),
                                                              resweek == null ? 0 : (db.Material.Bauxite - resweek.Bauxite),
                                                              resmonth == null ? 0 : (db.Material.Bauxite - resmonth.Bauxite)));
            }
            FlowPanelResource.ResumeLayout();

            FlowPanelMaster.ResumeLayout();
            if (!FlowPanelMaster.Visible)
            {
                FlowPanelMaster.Visible = true;
            }
            AdmiralName.Refresh();
            AdmiralComment.Refresh();
        }
        void Updated(string apiname, dynamic data)
        {
            KCDatabase db = KCDatabase.Instance;


            FlowPanelMaster.SuspendLayout();

            //Admiral
            FlowPanelAdmiral.SuspendLayout();
            AdmiralName.Text    = string.Format("{0} {1}", db.Admiral.AdmiralName, Constants.GetAdmiralRank(db.Admiral.Rank));
            AdmiralComment.Text = db.Admiral.Comment;
            FlowPanelAdmiral.ResumeLayout();

            //HQ Level
            HQLevel.Value = db.Admiral.Level;
            {
                StringBuilder tooltip = new StringBuilder();
                if (db.Admiral.Level < ExpTable.AdmiralExp.Max(e => e.Key))
                {
                    HQLevel.TextNext  = "next:";
                    HQLevel.ValueNext = ExpTable.GetNextExpAdmiral(db.Admiral.Exp);
                    tooltip.AppendFormat("{0} / {1}\r\n", db.Admiral.Exp, ExpTable.AdmiralExp[db.Admiral.Level + 1].Total);
                }
                else
                {
                    HQLevel.TextNext  = "exp:";
                    HQLevel.ValueNext = db.Admiral.Exp;
                }

                //戦果ツールチップ
                //fixme: もっとましな書き方はなかっただろうか
                {
                    var res = RecordManager.Instance.Resource.GetRecordPrevious();
                    if (res != null)
                    {
                        int diff = db.Admiral.Exp - res.HQExp;
                        tooltip.AppendFormat(GeneralRes.ThisTime + ": +{0} exp. / " + GeneralRes.RankPoints + " {1:n2}\r\n", diff, diff * 7 / 10000.0);
                    }
                }
                {
                    var res = RecordManager.Instance.Resource.GetRecordDay();
                    if (res != null)
                    {
                        int diff = db.Admiral.Exp - res.HQExp;
                        tooltip.AppendFormat(GeneralRes.Today + ": +{0} exp. / " + GeneralRes.RankPoints + " {1:n2}\r\n", diff, diff * 7 / 10000.0);
                    }
                }
                {
                    var res = RecordManager.Instance.Resource.GetRecordMonth();
                    if (res != null)
                    {
                        int diff = db.Admiral.Exp - res.HQExp;
                        tooltip.AppendFormat(GeneralRes.ThisMonth + ": +{0} exp. / " + GeneralRes.RankPoints + " {1:n2}\r\n", diff, diff * 7 / 10000.0);
                    }
                }

                ToolTipInfo.SetToolTip(HQLevel, tooltip.ToString());
            }

            //Fleet
            FlowPanelFleet.SuspendLayout();
            {
                ShipCount.Text = string.Format("{0}/{1}", RealShipCount, db.Admiral.MaxShipCount);
                if (RealShipCount > db.Admiral.MaxShipCount - 5)
                {
                    ShipCount.BackColor = Color.LightCoral;
                }
                else
                {
                    ShipCount.BackColor = Color.Transparent;
                }
                ShipCount.Tag = RealShipCount >= db.Admiral.MaxShipCount;

                EquipmentCount.Text = string.Format("{0}/{1}", RealEquipmentCount, db.Admiral.MaxEquipmentCount);
                if (RealEquipmentCount > db.Admiral.MaxEquipmentCount + 3 - 20)
                {
                    EquipmentCount.BackColor = Color.LightCoral;
                }
                else
                {
                    EquipmentCount.BackColor = Color.Transparent;
                }
                EquipmentCount.Tag = RealEquipmentCount >= db.Admiral.MaxEquipmentCount;
            }
            FlowPanelFleet.ResumeLayout();

            //UseItems
            FlowPanelUseItem.SuspendLayout();
            InstantRepair.Text       = db.Material.InstantRepair.ToString();
            InstantConstruction.Text = db.Material.InstantConstruction.ToString();
            DevelopmentMaterial.Text = db.Material.DevelopmentMaterial.ToString();
            ModdingMaterial.Text     = db.Material.ModdingMaterial.ToString();
            FurnitureCoin.Text       = db.Admiral.FurnitureCoin.ToString();
            FlowPanelUseItem.ResumeLayout();


            //Resources
            FlowPanelResource.SuspendLayout();
            {
                Color overcolor = Color.Moccasin;

                var resday   = RecordManager.Instance.Resource.GetRecord(DateTime.Now.AddHours(-5).Date.AddHours(5));
                var resweek  = RecordManager.Instance.Resource.GetRecord(DateTime.Now.AddHours(-5).Date.AddDays(-(((int)DateTime.Now.AddHours(-5).DayOfWeek + 6) % 7)).AddHours(5));                                    //月曜日起点
                var resmonth = RecordManager.Instance.Resource.GetRecord(new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddHours(5));


                Fuel.Text      = db.Material.Fuel.ToString();
                Fuel.BackColor = db.Material.Fuel < db.Admiral.MaxResourceRegenerationAmount ? Color.Transparent : overcolor;
                ToolTipInfo.SetToolTip(Fuel, string.Format("今日: {0:+##;-##;±0}\n今週: {1:+##;-##;±0}\n今月: {2:+##;-##;±0}",
                                                           resday == null ? 0 : (db.Material.Fuel - resday.Fuel),
                                                           resweek == null ? 0 : (db.Material.Fuel - resweek.Fuel),
                                                           resmonth == null ? 0 : (db.Material.Fuel - resmonth.Fuel)));

                Ammo.Text      = db.Material.Ammo.ToString();
                Ammo.BackColor = db.Material.Ammo < db.Admiral.MaxResourceRegenerationAmount ? Color.Transparent : overcolor;
                ToolTipInfo.SetToolTip(Ammo, string.Format("今日: {0:+##;-##;±0}\n今週: {1:+##;-##;±0}\n今月: {2:+##;-##;±0}",
                                                           resday == null ? 0 : (db.Material.Ammo - resday.Ammo),
                                                           resweek == null ? 0 : (db.Material.Ammo - resweek.Ammo),
                                                           resmonth == null ? 0 : (db.Material.Ammo - resmonth.Ammo)));

                Steel.Text      = db.Material.Steel.ToString();
                Steel.BackColor = db.Material.Steel < db.Admiral.MaxResourceRegenerationAmount ? Color.Transparent : overcolor;
                ToolTipInfo.SetToolTip(Steel, string.Format("今日: {0:+##;-##;±0}\n今週: {1:+##;-##;±0}\n今月: {2:+##;-##;±0}",
                                                            resday == null ? 0 : (db.Material.Steel - resday.Steel),
                                                            resweek == null ? 0 : (db.Material.Steel - resweek.Steel),
                                                            resmonth == null ? 0 : (db.Material.Steel - resmonth.Steel)));

                Bauxite.Text      = db.Material.Bauxite.ToString();
                Bauxite.BackColor = db.Material.Bauxite < db.Admiral.MaxResourceRegenerationAmount ? Color.Transparent : overcolor;
                ToolTipInfo.SetToolTip(Bauxite, string.Format("今日: {0:+##;-##;±0}\n今週: {1:+##;-##;±0}\n今月: {2:+##;-##;±0}",
                                                              resday == null ? 0 : (db.Material.Bauxite - resday.Bauxite),
                                                              resweek == null ? 0 : (db.Material.Bauxite - resweek.Bauxite),
                                                              resmonth == null ? 0 : (db.Material.Bauxite - resmonth.Bauxite)));
            }
            FlowPanelResource.ResumeLayout();

            FlowPanelMaster.ResumeLayout();
            if (!FlowPanelMaster.Visible)
            {
                FlowPanelMaster.Visible = true;
            }
            AdmiralName.Refresh();
            AdmiralComment.Refresh();
        }
Пример #17
0
        void Updated(string apiname, dynamic data)
        {
            KCDatabase db = KCDatabase.Instance;


            FlowPanelMaster.SuspendLayout();

            //Admiral
            FlowPanelAdmiral.SuspendLayout();
            AdmiralName.Text    = string.Format("{0} {1}", db.Admiral.AdmiralName, Constants.GetAdmiralRank(db.Admiral.Rank));
            AdmiralComment.Text = db.Admiral.Comment;
            FlowPanelAdmiral.ResumeLayout();

            //HQ Level
            HQLevel.Value = db.Admiral.Level;
            if (db.Admiral.Level < ExpTable.AdmiralExp.Max(e => e.Key))
            {
                HQLevel.TextNext  = "next:";
                HQLevel.ValueNext = ExpTable.GetNextExpAdmiral(db.Admiral.Exp);
            }
            else
            {
                HQLevel.TextNext  = "exp:";
                HQLevel.ValueNext = db.Admiral.Exp;
            }


            //Fleet
            FlowPanelFleet.SuspendLayout();
            ShipCount.Text = string.Format("{0}/{1}", db.Ships.Count, db.Admiral.MaxShipCount);
            if (db.Ships.Count > db.Admiral.MaxShipCount - 5)
            {
                ShipCount.BackColor = Color.LightCoral;
            }
            else
            {
                ShipCount.BackColor = Color.Transparent;
            }

            EquipmentCount.Text = string.Format("{0}/{1}", db.Equipments.Count, db.Admiral.MaxEquipmentCount);
            if (db.Equipments.Count > db.Admiral.MaxEquipmentCount - 20)
            {
                EquipmentCount.BackColor = Color.LightCoral;
            }
            else
            {
                EquipmentCount.BackColor = Color.Transparent;
            }
            FlowPanelFleet.ResumeLayout();

            //UseItems
            FlowPanelUseItem.SuspendLayout();
            InstantRepair.Text       = db.Material.InstantRepair.ToString();
            InstantConstruction.Text = db.Material.InstantConstruction.ToString();
            DevelopmentMaterial.Text = db.Material.DevelopmentMaterial.ToString();
            ModdingMaterial.Text     = db.Material.ModdingMaterial.ToString();
            FurnitureCoin.Text       = db.Admiral.FurnitureCoin.ToString();
            FlowPanelUseItem.ResumeLayout();


            //Resources
            FlowPanelResource.SuspendLayout();
            {
                Color overcolor = Color.Moccasin;
                Fuel.Text      = db.Material.Fuel.ToString();
                Fuel.BackColor = db.Material.Fuel < db.Admiral.MaxResourceRegenerationAmount ? Color.Transparent : overcolor;

                Ammo.Text      = db.Material.Ammo.ToString();
                Ammo.BackColor = db.Material.Ammo < db.Admiral.MaxResourceRegenerationAmount ? Color.Transparent : overcolor;

                Steel.Text      = db.Material.Steel.ToString();
                Steel.BackColor = db.Material.Steel < db.Admiral.MaxResourceRegenerationAmount ? Color.Transparent : overcolor;

                Bauxite.Text      = db.Material.Bauxite.ToString();
                Bauxite.BackColor = db.Material.Bauxite < db.Admiral.MaxResourceRegenerationAmount ? Color.Transparent : overcolor;
            }
            FlowPanelResource.ResumeLayout();

            FlowPanelMaster.ResumeLayout();
            if (!FlowPanelMaster.Visible)
            {
                FlowPanelMaster.Visible = true;
            }
            AdmiralName.Refresh();
            AdmiralComment.Refresh();
        }