Exemplo n.º 1
0
        public override void LoadFromResponse(string apiname, dynamic data)
        {
            switch (apiname)
            {
            case "api_req_combined_battle/goback_port":
                foreach (int index in KCDatabase.Instance.Battle.Result.EscapingShipIndex)
                {
                    Fleets[(index - 1) < 6 ? 1 : 2].Escape((index - 1) % 6);
                }
                break;

            case "api_get_member/ndock":
                foreach (var fleet in Fleets.Values)
                {
                    fleet.LoadFromResponse(apiname, data);
                }
                break;

            default:
                base.LoadFromResponse(apiname, (object)data);

                //api_port/port, api_get_member/deck
                foreach (var elem in data)
                {
                    int id = (int)elem.api_id;

                    if (!Fleets.ContainsKey(id))
                    {
                        var a = new FleetData();
                        a.LoadFromResponse(apiname, elem);
                        Fleets.Add(a);
                    }
                    else
                    {
                        Fleets[id].LoadFromResponse(apiname, elem);
                    }
                }
                break;
            }

            //泊地修理関連
            if (apiname == "api_port/port")
            {
                if ((DateTime.Now - AnchorageRepairingTimer).TotalMinutes >= 20 || AnchorageRepairingTimer == DateTime.MinValue)
                {
                    ResetAnchorageRepairing();
                }
            }
        }
Exemplo n.º 2
0
        public override void LoadFromResponse(string apiname, dynamic data)
        {
            switch (apiname)
            {
            case "api_req_sortie/goback_port":
            case "api_req_combined_battle/goback_port":
            {
                var battle = KCDatabase.Instance.Battle;

                foreach (int ii in battle.Result.EscapingShipIndex)
                {
                    int index = ii - 1;

                    if (index < battle.FirstBattle.Initial.FriendFleet.Members.Count)
                    {
                        battle.FirstBattle.Initial.FriendFleet.Escape(index);
                    }
                    else
                    {
                        battle.FirstBattle.Initial.FriendFleetEscort.Escape(index - 6);
                    }
                }
            }
            break;

            case "api_get_member/ndock":
                foreach (var fleet in Fleets.Values)
                {
                    fleet.LoadFromResponse(apiname, data);
                }
                break;

            case "api_req_hensei/preset_select":
            {
                int id = (int)data.api_id;

                if (!Fleets.ContainsKey(id))
                {
                    var a = new FleetData();
                    a.LoadFromResponse(apiname, data);
                    Fleets.Add(a);
                }
                else
                {
                    Fleets[id].LoadFromResponse(apiname, data);
                }
            }
            break;

            default:
                base.LoadFromResponse(apiname, (object)data);

                //api_port/port, api_get_member/deck
                foreach (var elem in data)
                {
                    int id = (int)elem.api_id;

                    if (!Fleets.ContainsKey(id))
                    {
                        var a = new FleetData();
                        a.LoadFromResponse(apiname, elem);
                        Fleets.Add(a);
                    }
                    else
                    {
                        Fleets[id].LoadFromResponse(apiname, elem);
                    }
                }
                break;
            }


            // 泊地修理・コンディションの処理
            if (apiname == "api_port/port")
            {
                if ((DateTime.Now - AnchorageRepairingTimer).TotalMinutes >= 20)
                {
                    StartAnchorageRepairingTimer();
                }
                else
                {
                    CheckAnchorageRepairingHealing();
                }

                UpdateConditionPrediction();
            }
        }