예제 #1
0
 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键退出创建模式";
     }
 }
예제 #2
0
 private void Window_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Escape)
     {
         UnitCreatorList.SelectedItem = null;
         WpfServer.SendMessage("Cancel");
         statusBar.Text = "就绪";
     }
 }
예제 #3
0
 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();
 }
예제 #4
0
 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();
 }
예제 #5
0
 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 = "就绪";
         }
     }
 }
예제 #6
0
        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;
        }
예제 #7
0
        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;
        }
예제 #8
0
        private void MsgHandler(object sender, EventArgs e)
        {
            List <string> tmsg = WpfServer.GetMsg("Spawn");

            if (tmsg != null)
            {
                Console.WriteLine("msgget");
                mUnitMan.ParseMsg(tmsg);
            }
            tmsg = WpfServer.GetMsg("Select");
            if (tmsg != null)
            {
                Console.WriteLine("msgsel");
                mUnitMan.ParseMsg(tmsg);
            }
            tmsg = WpfServer.GetMsg("Modify");
            if (tmsg != null)
            {
                Console.WriteLine("msgmod");
                mUnitMan.ParseMsg(tmsg);
            }
            tmsg = WpfServer.GetMsg("Add");
            if (tmsg != null)
            {
                Console.WriteLine("msgadd");
                mUnitMan.ParseMsg(tmsg);
            }
            tmsg = WpfServer.GetMsg("Disselect");
            if (tmsg != null)
            {
                Console.WriteLine("msgdissel");
                mUnitMan.ParseMsg(tmsg);
            }
            tmsg = WpfServer.GetMsg("Fire");
            if (tmsg != null)
            {
                Console.WriteLine("msgfire");
                mUnitMan.ParseMsg(tmsg);
            }
            tmsg = WpfServer.GetMsg("SyncTime");
            if (tmsg != null)
            {
                Console.WriteLine("msgsync");
                mUnitMan.ParseMsg(tmsg);
            }
            //dispatcherTimer2.Start();
        }
예제 #9
0
 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;
     }
 }
예제 #10
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //AllocConsole();

            IntPtr hwnd = ((HwndSource)PresentationSource.FromVisual(Panel1)).Handle;

            process = new Process();
            process.StartInfo.FileName = "Data\\场景仿真推演系统.exe";
            //process.StartInfo.FileName = "Oven\\Ovencooked.exe";
            process.StartInfo.Arguments       = "-parentHWND " + hwnd.ToInt32() + " " + Environment.CommandLine;
            process.StartInfo.UseShellExecute = true;
            process.StartInfo.CreateNoWindow  = true;

            process.Start();

            process.WaitForInputIdle();
            isU3DLoaded = true;
            // Doesn't work for some reason ?!
            //unityHWND = process.MainWindowHandle;
            EnumChildWindows(hwnd, WindowEnum, IntPtr.Zero);
            dispatcherTimer          = new DispatcherTimer();
            dispatcherTimer.Tick    += new EventHandler(InitialResize);
            dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 10);

            dispatcherTimer.Start();
            dispatcherTimer2          = new DispatcherTimer();
            dispatcherTimer2.Tick    += new EventHandler(MsgHandler);
            dispatcherTimer2.Interval = new TimeSpan(0, 0, 0, 0, 10);

            dispatcherTimer2.Start();

            clockDispatcher          = new DispatcherTimer();
            clockDispatcher.Tick    += new EventHandler(ClockUpdate);
            clockDispatcher.Interval = new TimeSpan(0, 0, 0, 1);
            clockDispatcher.Start();
            WpfServer.StartServer();
            TcpFileServer.StartServer();
            UnitsGrid.DataContext = mUnitMan.unitsDisplayList;
            //KeyDataGrid.ItemsSource = list;

            timeSlider.Maximum           = mClock.TimeSpan;
            timeSlider.Value             = mClock.CurrentTime;
            currentTimeIndicator.Content = $"{mClock.CurrentTime}";
            maxTimeIndicator.Content     = $"{mClock.TimeSpan}";
            camid.ItemsSource            = UnitManager.camList;
        }
예제 #11
0
 private void NewFile(object sender, RoutedEventArgs e)
 {
     try
     {
         InitWindow iw = new InitWindow();
         iw.Show();
         while (process.HasExited == false)
         {
             process.Kill();
         }
         //FreeConsole();
         WpfServer.QuitServer();
         this.Close();
     }
     catch (Exception)
     {
     }
 }
예제 #12
0
        private void Window_Closed(object sender, EventArgs e)
        {
            try
            {
                process.CloseMainWindow();

                Thread.Sleep(1000);
                while (process.HasExited == false)
                {
                    process.Kill();
                }
                //FreeConsole();
                WpfServer.QuitServer();
                TcpFileServer.QuitServer();
            }
            catch (Exception)
            {
            }
        }
예제 #13
0
        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键退出创建模式";
                }
            }
        }
예제 #14
0
        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();
            }
        }
예제 #15
0
 private void LaunchTorpedoBtn_Click(object sender, RoutedEventArgs e)
 {
     WpfServer.SendMessage($"Aim Torpedo {mUnitMan.selUnit.mID}");
     statusBar.Text = "左键单击指定攻击目标点,按ESC键取消攻击";
 }
예제 #16
0
        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();
        }