本文整理汇总了C#中Packet.setFireOff方法的典型用法代码示例。如果您正苦于以下问题:C# Packet.setFireOff方法的具体用法?C# Packet.setFireOff怎么用?C# Packet.setFireOff使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packet
的用法示例。
在下文中一共展示了Packet.setFireOff方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FPSAim
public FPSAim(String vcd)
{
InitializeComponent();
VideoCaptureDevice videoSource = new VideoCaptureDevice(vcd, new Size(320, 240), false);
OpenVideoSource(videoSource);
redDot.Location = new Point(gridBox.Width / 2 + gridBox.Left, gridBox.Height / 2 + gridBox.Top);
servos = new Servos();
redDot.Location = servos.GetPorportionalMathPosition(gridBox.Bounds);
redDot.Location = new Point(redDot.Location.X - REDDOT_OFFSET_X, redDot.Location.Y - REDDOT_OFFSET_Y);
label1.Text = "(-" + servos.CenterServosPosition.X + "," + servos.CenterServosPosition.Y + ")";
textBoxXServo.Text = servos.ShootingRange.Width.ToString();
textBoxYServo.Text = servos.ShootingRange.Height.ToString();
textBoxXCoord.Text = servos.ServosPosition.X.ToString();
textBoxYCoord.Text = servos.ServosPosition.Y.ToString();
Packet packet = new Packet(servos.CenterServosPosition);
packet.setFireOff();
this.sendData(packet);
Cursor.Hide();
cursorhidden = true;
CoordinateTimer.Start();
//Point camwindowcenter = new Point(gridBox.PointToScreen(new Point(0, 0)).X , gridBox.PointToScreen(new Point(0, 0)).Y );
//Cursor.Position = camwindowcenter;
currentX = Cursor.Position.X;
currentY = Cursor.Position.Y;
lastX = 0;
lastY = 0;
}
示例2: centerButton_Click
private void centerButton_Click(object sender, EventArgs e)
{
int x = 0;
int y = 0;
servos.ServosPosition = servos.ConvertPositionMathToServos(new Point(x, y));
XTextBox.Text = servos.GetMathPosition().X.ToString();
YTextBox.Text = servos.GetMathPosition().Y.ToString();
redDot.Location = servos.GetPorportionalMathPosition(gridBox.Bounds);
redDot.Location = new Point(redDot.Location.X - REDDOT_OFFSET_X, redDot.Location.Y - REDDOT_OFFSET_Y);
textBoxXCoord.Text = servos.CenterServosPosition.X.ToString();
textBoxYCoord.Text = servos.CenterServosPosition.Y.ToString();
Packet packet = new Packet(servos.CenterServosPosition);
packet.setFireOff();
this.sendData(packet);
}
示例3: RemoteAim
public RemoteAim(String vcd)
{
InitializeComponent();
VideoCaptureDevice videoSource = new VideoCaptureDevice(vcd, new Size(320, 240), false);
OpenVideoSource(videoSource);
redDot.Location = new Point(gridBox.Width / 2 + gridBox.Left, gridBox.Height / 2 + gridBox.Top);
servos = new Servos();
XTextBox.Text = servos.GetMathPosition().X.ToString();
YTextBox.Text = servos.GetMathPosition().Y.ToString();
redDot.Location = servos.GetPorportionalMathPosition(gridBox.Bounds);
redDot.Location = new Point(redDot.Location.X - REDDOT_OFFSET_X, redDot.Location.Y - REDDOT_OFFSET_Y);
label1.Text = "(-" + servos.CenterServosPosition.X + "," + servos.CenterServosPosition.Y + ")";
PosIncTextBox.Text = positionIncrement.ToString();
textBoxXServo.Text = servos.ShootingRange.Width.ToString();
textBoxYServo.Text = servos.ShootingRange.Height.ToString();
textBoxXCoord.Text = servos.ServosPosition.X.ToString();
textBoxYCoord.Text = servos.ServosPosition.Y.ToString();
Packet packet = new Packet(servos.CenterServosPosition);
packet.setFireOff();
this.sendData(packet);
}
示例4: FPSAim_FormClosing
private void FPSAim_FormClosing(object sender, FormClosingEventArgs e)
{
CoordinateTimer.Stop();
CloseVideoSource();
Cursor.Show();
Packet packet = new Packet(servos.CenterServosPosition);
packet.setFireOff();
sendData(packet);
}
示例5: CoordinateTimer_Tick
private void CoordinateTimer_Tick(object sender, EventArgs e)
{
int deltaX = Cursor.Position.X - currentX;
int deltaY = Cursor.Position.Y - currentY;
lastX += deltaX/sensitivity;
lastY -= deltaY/sensitivity;
if (lastX > servos.ShootingRange.Width / 2)
{
lastX = servos.ShootingRange.Width / 2;
}
else if (lastX < -servos.ShootingRange.Width / 2)
{
lastX = -servos.ShootingRange.Width / 2;
}
if (lastY > servos.ShootingRange.Height / 2)
{
lastY = servos.ShootingRange.Height / 2;
}
else if (lastY < -servos.ShootingRange.Height / 2)
{
lastY = -servos.ShootingRange.Height / 2;
}
//MessageBox.Show(lastX.ToString() + " " + lastY.ToString());
servos.ServosPosition = servos.ConvertPositionMathToServos(new Point(lastX, lastY));
//servos.SetPorportionalMathPosition(gridBox.Bounds, new Point(lastX, lastY));
Packet packet = new Packet(servos.ServosPosition);
textBoxXCoord.Text = servos.ServosPosition.X.ToString();
textBoxYCoord.Text = servos.ServosPosition.Y.ToString();
if (fireOK == true)
packet.setFireOn();
else
packet.setFireOff();
this.sendData(packet);
Cursor.Position = new Point(currentX, currentY);
}
示例6: RemoteAim_FormClosing
private void RemoteAim_FormClosing(object sender, FormClosingEventArgs e)
{
CloseVideoSource();
Packet packet = new Packet(servos.CenterServosPosition);
packet.setFireOff();
sendData(packet);
}
示例7: remoteAim
private void remoteAim()
{
int x = int.Parse(XTextBox.Text);
int y = int.Parse(YTextBox.Text);
servos.ServosPosition = servos.ConvertPositionMathToServos(new Point(x, y));
XTextBox.Text = servos.GetMathPosition().X.ToString();
YTextBox.Text = servos.GetMathPosition().Y.ToString();
redDot.Location = servos.GetPorportionalMathPosition(gridBox.Bounds);
redDot.Location = new Point(redDot.Location.X - REDDOT_OFFSET_X, redDot.Location.Y - REDDOT_OFFSET_Y);
Packet packet = new Packet(servos.ServosPosition);
if (fireOK == true)
packet.setFireOn();
else
packet.setFireOff();
this.sendData(packet);
}
示例8: CoordinateTimer_Tick
private void CoordinateTimer_Tick(object sender, EventArgs e)
{
servos.SetPorportionalMathPosition(gridBox.Bounds, new Point(redDot.Location.X + REDDOT_OFFSET_X, redDot.Location.Y + REDDOT_OFFSET_Y));
XTextBox.Text = servos.GetMathPosition().X.ToString();
YTextBox.Text = servos.GetMathPosition().Y.ToString();
Packet packet = new Packet(servos.ServosPosition);
textBoxXCoord.Text = servos.ServosPosition.X.ToString();
textBoxYCoord.Text = servos.ServosPosition.Y.ToString();
if (fireOK == true)
packet.setFireOn();
else
packet.setFireOff();
this.sendData(packet);
}
示例9: TrackingTimer_Tick
//125ms refresh rate as of right now
//Timer that tracks refresh of position tracking
private void TrackingTimer_Tick(object sender, EventArgs e)
{
if (cameraWindow1.Camera != null && cameraWindow1.Camera.MotionDetector != null)
{
CountingMotionDetector cmd = (CountingMotionDetector)cameraWindow1.Camera.MotionDetector;
Rectangle[] rectmotion = cmd.ObjectRectangles;
if (rectmotion.Length != 0)
{
if (!firingsoundplayed && soundOn)
{
switch (soundTracker % 4)
{
case 0:
PlaySound(pwd + "\\Sounds\\Sentry Sounds\\Target Found\\firing.wav", IntPtr.Zero, SoundFlags.SND_FILENAME | SoundFlags.SND_ASYNC);
firingsoundplayed = true;
break;
case 1:
PlaySound(pwd + "\\Sounds\\Sentry Sounds\\Target Found\\i_see_you.wav", IntPtr.Zero, SoundFlags.SND_FILENAME | SoundFlags.SND_ASYNC);
firingsoundplayed = true;
break;
case 2:
PlaySound(pwd + "\\Sounds\\Sentry Sounds\\Target Found\\target_acquired.wav", IntPtr.Zero, SoundFlags.SND_FILENAME | SoundFlags.SND_ASYNC);
firingsoundplayed = true;
break;
case 3:
PlaySound(pwd + "\\Sounds\\Sentry Sounds\\Target Found\\there_you_are.wav", IntPtr.Zero, SoundFlags.SND_FILENAME | SoundFlags.SND_ASYNC);
firingsoundplayed = true;
break;
}
}
ceasefiringsoundplayed = false;
aimDot.BackColor = Color.Red;
//aimDot.Visible = true;
//calculate largest detected motion area
Rectangle largest = rectmotion[0];
for (int i = 1; i < rectmotion.Length; i++)
{
if (rectmotion[i].Width * rectmotion[i].Height > largest.Width * largest.Height)
{
largest = rectmotion[i];
}
}
//get center of largest motion area
int x = largest.X + largest.Width / 2 + cameraWindow1.Location.X;
int y = largest.Y + largest.Height / 2 + cameraWindow1.Location.Y;
//calculate difference from last center point and adjust target lead depending on speed
if (lastCenterPosition.IsEmpty)
{
lastCenterPosition = new Point(x, y);
lastLeadingPosition = new Point(lastCenterPosition.X, lastCenterPosition.Y);
}
else if (!lastCenterPosition.IsEmpty)
{
int xdiff = x - lastCenterPosition.X;
int ydiff = y - lastCenterPosition.Y;
lastLeadingPosition = new Point(x + multiplier*xdiff, y + ydiff);
lastCenterPosition = new Point(x, y);
Console.WriteLine(xdiff.ToString());
}
//set aimdot location
aimDot.Location = new Point(lastLeadingPosition.X - 2, lastLeadingPosition.Y - 2);
//create packet, set servo position, and fire
servos.SetPorportionalMathPosition(cameraWindow1.Bounds, lastLeadingPosition);
Packet packet = new Packet(servos.ServosPosition);
//Console.WriteLine("(" + servos.Position.X + "," + servos.Position.Y + ")");
//MessageBox.Show("(" + servos.Position.X + "," + servos.Position.Y + ")");
packet.setFireOff();
if (firingOn)
{
packet.setFireOn();
}
sendData(packet);
}
else if (rectmotion.Length == 0)
{
if (!ceasefiringsoundplayed && soundOn)
{
switch (soundTracker % 4)
{
case 0:
PlaySound(pwd + "\\Sounds\\Sentry Sounds\\Target lost\\searching.wav", IntPtr.Zero, SoundFlags.SND_FILENAME | SoundFlags.SND_ASYNC);
ceasefiringsoundplayed = true;
break;
case 1:
PlaySound(pwd + "\\Sounds\\Sentry Sounds\\Target lost\\is_anyone_there.wav", IntPtr.Zero, SoundFlags.SND_FILENAME | SoundFlags.SND_ASYNC);
ceasefiringsoundplayed = true;
break;
case 2:
PlaySound(pwd + "\\Sounds\\Sentry Sounds\\Target lost\\target_lost.wav", IntPtr.Zero, SoundFlags.SND_FILENAME | SoundFlags.SND_ASYNC);
ceasefiringsoundplayed = true;
break;
case 3:
//.........这里部分代码省略.........
示例10: exitToolStripMenuItem_Click
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Packet packet = new Packet(servos.CenterServosPosition);
packet.setFireOff();
sendData(packet);
Application.Exit();
}