private void SpawnCall(string con, int team) { Console.WriteLine(con); Console.WriteLine(team); if (con == "驱逐舰") { WpfServer.SendMessage($"Spawn DD {team}"); statusBar.Text = "按ESC键退出创建模式"; } else if (con == "摄像机") { WpfServer.SendMessage($"Spawn Camera {team}"); statusBar.Text = "按ESC键退出创建模式"; } else if (con == "战列舰") { WpfServer.SendMessage($"Spawn BB {team}"); statusBar.Text = "按ESC键退出创建模式"; } else if (con == "航空母舰") { WpfServer.SendMessage($"Spawn CV {team}"); statusBar.Text = "按ESC键退出创建模式"; } else if (con == "炮弹") { WpfServer.SendMessage($"Spawn Shell {team}"); statusBar.Text = "按ESC键退出创建模式"; } }
public void Timeshift(int to) { mClock.CurrentTime = to; currentTimeIndicator.Content = $"{mClock.CurrentTime}"; maxTimeIndicator.Content = $"{mClock.TimeSpan}"; timeSlider.Value = (int)mClock.CurrentTime; WpfServer.SendMessage($"Timeleap {(int)mClock.CurrentTime}"); mUnitMan.UpdateParamList(); }
private void Window_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Escape) { UnitCreatorList.SelectedItem = null; WpfServer.SendMessage("Cancel"); statusBar.Text = "就绪"; } }
private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { if (mClock.IsPlaying) { return; } mClock.CurrentTime = (int)(timeSlider.Value); currentTimeIndicator.Content = $"{mClock.CurrentTime}"; maxTimeIndicator.Content = $"{mClock.TimeSpan}"; WpfServer.SendMessage($"Timeleap {(int)mClock.CurrentTime}"); mUnitMan.UpdateParamList(); }
private void LeftTabCtrl_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.Source is TabControl) { string ts = LeftTabCtrl.SelectedContent as string; if (ts != "单位创建") { UnitCreatorList.SelectedItem = null; WpfServer.SendMessage("Cancel"); statusBar.Text = "就绪"; } } }
private void Run(object sender, RoutedEventArgs e) { Timeshift(0); mClock.IsPlaying = true; PlaystateBtn.Content = "暂停"; List <string> cmd = mUnitMan.mCamMan.PrepareDopesheetCmd(); foreach (string s in cmd) { WpfServer.SendMessage(s); } WpfServer.SendMessage("Run"); LeftPanels.IsEnabled = false; }
private void UnitsGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (UnitsGrid.SelectedItem == null) { return; } string selID = (UnitsGrid.SelectedItem as UnitData).ID; mUnitMan.selUnit = mUnitMan.GetUnit(int.Parse(selID)); mUnitMan.UpdateParamList(); mUnitMan.UpdateKeyframeList(); WpfServer.SendMessage($"Select {selID}"); LeftTabCtrl.SelectedIndex = 2; }
private void PlaystateBtn_Click(object sender, RoutedEventArgs e) { if (mClock.IsPlaying) { mClock.IsPlaying = false; PlaystateBtn.Content = "播放"; WpfServer.SendMessage("Pause"); LeftPanels.IsEnabled = true; } else { mClock.IsPlaying = true; PlaystateBtn.Content = "暂停"; WpfServer.SendMessage("Play"); LeftPanels.IsEnabled = false; } }
private void ListBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { ListBoxItem ts = (UnitCreatorList.SelectedItem as ListBoxItem); if (ts != null) { string con = ts.Content as string; Console.WriteLine(con); if (con == "驱逐舰") { statusBar.Text = $"Select {ts.Content.ToString()}"; WpfServer.SendMessage("Spawn DD"); statusBar.Text = "按ESC键退出创建模式"; } else if (con == "摄像机") { statusBar.Text = $"Select {ts.Content.ToString()}"; WpfServer.SendMessage("Spawn Camera"); statusBar.Text = "按ESC键退出创建模式"; } else if (con == "战列舰") { statusBar.Text = $"Select {ts.Content.ToString()}"; WpfServer.SendMessage("Spawn BB"); statusBar.Text = "按ESC键退出创建模式"; } else if (con == "航空母舰") { statusBar.Text = $"Select {ts.Content.ToString()}"; WpfServer.SendMessage("Spawn CV"); statusBar.Text = "按ESC键退出创建模式"; } else if (con == "炮弹") { statusBar.Text = $"Select {ts.Content.ToString()}"; WpfServer.SendMessage("Spawn Shell"); statusBar.Text = "按ESC键退出创建模式"; } } }
private void KeyDataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { if ((e.Column.Header as string) == "动作") { string oldValue = (e.Row.DataContext as KeyframeData).time; string newValue = (e.EditingElement as TextBox).Text; mUnitMan.selUnit.SetKeyframeMemo(newValue, int.Parse(oldValue)); mUnitMan.UpdateKeyframeList(); } else if ((e.Column.Header as string) == "时刻") { string oldValue = (e.Row.DataContext as KeyframeData).time; string newValue = (e.EditingElement as TextBox).Text; Console.WriteLine(oldValue + " " + newValue); int tmp; if (oldValue == newValue) { return; } if (!int.TryParse(newValue, out tmp)) { e.Cancel = true; return; } if (mUnitMan.selUnit.ContainsTargetAtSameTime(tmp)) { Console.WriteLine("SWAP KEYS"); WpfServer.SendMessage($"SwapKey {mUnitMan.selUnit.mID} {oldValue} {newValue}"); mUnitMan.selUnit.SwapTime(int.Parse(oldValue), int.Parse(newValue)); } else { WpfServer.SendMessage($"Timeshift {mUnitMan.selUnit.mID} {oldValue} {newValue}"); mUnitMan.selUnit.TimeshiftTarget(int.Parse(oldValue), int.Parse(newValue)); } Timeshift(tmp); mUnitMan.UpdateKeyframeList(); } }
private void LaunchTorpedoBtn_Click(object sender, RoutedEventArgs e) { WpfServer.SendMessage($"Aim Torpedo {mUnitMan.selUnit.mID}"); statusBar.Text = "左键单击指定攻击目标点,按ESC键取消攻击"; }
private void ParamsDataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { string newKey = (e.Row.DataContext as ParamsData).name; string newValue = (e.EditingElement as TextBox).Text; float res; UnitType ta; if (newKey == "类型" && !UnitType.TryParse(newValue, out ta)) { e.Cancel = true; mUnitMan.UpdateParamList(); return; } if (newKey != "类型" && newKey != "名称" && !float.TryParse(newValue, out res)) { e.Cancel = true; mUnitMan.UpdateParamList(); return; } Console.WriteLine(newValue); ObservableCollection <ParamsData> toc = ParamsDataGrid.DataContext as ObservableCollection <ParamsData>; string[] args = new string[6]; for (int i = 0; i < toc.Count; i++) { if (toc[i].name == "X坐标") { args[0] = toc[i].name == newKey?newValue:toc[i].value; } else if (toc[i].name == "Y坐标") { args[1] = toc[i].name == newKey ? newValue : toc[i].value; } else if (toc[i].name == "Z坐标") { args[2] = toc[i].name == newKey ? newValue : toc[i].value; } else if (toc[i].name == "类型") { UnitType tmp2 = (UnitType)UnitType.Parse(typeof(UnitType), toc[i].value); args[4] = ((int)tmp2).ToString(); } else if (toc[i].name == "名称") { if (toc[i].name == newKey) { args[5] = newValue; mUnitMan.selUnit.mName = newValue; mUnitMan.UpdateDisplayList(); } else { args[5] = toc[i].value; } } } args[3] = mClock.CurrentTime.ToString(); Position tp = new Position(); tp.X = args[0]; tp.Y = args[1]; tp.Z = args[2]; tp.T = (int)mClock.CurrentTime; if (mUnitMan.selUnit.ContainsTargetAtSameTime(tp)) { WpfServer.SendMessage($"Modify {mUnitMan.selUnit.mID} {args[0]} {args[1]} {args[2]} {args[3]} {args[4]} {args[5]}"); mUnitMan.selUnit.ModifyTarget(tp); } else { WpfServer.SendMessage($"Add {mUnitMan.selUnit.mID} {args[0]} {args[1]} {args[2]} {args[3]} {args[4]} {args[5]}"); mUnitMan.selUnit.AddTarget(tp.X, tp.Y, tp.Z, tp.T); } if (int.Parse(args[4]) != (int)mUnitMan.selUnit.mType) { mUnitMan.selUnit.mType = (UnitType)int.Parse(args[4]); mUnitMan.UpdateDisplayList(); } mUnitMan.UpdateKeyframeList(); }