public void OnHandControlClick(HandControl handControl, Piece piece) { if (handControl.HandOwner != GameState.CurrentPlayerColor) { return; } CurrentPiece = piece; }
public static void ControlUp(ControlType c, SteamVR_Input_Sources handType) { HandControl key = new HandControl(c, handType); ControlState state = controls[key]; state.Down = false; state.GetUp = Time.frameCount; controls[key] = state; }
public void SetHandShape(Global.Side side, Global.HandPose handPose) { if (side == Global.Side.LEFT) { HandControl.SetLeftHand((int)handPose); } else if (side == Global.Side.RIGHT) { HandControl.SetRightHand((int)handPose); } }
public override bool Equals(object obj) { if (GetType() != obj.GetType()) { return(false); } HandControl other = (HandControl)obj; return(Control == other.Control && HandType == other.HandType); }
private static void SetControlState(ControlType c, SteamVR_Input_Sources handType, int getDown, bool down, int getUp) { HandControl key = new HandControl(c, handType); ControlState state = controls[key]; state.GetDown = getUp; state.Down = down; state.GetUp = getUp; controls[key] = state; }
public static bool GetControlUp(SteamVR_Input_Sources handType, ControlType c) { HandControl key = new HandControl(c, handType); #if UNITY_NONVRCOMPUTER // Fix for TestHandMover int frameDifference = controls[key].GetUp - Time.frameCount; if (frameDifference == -1) { return(controls[key].GetUp > 10); } return(controls[key].GetUp == Time.frameCount); #else return(controls[key].GetUp == Time.frameCount); #endif }
public override void OnInspectorGUI() { DrawDefaultInspector(); HandControl myScript = (HandControl)target; if (GUILayout.Button("Auto Set")) { myScript.SetRotation(); } if (GUILayout.Button("Reset")) { myScript.Reset(); } if (GUILayout.Button("Do not click this button")) { myScript.OnShot(); } }
public static bool GetControl(SteamVR_Input_Sources handType, ControlType c) { HandControl key = new HandControl(c, handType); return(controls[key].Down); }
/// <summary> /// 反复寻找手柄,炮台,直到找到为止 /// </summary> void Onfind() { if (Player == null) { Player = Recever.rInstance.PlayerData.gameObject.transform.FindChild("_player").gameObject; } else if (Recever.rInstance.PlayerData != null && !Recever.rInstance.IsShaking) { } if (Recever.rInstance.PlayerData != null) { //Debug.Log("PlayerData"); if (HandlerLL == null || HandlerRR == null) { HandlerLL = Recever.rInstance.PlayerData.transform.FindChild("_player").FindChild("FireLL").gameObject; HandlerRR = Recever.rInstance.PlayerData.transform.FindChild("_player").FindChild("FireRR").gameObject; } if (handcontrollsLL == null) { handcontrollsLL = Recever.rInstance.PlayerData.transform.FindChild("Controller (left)").GetComponent <HandControl>(); isfindLL = true; } if (handcontrollsRR == null) { handcontrollsRR = Recever.rInstance.PlayerData.transform.FindChild("Controller (right)").GetComponent <HandControl>(); isfindRR = true; } if (isfindRR) { handcontrollsRR.playercontroller = this; //LineRenderer lineRR = handcontrollsRR.GetComponent<LineRenderer>(); //lineRR.SetPosition(0, lineRR.gameObject.transform.position); //lineRR.SetPosition(1, lineRR.gameObject.transform.position); //lineRR.SetColors(Color.yellow, Color.red); //lineRR.SetWidth(0.02f, 0.02f); //lineRR.material = Resources.Load<Material>("handlerline"); //t_lines.Add(lineRR); } if (isfindLL) { handcontrollsLL.playercontroller = this; //LineRenderer lineLL = handcontrollsLL.GetComponent<LineRenderer>(); //lineLL.SetPosition(0, lineLL.gameObject.transform.position); //lineLL.SetPosition(1, lineLL.gameObject.transform.position); //lineLL.SetColors(Color.yellow, Color.red); //lineLL.SetWidth(0.02f, 0.02f); //lineLL.material = Resources.Load<Material>("handlerline"); //t_lines.Add(lineLL); } } if (!handcontrollsLL || !handcontrollsRR) { //Debug.Log("请检查两个控制器是否同时开启"); } /* //if为测试单机使用: * if (handcontrollsLL == null || handcontrollsRR == null) * { * // //Debug.Log(gameObject.transform.FindChild("_player").FindChild("Controller (left)")); * handcontrollsLL = gameObject.transform.FindChild("Controller (left)").gameObject.GetComponent<HandControl>(); * handcontrollsRR = gameObject.transform.FindChild("Controller (right)").gameObject.GetComponent<HandControl>(); * handray_tempR.origin = handcontrollsLL.transform.position; * handray_tempR.direction = handcontrollsLL.transform.forward; * handray_tempL.origin = handcontrollsRR.transform.position; * handray_tempL.direction = handcontrollsRR.transform.forward; * } * //if为测试单机使用: * if (HandlerLL == null || HandlerRR == null) * { * HandlerLL = gameObject.transform.FindChild("_player").FindChild("FireLL").gameObject; * HandlerRR = gameObject.transform.FindChild("_player").FindChild("FireRR").gameObject; * } * if (Physics.Raycast(handray_tempR, out hand_hitR, 1000f)) * { * //Debug.Log("<color=yellow>" + handray_tempR.origin + handray_tempR.direction + handcontrollsRR.transform.forward + hand_hitR.point + "</color>"); * HandlerRR.transform.LookAt(hand_hitR.point); * //lines[0].SetPosition(1, hand_hitR.point); * // //Debug.Log("<color=red>" + hand_hitR.point + "</color>", gameObject); * * Debug.DrawLine(handcontrollsRR.transform.position, hand_hitR.point); * } * else * { * HandlerRR.transform.LookAt(handray_tempR.origin + handray_tempR.direction * 100f); * // lines[0].SetPosition(1, handray_tempR.origin + handray_tempR.direction * 100f); * } * if (Physics.Raycast(handray_tempL, out hand_hitL, 1000f)) * { * HandlerLL.transform.LookAt(hand_hitL.point); * } * else * { * HandlerLL.transform.LookAt(handray_tempL.origin + handray_tempL.direction * 100f); * }*/ }
public FreeControllerV3WithSnapshot(FreeControllerV3 controller) { this.controller = controller; handControl = controller.GetComponent <HandControl>() ?? controller.GetComponent <HandControlLink>()?.handControl; }
void Pickup() { RaycastHit2D hit = Physics2D.Raycast(firePoint.position, Vector3.up, 1f); if (hit) { if (hit.collider.tag == "Object") { if (Input.GetKeyDown(KeyCode.Space) || Input.GetKey(KeyCode.Space) && handControl == HandControl.Idle) { handControl = HandControl.Pick; SfxManage.instance.SfxPlay(audioSource, audioClip); } else if (handControl == HandControl.Pick) { ObjectController obj = hit.collider.gameObject.GetComponent <ObjectController>(); if (Input.GetButton("Fire1") || Input.GetButtonDown("Fire1")) { SfxManage.instance.SfxPlay(audioSource, ThrowClip); PlayerController.instance.BasicSpeed = PlayerController.instance.SettingSpeed; Rigidbody2D the2D = hit.collider.gameObject.GetComponent <Rigidbody2D>(); the2D.AddForce(firePoint.right * obj.throwSpeed, ForceMode2D.Impulse); obj.isPick = false; obj.isThrow = true; handControl = HandControl.Idle; } if (Input.GetButton("Fire2") || Input.GetButtonDown("Fire2")) { PlayerController.instance.BasicSpeed = PlayerController.instance.SettingSpeed; obj.isPick = false; handControl = HandControl.Idle; } } if (handControl == HandControl.Pick) { PlayerController.instance.BasicSpeed = hit.collider.gameObject.GetComponent <ObjectController>().MoveSpeed; hit.collider.gameObject.GetComponent <Rigidbody2D>().MovePosition(firePoint.position + firePoint.right * Time.fixedDeltaTime); ObjectController obj = hit.collider.gameObject.GetComponent <ObjectController>(); obj.isPick = true; } } if (hit.collider.tag == "Object_Faint") { if (Input.GetKeyDown(KeyCode.Space) || Input.GetKey(KeyCode.Space) && handControl == HandControl.Idle) { handControl = HandControl.Pick; SfxManage.instance.SfxPlay(audioSource, audioClip); } else if (handControl == HandControl.Pick) { ObjectController obj = hit.collider.gameObject.GetComponent <ObjectController>(); obj.isPick = false; if (Input.GetButton("Fire1") || Input.GetButtonDown("Fire1")) { SfxManage.instance.SfxPlay(audioSource, ThrowClip); PlayerController.instance.BasicSpeed = PlayerController.instance.SettingSpeed; Rigidbody2D the2D = hit.collider.gameObject.GetComponent <Rigidbody2D>(); the2D.AddForce(firePoint.right * obj.throwSpeed, ForceMode2D.Impulse); obj.isPick = false; obj.isThrow = true; handControl = HandControl.Idle; } if (Input.GetButton("Fire2") || Input.GetButtonDown("Fire2")) { PlayerController.instance.BasicSpeed = PlayerController.instance.SettingSpeed; obj.isPick = false; handControl = HandControl.Idle; } } if (handControl == HandControl.Pick) { PlayerController.instance.BasicSpeed = hit.collider.gameObject.GetComponent <ObjectController>().MoveSpeed; hit.collider.gameObject.GetComponent <Rigidbody2D>().MovePosition(firePoint.position + firePoint.right * Time.fixedDeltaTime); ObjectController obj = hit.collider.gameObject.GetComponent <ObjectController>(); obj.isPick = true; } } } }