/// <summary> /// Clear the database /// </summary> public void Clear() { MasterShips.Clear(); ShipTypes.Clear(); MasterEquipments.Clear(); EquipmentTypes.Clear(); MasterUseItems.Clear(); MapArea.Clear(); MapInfo.Clear(); Mission.Clear(); }
public void InitializeApiStart2(dynamic data) { string APIName = "api_start2"; if (data.api_data != null && data.api_result == 1) { data = data.api_data; } //特別置換処理 data.api_mst_stype[7].api_name = "巡洋戦艦"; ClearUpdated(); //api_mst_ship foreach (var elem in data.api_mst_ship) { int id = (int)elem.api_id; if (MasterShips[id] == null) { var ship = new ShipDataMaster(); ship.LoadFromResponse(APIName, elem); MasterShips.Add(ship); } else { MasterShips[id].LoadFromResponse(APIName, elem); } } //改装関連のデータ設定 foreach (var ship in MasterShips) { var remodelID = ship.Value.RemodelAfterShipID; if (remodelID != 0) { MasterShips[remodelID].RemodelBeforeShipID = ship.Key; } } //api_mst_shipgraph foreach (var elem in data.api_mst_shipgraph) { int id = (int)elem.api_id; ShipDataMaster ship = MasterShips[id]; if (ship != null) { ship.ResourceName = elem.api_filename; dynamic versions = elem.api_version; ship.ResourceGraphicVersion = versions[0]; ship.ResourceVoiceVersion = versions[1]; ship.ResourcePortVoiceVersion = versions[2]; } } //api_mst_slotitem_equiptype foreach (var elem in data.api_mst_slotitem_equiptype) { int id = (int)elem.api_id; if (EquipmentTypes[id] == null) { var eqt = new EquipmentType(); eqt.LoadFromResponse(APIName, elem); EquipmentTypes.Add(eqt); } else { EquipmentTypes[id].LoadFromResponse(APIName, elem); } } //api_mst_stype foreach (var elem in data.api_mst_stype) { int id = (int)elem.api_id; if (ShipTypes[id] == null) { var spt = new ShipType(); spt.LoadFromResponse(APIName, elem); ShipTypes.Add(spt); } else { ShipTypes[id].LoadFromResponse(APIName, elem); } } //api_mst_slotitem foreach (var elem in data.api_mst_slotitem) { int id = (int)elem.api_id; if (MasterEquipments[id] == null) { var eq = new EquipmentDataMaster(); eq.LoadFromResponse(APIName, elem); MasterEquipments.Add(eq); } else { MasterEquipments[id].LoadFromResponse(APIName, elem); } } //api_mst_slotitemgraph /* * foreach ( var elem in data.api_mst_slotitemgraph ) { * * int id = (int)elem.api_id; * EquipmentDataMaster eq = db.MasterEquipments[id]; * if ( eq != null ) { * eq.ResourceVersion = elem.api_version; * } * } */ //api_mst_useitem foreach (var elem in data.api_mst_useitem) { int id = (int)elem.api_id; if (MasterUseItems[id] == null) { var item = new UseItemMaster(); item.LoadFromResponse(APIName, elem); MasterUseItems.Add(item); } else { MasterUseItems[id].LoadFromResponse(APIName, elem); } } //api_mst_maparea foreach (var elem in data.api_mst_maparea) { int id = (int)elem.api_id; if (MapArea[id] == null) { var item = new MapAreaData(); item.LoadFromResponse(APIName, elem); MapArea.Add(item); } else { MapArea[id].LoadFromResponse(APIName, elem); } } //api_mst_mapinfo foreach (var elem in data.api_mst_mapinfo) { int id = (int)elem.api_id; if (MapInfo[id] == null) { var item = new MapInfoData(); item.LoadFromResponse(APIName, elem); MapInfo.Add(item); } else { MapInfo[id].LoadFromResponse(APIName, elem); } } //api_mst_mission foreach (var elem in data.api_mst_mission) { int id = (int)elem.api_id; if (Mission[id] == null) { var item = new MissionData(); item.LoadFromResponse(APIName, elem); Mission.Add(item); } else { Mission[id].LoadFromResponse(APIName, elem); } } //api_mst_shipupgrade Dictionary <int, int> upgradeLevels = new Dictionary <int, int>(); foreach (var elem in data.api_mst_shipupgrade) { int idbefore = (int)elem.api_current_ship_id; int idafter = (int)elem.api_id; var shipbefore = MasterShips[idbefore]; var shipafter = MasterShips[idafter]; int level = (int)elem.api_upgrade_level; if (upgradeLevels.ContainsKey(idafter)) { if (level < upgradeLevels[idafter]) { shipafter.RemodelBeforeShipID = idbefore; upgradeLevels[idafter] = level; } } else { shipafter.RemodelBeforeShipID = idbefore; upgradeLevels.Add(idafter, level); } if (shipbefore != null) { shipbefore.NeedBlueprint = (int)elem.api_drawing_count; shipbefore.NeedCatapult = (int)elem.api_catapult_count; } } }