private void airSupremacy(BattleEventArgs e) { Dispatcher.FromThread(UIThread).Invoke((MainWindow.Invoker) delegate { try { if (e.Data["api_kouku"] == null) { return; } labAirSup.Content = seikuMap[e.Data["api_kouku"]["api_stage1"]["api_disp_seiku"].ToString()]; int ec1 = int.Parse(e.Data["api_kouku"]["api_stage1"]["api_e_lostcount"].ToString()); int elc1 = int.Parse(e.Data["api_kouku"]["api_stage1"]["api_e_count"].ToString()); double elp1 = ec1 == 0 ? 0 : (double)ec1 / (double)elc1; int fc1 = int.Parse(e.Data["api_kouku"]["api_stage1"]["api_f_lostcount"].ToString()); int flc1 = int.Parse(e.Data["api_kouku"]["api_stage1"]["api_f_count"].ToString()); double flp1 = fc1 == 0 ? 0 : (double)fc1 / (double)flc1; labAirS1.Content = string.Format("Stage1:\n 敵軍 {0,3}/{1,3}({2:P1}) 我軍 {3,3}/{4,3}({5:P1})", ec1, elc1, elp1, fc1, flc1, flp1); if (e.Data["api_kouku"]["api_stage2"]["api_e_lostcount"] == null) { labAirS2.Content = "Stage2:無"; return; } int ec2 = int.Parse(e.Data["api_kouku"]["api_stage2"]["api_e_lostcount"].ToString()); int elc2 = int.Parse(e.Data["api_kouku"]["api_stage2"]["api_e_count"].ToString()); double elp2 = elc2 == 0 ? 0 : (double)ec2 / (double)elc2; int fc2 = int.Parse(e.Data["api_kouku"]["api_stage2"]["api_f_lostcount"].ToString()); int flc2 = int.Parse(e.Data["api_kouku"]["api_stage2"]["api_f_count"].ToString()); double flp2 = flc2 == 0 ? 0 : (double)fc2 / (double)flc2; labAirS2.Content = string.Format("Stage2:\n 敵軍 {0,3}/{1,3}({2:P1}) 我軍 {3,3}/{4,3}({5:P1})", ec2, elc2, elp2, fc2, flc2, flp2); } catch (Exception ex) { Debug.Print(ex.ToString()); } }, null); }
private void KCODt_BattleFinish(object sender, BattleEventArgs e) { Dispatcher.FromThread(UIThread).Invoke((MainWindow.Invoker) delegate { try { labAirSup.Content = ""; if (e.Data["api_get_ship"] != null) { labAirSup.Content = "發見: " + e.Data["api_get_ship"]["api_ship_name"].ToString(); } } catch (Exception ex) { Debug.Print(ex.ToString()); } }, null); }
protected virtual void OnBattleStartEvent(BattleEventArgs e) { if (enemyDeckId != "" && e.Type == "day") { if (e.Data["api_formation"] != null) { enemyFormation = e.Data["api_formation"][1].ToString(); } } BattleEventHandler handler = BattleStart; if (handler != null) { handler(this, e); } }
protected virtual void OnBattleFinishEvent(BattleEventArgs e) { if (enemyDeckId != "") { EnemyDeckInfo info = new EnemyDeckInfo(enemyDeckId, enemyFormation, e.Data["api_enemy_info"]["api_deck_name"].ToString(), e.Data["api_ship_id"]); EnemyDeckMap.Add(enemyDeckId, JToken.FromObject(info)); enemyDeckId = ""; enemyFormation = ""; List <string> lx = new List <string>(); foreach (JToken item in EnemyDeckMap.Values) { lx.Add(item.ToString()); } string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "data", defEnemyDeck); File.WriteAllText(path, string.Format("[{0}]", string.Join(",", lx))); } BattleEventHandler handler = BattleFinish; if (handler != null) { handler(this, e); } }
private void KCODt_BattleStart(object sender, BattleEventArgs e) { airSupremacy(e); }