public override void PostFrameCallback() { uint frame = Mem.ReadU32(AddrGlobal.NonLagFrameCount); if ((frame <= _prevF) && !Emu.IsLagged()) { Emu.SetIsLagged(true); Emu.SetLagCount(Emu.LagCount() + 1); } uint mode = Mem.ReadByte(AddrGlobal.GameMode); _levelTime = Mem.ReadU16(AddrGlobal.LevelFrameCount); ResetStatusLine(); StatusText($"Frames: {Mem.ReadU32(AddrGlobal.FrameCount),7} Nonlag: {frame,7} Level: {_levelTime,6} GameMode: {mode:X2}"); switch (mode) { case 0x20: case 0x28: case 0xAC: Update2DTickers(); if (_mapDumpState != 0) { PostProcessMapDump(); } DrawTurnSignal(); break; case 0xF6: Update3DTickers(); break; } Joy.Set("C", null, 1); Joy.Set("Start", null, 1); Gui.DrawFinish(); }
public override int GetHashCode() { int hash = 1; if (CtrlNum != 0) { hash ^= CtrlNum.GetHashCode(); } if (pos_ != null) { hash ^= Pos.GetHashCode(); } if (rot_ != null) { hash ^= Rot.GetHashCode(); } if (joy_ != null) { hash ^= Joy.GetHashCode(); } if (Trigger != 0F) { hash ^= Trigger.GetHashCode(); } if (Buttons != 0) { hash ^= Buttons.GetHashCode(); } return(hash); }
void joyTwistCallback(Joy joy) { TwistStamped velocity = new TwistStamped(); velocity.header.Frame_id = baseStabilizedFrame; velocity.header.Stamp = ROS.GetTime(); velocity.twist.linear.x = getAxis(joy, sAxes.x); velocity.twist.linear.y = getAxis(joy, sAxes.y); velocity.twist.linear.z = getAxis(joy, sAxes.z); velocity.twist.angular.z = getAxis(joy, sAxes.yaw) * Math.PI / 180.0; if (getButton(joy, sButtons.slow)) { velocity.twist.linear.x *= slowFactor; velocity.twist.linear.y *= slowFactor; velocity.twist.linear.z *= slowFactor; velocity.twist.angular.z *= slowFactor; } velocityPublisher.publish(velocity); if (getButton(joy, sButtons.stop)) { enableMotors(false); } else if (getButton(joy, sButtons.go)) { enableMotors(true); } }
public XYZrobot() { InitializeComponent(); joys = new Joy(); joys.Show(); robot = new Robot(); sw = new Stopwatch(); }
public IndexNode(Joy.Data.IndexUnit indexPage) { this.ID = Guid.Empty; this.IsDeleted = true; this.Right = new IndexLink(); this.Left = new IndexLink(); this.DataPageID = uint.MaxValue; this.IndexPage = indexPage; }
} // 플레이어가 현재 상호작용중인지 정의하는 변수다. //public // CheaserHitBButton hitButton; void Start() { animator = GetComponent <Animator>(); JoyStick = GameObject.Find("JoyStickBackground").GetComponent <Joy>(); // 다른클래스를 호출한다. _cFunc = new CommonFunction(); _moveSpeed = 0; isInteracting = false; // hitButton = GameObject.Find("AttckButton").GetComponent<CheaserHitBButton>(); }
Vector2 GetUIPoint(Joy joy) { var virtualCenter = GetVirtualCenter(joy); Vector2 uiPoint = Vector2.zero; uiPoint.x = virtualCenter.x - joy.parame.radius; uiPoint.y = virtualCenter.y - joy.parame.radius; return(uiPoint); }
public bool getButton(Joy joy, SButton button) { if (button.button <= 0 || button.button > joy.buttons.Length) { ROS.Error("Button " + button.button + " out of range, joy has " + joy.buttons.Length + " buttons"); return(false); } return(joy.buttons[button.button - 1] > 0); }
Texture2D GetJoyTexture(Joy joy) { if (joy.virtualShape == JoyVirtualShape.Circle) { return(circleTexture); } else { return(squarTexture); } }
private void AutoFire3D() { if ((_player3D.ChargeCtr <= 1) && ((_player3D.State == 0) || (_player3D.BreachCtr != 0))) { Joy.Set("B", true, 1); } else if (_player3D.ChargeCtr > 1) { Joy.Set("B", false, 1); } Joy.Set("C", (_levelTime & 1) == 0, 1); }
public void Start() { this.firePosition = this.transform.Find("TankRenderers/TankTurret/firePosition").GetComponent <Transform>(); this.tankInformation = this.GetComponent <TankInfomation>(); this.buller_Scale = 1f; if (this.isLocalPlayer == true) { // 这个主要是要控制坦克joy来动态的给属性firingBullet赋值,因为会同时存在多个坦克,使得joy不知道该是哪个坦克身上的脚本。 this.joy = GameObject.Find("Canvas").transform.Find("YaoGan_ControllFaShe/Joy").GetComponent <Joy>(); this.joy.GetComponent <Joy>().firingBullet = this; } Network.sendRate = 60; }
Vector2 GetVirtualCenter(Joy joy) { JoyParame parame = joy.parame; Vector2 center = Vector2.zero; if (joy.screenDirection == JoyScreenDirection.Left) { center.x = parame.boundary.x + parame.radius; center.y = Screen.height - parame.boundary.y - parame.radius; } else if (joy.screenDirection == JoyScreenDirection.Right) { center.x = Screen.width - parame.boundary.x - parame.radius; center.y = Screen.height - parame.boundary.y - parame.radius; } return(center); }
public double getAxis(Joy joy, SAxis axis) { if (axis.axis == 0 || Math.Abs(axis.axis) > joy.axes.Length) { ROS.Error("Axis " + axis.axis + " out of range, joy has " + joy.axes.Length + " axes"); return(0); } double output = Math.Abs(axis.axis) / axis.axis * joy.axes[Math.Abs(axis.axis) - 1] * axis.factor + axis.offset; // TODO keep or remove deadzone? may not be needed // if (Math.Abs(output) < axis.max_ * 0.2) // { // output = 0.0; // } return(output); }
public void MergeFrom(Hydra other) { if (other == null) { return; } if (other.CtrlNum != 0) { CtrlNum = other.CtrlNum; } if (other.pos_ != null) { if (pos_ == null) { pos_ = new global::Google.Protobuf.VRCom.Position(); } Pos.MergeFrom(other.Pos); } if (other.rot_ != null) { if (rot_ == null) { rot_ = new global::Google.Protobuf.VRCom.Rotation(); } Rot.MergeFrom(other.Rot); } if (other.joy_ != null) { if (joy_ == null) { joy_ = new global::Google.Protobuf.VRCom.Joystick(); } Joy.MergeFrom(other.Joy); } if (other.Trigger != 0F) { Trigger = other.Trigger; } if (other.Buttons != 0) { Buttons = other.Buttons; } }
public void joyAttitudeCallback(Joy joy) { AttitudeCommand attitude = new AttitudeCommand(); ThrustCommand thrust = new ThrustCommand(); YawRateCommand yawrate = new YawRateCommand(); attitude.header.Stamp = thrust.header.Stamp = yawrate.header.Stamp = ROS.GetTime(); attitude.header.Frame_id = yawrate.header.Frame_id = baseStabilizedFrame; thrust.header.Frame_id = baseLinkFrame; attitude.roll = (float)(-getAxis(joy, sAxes.y) * Math.PI / 180.0); attitude.pitch = (float)(getAxis(joy, sAxes.x) * Math.PI / 180.0); if (getButton(joy, sButtons.slow)) { attitude.roll *= (float)slowFactor; attitude.pitch *= (float)slowFactor; } attitudePublisher.publish(attitude); thrust.thrust = (float)getAxis(joy, sAxes.thrust); thrustPublisher.publish(thrust); yawrate.turnrate = (float)(getAxis(joy, sAxes.yaw) * Math.PI / 180.0); if (getButton(joy, sButtons.slow)) { yawrate.turnrate *= (float)slowFactor; } yawRatePublisher.publish(yawrate); if (getButton(joy, sButtons.stop)) { enableMotors(false); } else if (getButton(joy, sButtons.go)) { enableMotors(true); } }
void joyPoseCallback(Joy joy) { Messages.std_msgs.Time now = ROS.GetTime(); double dt = 0.0; if ((pose.header.Stamp.data.sec == 0 && pose.header.Stamp.data.nsec == 0)) { TimeData td = (now - pose.header.Stamp).data; double sec = td.toSec(); dt = Mathf.Max(0, Mathf.Min(1f, (float)sec)); } if (getButton(joy, sButtons.go)) { pose.header.Stamp = ROS.GetTime(); pose.header.Frame_id = worldFrame; pose.pose.position.x += (Math.Cos(yaw) * getAxis(joy, sAxes.x) - Math.Sin(yaw) * getAxis(joy, sAxes.y)) * dt; pose.pose.position.y += (Math.Cos(yaw) * getAxis(joy, sAxes.y) + Math.Sin(yaw) * getAxis(joy, sAxes.x)) * dt; pose.pose.position.z += getAxis(joy, sAxes.z) * dt; yaw += getAxis(joy, sAxes.yaw) * Math.PI / 180.0 * dt; tf.net.emQuaternion q = tf.net.emQuaternion.FromRPY(new tf.net.emVector3(0, 0, yaw)); pose.pose.orientation = q.ToMsg(); PoseGoal goal = new PoseGoal(); goal.target_pose = pose; poseClient.sendGoal(goal); } if (getButton(joy, sButtons.interrupt)) { poseClient.cancelGoalsAtAndBeforeTime(ROS.GetTime()); } if (getButton(joy, sButtons.stop)) { landingClient.sendGoalAndWait(new LandingGoal(), new Messages.std_msgs.Duration(new TimeData(10, 0)), new Messages.std_msgs.Duration(new TimeData(10, 0))); } }
void Handler([NotNull] Joy joy) { bool newHasMain = (joy.Buttons.Length == 1 && joy.Buttons[0] == 0) || joy.Buttons.Length == 2; //Debug.Log("newhasmain " + newHasMain); if (currentHasMain != newHasMain) { if (newHasMain) { OnMainDown(); } else { OnMainUp(); } currentHasMain = newHasMain; } bool newHasAlt = (joy.Buttons.Length == 1 && joy.Buttons[0] == 1) || joy.Buttons.Length == 2; //Debug.Log("newhasalt" + newHasAlt); if (currentHasAlt != newHasAlt) { if (newHasAlt) { OnAltDown(); } else { OnAltUp(); } currentHasAlt = newHasAlt; } }
protected override void ReceiveMessage(Joy message) { throw new System.NotImplementedException(); }
Rect GetUIRect(Joy joy) { var uiPoint = GetUIPoint(joy); return(new Rect(uiPoint.x, uiPoint.y, joy.parame.radius * 2, joy.parame.radius * 2)); }
public override void PreFrameCallback() { Gui.ClearText(); if (!Gui.HasGUISurface) { Gui.DrawNew("emu"); } _camX = Mem.ReadS16(Addr2D.CamX) - _left; _camY = Mem.ReadS16(Addr2D.CamY) - _top; switch (Mem.ReadU8(AddrGlobal.GameMode)) { // Dialog screen case 0x00: if (_autofireEnabled) { // This doesn't fully work, but gets > 50% if (Mem.ReadS16(AddrGlobal.TextYSpeed) == -3) { Joy.Set("C", true, 1); } else { Joy.Set("C", false, 1); } } break; case 0xF6: UpdatePlayer3D(); if (_autofireEnabled) { AutoFire3D(); } break; case 0x20: case 0x28: case 0xAC: UpdatePlayer2D(); if (_autofireEnabled) { AutoFire2D(); } break; default: break; } if (!_mapDumpingEnabled || (_mapDumpState == 0)) { Color bg = BackdropColor(); Gui.DrawRectangle(0, 0, _left + 320 + _right, _top, bg, bg); Gui.DrawRectangle(0, 0, _left, _top + 224 + _bottom, bg, bg); Gui.DrawRectangle(_left + 320, 0, _left + 320 + _right, _top + 224 + _bottom, bg, bg); Gui.DrawRectangle(0, _top + 224, _left + 320 + _right, _top + 224 + _bottom, bg, bg); } switch (Mem.ReadU8(AddrGlobal.GameMode)) { case 0x20: case 0x28: case 0xAC: if (_mapDumpState <= 1) { Draw2DHud(); } if (_mapDumpingEnabled) { PreProcessMapDump(); } break; case 0xF6: Draw3DHud(); break; default: break; } _prevF = Mem.ReadU32(AddrGlobal.NonLagFrameCount); }