GameObject GetHandShadowAxis(int seat, PlayerType handStyle, HandDirection handDir, int shadowIdx) { if (handStyle == PlayerType.FEMALE) { if (handDir == HandDirection.LeftHand) { return(femaleLHandShadow[shadowIdx, seat]); } else { return(femaleRHandShadow[shadowIdx, seat]); } } else { if (handDir == HandDirection.LeftHand) { return(maleLHandShadow[shadowIdx, seat]); } else { return(maleRHandShadow[shadowIdx, seat]); } } }
/// <summary> /// 获取麻将桌目标牌到手部相对偏移值列表 /// </summary> /// <param name="seat"></param> /// <param name="handStyle"></param> /// <param name="handDir"></param> /// <returns></returns> List <Vector3> GetDeskMjHandOffsetList(int seat, PlayerType handStyle, HandDirection handDir) { if (handStyle == PlayerType.FEMALE) { if (handDir == HandDirection.LeftHand) { return(mjToFemaleLHandOffsetList[seat]); } else { return(mjToFemaleRHandOffsetList[seat]); } } else { if (handDir == HandDirection.LeftHand) { return(mjToMaleLHandOffsetList[seat]); } else { return(mjToMaleRHandOffsetList[seat]); } } }
GameObject GetHandBone(int seat, PlayerType handStyle, HandDirection handDir, int boneIdx) { if (handStyle == PlayerType.FEMALE) { if (handDir == HandDirection.LeftHand) { return(femaleLHandMjBone[boneIdx, seat]); } else { return(femaleRHandMjBone[boneIdx, seat]); } } else { if (handDir == HandDirection.LeftHand) { return(maleLHandMjBone[boneIdx, seat]); } else { return(maleRHandMjBone[boneIdx, seat]); } } }
void CreateHands(PlayerType handStyle, HandDirection handDir) { string sexStr = "Female"; GameObject prefabHand = mjAssets.defaultPrefabDict[(int)PrefabIdx.FEMALE_HAND][0]; if (handStyle == PlayerType.MALE) { //prefabHand = mjAssets.maleHand; sexStr = "Male"; } for (int i = 0; i < 4; i++) { GameObject cpHand = Object.Instantiate(prefabHand); if (handDir == HandDirection.LeftHand) { cpHand.name = sexStr + "LeftHand" + i; Vector3 scale = cpHand.transform.localScale; cpHand.transform.localScale = new Vector3(scale.x, scale.y, -scale.z); } else { cpHand.name = sexStr + "RightHand" + i; } cpHand.transform.SetParent(gameObject.transform, false); cpHand.SetActive(false); SaveHand(i, handStyle, handDir, cpHand); SaveHandBones(i, handStyle, handDir); } }
public void ChangeHandDirection(HandDirection whichDirection) { if (whichDirection == HandDirection.Left) { lifeUpLeftHand(); liftDownRightHand(); Debug.Log("Lifting Up Left Hand..."); } if (whichDirection == HandDirection.Right) { lifeUpRightHand(); lifeDownLeftHand(); Debug.Log("Lifting Up Right Hand..."); } if (whichDirection == HandDirection.Normal) { /* * liftDownRightHand(); * lifeDownLeftHand(); */ // Debug.Log("Lifting Down Both Hands..."); } }
/// <summary> /// 获取指定类型的手部动画组件 /// </summary> /// <param name="seat"></param> /// <param name="handStyle"></param> /// <param name="handDir"></param> /// <returns></returns> Animation GetHandAnimation(int seat, PlayerType handStyle, HandDirection handDir) { if (handStyle == PlayerType.FEMALE) { if (handDir == HandDirection.LeftHand) { return(femaleLHandsAnimation[seat]); } else { return(femaleRHandsAnimation[seat]); } } else { if (handDir == HandDirection.LeftHand) { return(maleLHandsAnimation[seat]); } else { return(maleRHandsAnimation[seat]); } } }
public StickDetector() { leftHand = new HandDirection(false); rightHand = new HandDirection(true); doubleHandTimer = 0; isDoubleHanded = false; isRightHanded = true; }
void Start() { screenTouch = GameObject.Find("Canvas").transform.Find("SimpleTouch").GetComponent <SimpleTouchController>(); characterController = GetComponent <CharacterController>(); moveTarget = new Vector3(0, 0, RunSpeed); highFiveController = GetComponent <HighFiveController>(); currentHandDirection = HandDirection.Normal; OnHandDirectionChanged(); }
void SaveHand(int seat, PlayerType handStyle, HandDirection handDir, GameObject saveHand) { if (handStyle == PlayerType.FEMALE) { if (handDir == HandDirection.LeftHand) { femaleLHands[seat] = saveHand; femaleLHandsAnimation[seat] = saveHand.GetComponent <Animation>(); if (mjAssets.handActionDataInfoDicts.ContainsKey(saveHand.name)) { femaleLHandsActionDataInfo[seat] = mjAssets.handActionDataInfoDicts[saveHand.name]; } } else { femaleRHands[seat] = saveHand; femaleRHandsAnimation[seat] = saveHand.GetComponent <Animation>(); if (mjAssets.handActionDataInfoDicts.ContainsKey(saveHand.name)) { femaleRHandsActionDataInfo[seat] = mjAssets.handActionDataInfoDicts[saveHand.name]; } } } else { if (handDir == HandDirection.LeftHand) { maleLHands[seat] = saveHand; maleLHandsAnimation[seat] = saveHand.GetComponent <Animation>(); if (mjAssets.handActionDataInfoDicts.ContainsKey(saveHand.name)) { maleLHandsActionDataInfo[seat] = mjAssets.handActionDataInfoDicts[saveHand.name]; } } else { maleRHands[seat] = saveHand; maleRHandsAnimation[seat] = saveHand.GetComponent <Animation>(); if (mjAssets.handActionDataInfoDicts.ContainsKey(saveHand.name)) { maleRHandsActionDataInfo[seat] = mjAssets.handActionDataInfoDicts[saveHand.name]; } } } }
void SetHandsActionsPlaySpeedFromSetting(int seatIdx, PlayerType handStyle, HandDirection handDir) { Animation anim = GetHandAnimation(seatIdx, handStyle, handDir); Dictionary <string, ActionDataInfo> actionDataDict = GetHandActionDataDict(seatIdx, handStyle, handDir); AnimationClip clip; foreach (var item in actionDataDict) { clip = anim.GetClip(item.Key); if (clip != null) { anim[item.Key].speed = item.Value.speed; } } }
public void Go(Coordinate coordinate, HandDirection direction) { StringBuilder sb = new StringBuilder(); sb.Append($"100GO XY({coordinate.X},{coordinate.Y},{coordinate.Z},{coordinate.U})"); if (direction != HandDirection.Default) { sb.Append($" /{ Enum.GetName(typeof(HandDirection), direction)[0]}"); } var result = _cmdClient.SendCommand(sb.ToString()); if (result != "0") { _cmdClient.SendCommand("100Reset Error"); } }
void SetHandsActionsPlaySpeed(int seatIdx, PlayerType handStyle, HandDirection handDir) { Animation anim = GetHandAnimation(seatIdx, handStyle, handDir); float scale = 1.6f; float scale2 = 1f; anim["DaPai1"].speed = 2f * scale; // anim["DaPai1_b"].speed = 1.5f; anim["DaPai1_1_a"].speed = 1f * scale; anim["DaPai1_1_b"].speed = 3.5f; anim["DaPai1EndTaiHand1"].speed = 0.4f * scale; anim["DaPai1EndTaiHand2"].speed = 0.4f * scale; anim["DaPai1EndZhengPai"].speed = 1f; anim["DaPai1EndZhengPaiEndTaiHand"].speed = 1f; anim["DaPai1EndMovPai1"].speed = 1f * scale; anim["DaPai1EndMovPai1EndTaiHand1"].speed = 1f * scale; anim["DaPai1EndMovPai1EndTaiHand2"].speed = 1f * scale; anim["DaPai1EndMovPai1EndZhengPai"].speed = 1f * scale; anim["DaPai1EndMovPai1EndZhengPaiEndTaiHand"].speed = 1f; anim["DaPai1EndMovPai2"].speed = 1.6f * scale; anim["DaPai1EndMovPai2EndTaiHand1"].speed = 1.3f * scale; anim["DaPai1EndMovPai2EndTaiHand2"].speed = 1.3f * scale; anim["DaPai2EndMovPai"].speed = 1f * scale; anim["DaPai2EndMovPaiEndTaiHand1"].speed = 1f * scale; anim["DaPai2EndMovPaiEndTaiHand2"].speed = 1f * scale; anim["DaPai3"].speed = 1f * scale; anim["DaPai3EndTaiHand"].speed = 1f * scale; anim["FirstTaiHand1EndHuPai"].speed = 1f * scale2; anim["FirstTaiHand1EndHuPaiEndTaiHand"].speed = 1f * scale2; anim["FirstTaiHand2EndDaPai4"].speed = 1.5f; anim["FirstTaiHand2EndDaPai4EndTaiHand"].speed = 1f * scale2; anim["FirstHand"].speed = 0.2f; anim["zhuaHandPai"].speed = 1f; anim["PutDownHandPai1"].speed = 1.6f * scale; anim["PutDownHandPai2"].speed = 1.6f * scale; anim["TaiHand"].speed = 2f * scale; float n = 0.3f / anim.GetClip("MovHandPai").length; anim["MovHandPai"].speed = 1f / n; }
float GetHandActionWaitTime(int seatIdx, PlayerType handStyle, HandDirection handDir, string actionName) { Dictionary <string, ActionDataInfo> actionDataDict = GetHandActionDataDict(seatIdx, handStyle, handDir); Animation anim = GetHandAnimation(seatIdx, handStyle, handDir); float waitTime = anim.GetClip(actionName).length / anim[actionName].speed; if (actionDataDict == null) { return(waitTime); } if (actionDataDict.ContainsKey(actionName)) { waitTime *= actionDataDict[actionName].crossFadeNormalTime; } else { return(waitTime); } return(waitTime); }
public void MovePlayer(float xPos_) { if (xPos_ < 0 && currentHandDirection != HandDirection.Left) { currentHandDirection = HandDirection.Left; OnHandDirectionChanged(); } else if (xPos_ > 0 && currentHandDirection != HandDirection.Right) { currentHandDirection = HandDirection.Right; OnHandDirectionChanged(); } else if (xPos_ == 0 && currentHandDirection != HandDirection.Normal) { currentHandDirection = HandDirection.Normal; OnHandDirectionChanged(); } var xPos = transform.position.x + (xPos_ * Time.deltaTime * MoveSpeed); moveTarget = new Vector3(MoveSpeed * xPos_, 0, RunSpeed); }
public static WaranResult JumpInPos(this ScaraRobot scaraRobot, Coordinate coordinate, HandDirection direction, bool bCheckHandleSys = false, bool bmauanl = false, int nTimeout = 20000) { logger.Info($"JumpInPos start pos{coordinate.X},{coordinate.Y},{coordinate.Z},{coordinate.U}"); try { WaranResult waran = WaranResult.Failture; bool bcmd = ScaraRobot.GetInstance().Jump(coordinate, direction, getLimit(coordinate)); DoWhile doWhile = new DoWhile((nTimeed, doWhile2, bmanual, objs) => { double dfine = 0.05; bool bInPosX = Math.Abs(ScaraRobot.GetInstance().CurrentPosition.X - coordinate.X) < dfine; bool bInPosY = Math.Abs(ScaraRobot.GetInstance().CurrentPosition.Y - coordinate.Y) < dfine; // bool bInPosZ = Math.Abs(ScaraRobot.GetInstance().CurrentPosition.Z - coordinate.Z) < dfine; bool bInPosU = Math.Abs(ScaraRobot.GetInstance().CurrentPosition.U - coordinate.U) < 0.1; bool bInPos = bInPosX && bInPosY && true && bInPosU; if (!bmanual) { if (GlobalVariable.g_StationState == StationState.StationStatePause) { logger.Info($"JumpInPos 程序状态: {GlobalVariable.g_StationState }"); ScaraRobot.GetInstance().SetStopActionFlag(); return(WaranResult.CheckAgain); } else if (GlobalVariable.g_StationState == StationState.StationStateRun) { Thread.Sleep(50); bInPosX = Math.Abs(ScaraRobot.GetInstance().CurrentPosition.X - coordinate.X) < dfine; bInPosY = Math.Abs(ScaraRobot.GetInstance().CurrentPosition.Y - coordinate.Y) < dfine; // bInPosZ = Math.Abs(ScaraRobot.GetInstance().CurrentPosition.Z - coordinate.Z) < dfine; bInPosU = Math.Abs(ScaraRobot.GetInstance().CurrentPosition.U - coordinate.U) < 0.1; bInPos = bInPosX && bInPosY && true && bInPosU; if (!bInPos) { Coordinate coordinatetemp = ScaraRobot.GetInstance().GetCurrentImmediately(); bInPosX = Math.Abs(coordinatetemp.X - coordinate.X) < dfine; bInPosY = Math.Abs(coordinatetemp.Y - coordinate.Y) < dfine; // bInPosZ = Math.Abs(coordinatetemp.Z - coordinate.Z) < dfine; bInPosU = Math.Abs(coordinatetemp.U - coordinate.U) < 0.1; bInPos = bInPosX && bInPosY && true && bInPosU; } logger.Info($"JumpInPos 程序状态:{GlobalVariable.g_StationState} bInPos {bInPos}, 目标位置 {coordinate.X},{coordinate.Y},{coordinate.Z},{coordinate.U}" + $"实际位置: {ScaraRobot.GetInstance().CurrentPosition.X},{ScaraRobot.GetInstance().CurrentPosition.Y},{ScaraRobot.GetInstance().CurrentPosition.Z},{ScaraRobot.GetInstance().CurrentPosition.U}"); if (bInPos) { return(WaranResult.Run); } else if (ScaraRobot.GetInstance().InPos&& !bInPos) { ScaraRobot.GetInstance().ReasetStopActionFlag(); ScaraRobot.GetInstance().Jump(coordinate, direction, getLimit(coordinate)); return(WaranResult.CheckAgain); } } } if (nTimeed > nTimeout) { logger.Info($"JumpInPos 程序状态:{GlobalVariable.g_StationState} bInPos {bInPos}, 超时, 目标位置 {coordinate.X},{coordinate.Y},{coordinate.Z},{coordinate.U}" + $"实际位置: {ScaraRobot.GetInstance().CurrentPosition.X},{ScaraRobot.GetInstance().CurrentPosition.Y},{ScaraRobot.GetInstance().CurrentPosition.Z},{ScaraRobot.GetInstance().CurrentPosition.U}"); ScaraRobot.GetInstance().SetStopActionFlag(); ScaraRobot.GetInstance().SetStopActionFlag(); ScaraRobot.GetInstance().ReasetStopActionFlag(); logger.Info($"JumpInPos 程序状态:{GlobalVariable.g_StationState} bInPos {bInPos}, 复位, 目标位置 {coordinate.X},{coordinate.Y},{coordinate.Z},{coordinate.U}" + $"实际位置: {ScaraRobot.GetInstance().CurrentPosition.X},{ScaraRobot.GetInstance().CurrentPosition.Y},{ScaraRobot.GetInstance().CurrentPosition.Z},{ScaraRobot.GetInstance().CurrentPosition.U}"); return(WaranResult.TimeOut); } if (ScaraRobot.GetInstance().InPos&& bInPos) { return(WaranResult.Run); } else { return(WaranResult.CheckAgain); } } , 30000); return(doWhile.doSomething2(null, doWhile, bmauanl, null)); } catch (Exception ex) { ScaraRobot.GetInstance().SetStopActionFlag(); ScaraRobot.GetInstance().SetStopActionFlag(); ScaraRobot.GetInstance().ReasetStopActionFlag(); throw ex; } }
/// <summary> /// 手举起来或者放下 /// </summary> public void HandUpAndDown(HandDirection hand) { _ischanging = true; switch (hand) { case HandDirection.R: _rightImgIndex = 0; break; case HandDirection.L: _leftImgIndex = LeftCount.Length; break; } _nextIndex = _midCount; }
public void Init() { leftImg.Visibility = SeesawManager.Instance.HandDirection == HandDirection.L ? Visibility.Visible : Visibility.Collapsed; rightImg.Visibility = SeesawManager.Instance.HandDirection == HandDirection.L ? Visibility.Collapsed : Visibility.Visible; Tuple<Uri, Uri> page1 = HandOption.Instance.Page1Img; Tuple<Uri, Uri> page2 = HandOption.Instance.Page2Img; Tuple<Uri, Uri> page3 = HandOption.Instance.Page3Img; Tuple<Uri, Uri> page4 = HandOption.Instance.Page4Img; img1.Source = new BitmapImage(page1.Item2); img2.Source = new BitmapImage(page2.Item2); img3.Source = new BitmapImage(page3.Item2); img4.Source = new BitmapImage(page4.Item2); demesion1.Source = new BitmapImage(page1.Item1); demesion2.Source = new BitmapImage(page2.Item1); demesion3.Source = new BitmapImage(page3.Item1); demesion4.Source = new BitmapImage(page4.Item1); currentDirection = SeesawManager.Instance.HandDirection; SeesawManager.Instance.HandDirection = HandDirection.None; SeesawManager.Instance.LeftHandTimes = SeesawManager.Instance.RightHandTimes = 0; HandOption.Instance.SetInit(); }
void SaveHandBones(int seat, PlayerType handStyle, HandDirection handDir) { //插牌手部位置节点路径 string[] chaPaiNodePathNames = new string[] { "rShldrTwist", "rForearmBend", "rForearmTwist", "rHand", "rThumb1", "rThumb2", "rThumb3" }; //打牌手部位置节点路径 string[] daPaiNodePathNames = new string[] { "rShldrTwist", "rForearmBend", "rForearmTwist", "rHand", "rCarpal1", "rIndex1", "rIndex2", "rIndex3", "Bone001" }; //打牌手部位置节点路径2 string[] daPaiNodePathNames2 = new string[] { "rShldrTwist", "rForearmBend", "rForearmTwist", "rHand", "rThumb1", "rThumb2", "rThumb3", "Bone002" }; //打牌手部阴影1 string[] handShadowPathNames1 = new string[] { "rShldrTwist", "shadow0" }; string[] handShadowPathNames2 = new string[] { "rShldrTwist", "shadow1" }; string[] handShadowPathNames3 = new string[] { "rShldrTwist", "shadow2" }; if (handStyle == PlayerType.FEMALE) { if (handDir == HandDirection.LeftHand) { femaleLHandMjBone[2, seat] = GetNodeTransformByNodePathNames(femaleLHands[seat], daPaiNodePathNames2); femaleLHandMjBone[1, seat] = GetNodeTransformByNodePathNames(femaleLHands[seat], daPaiNodePathNames); femaleLHandMjBone[0, seat] = GetNodeTransformByNodePathNames(femaleLHands[seat], chaPaiNodePathNames); femaleLHandShadow[0, seat] = GetNodeTransformByNodePathNames(femaleLHands[seat], handShadowPathNames1); femaleLHandShadow[1, seat] = GetNodeTransformByNodePathNames(femaleLHands[seat], handShadowPathNames2); femaleLHandShadow[2, seat] = GetNodeTransformByNodePathNames(femaleLHands[seat], handShadowPathNames3); } else { femaleRHandMjBone[2, seat] = GetNodeTransformByNodePathNames(femaleRHands[seat], daPaiNodePathNames2); femaleRHandMjBone[1, seat] = GetNodeTransformByNodePathNames(femaleRHands[seat], daPaiNodePathNames); femaleRHandMjBone[0, seat] = GetNodeTransformByNodePathNames(femaleRHands[seat], chaPaiNodePathNames); femaleRHandShadow[0, seat] = GetNodeTransformByNodePathNames(femaleRHands[seat], handShadowPathNames1); femaleRHandShadow[1, seat] = GetNodeTransformByNodePathNames(femaleRHands[seat], handShadowPathNames2); femaleRHandShadow[2, seat] = GetNodeTransformByNodePathNames(femaleRHands[seat], handShadowPathNames3); } } else { if (handDir == HandDirection.LeftHand) { maleLHandMjBone[2, seat] = GetNodeTransformByNodePathNames(maleLHands[seat], daPaiNodePathNames2); maleLHandMjBone[1, seat] = GetNodeTransformByNodePathNames(maleLHands[seat], daPaiNodePathNames); maleLHandMjBone[0, seat] = GetNodeTransformByNodePathNames(maleLHands[seat], chaPaiNodePathNames); maleLHandShadow[0, seat] = GetNodeTransformByNodePathNames(maleLHands[seat], handShadowPathNames1); maleLHandShadow[1, seat] = GetNodeTransformByNodePathNames(maleLHands[seat], handShadowPathNames2); maleLHandShadow[2, seat] = GetNodeTransformByNodePathNames(maleLHands[seat], handShadowPathNames3); } else { maleRHandMjBone[2, seat] = GetNodeTransformByNodePathNames(maleRHands[seat], daPaiNodePathNames2); maleRHandMjBone[1, seat] = GetNodeTransformByNodePathNames(maleRHands[seat], daPaiNodePathNames); maleRHandMjBone[0, seat] = GetNodeTransformByNodePathNames(maleRHands[seat], chaPaiNodePathNames); maleRHandShadow[0, seat] = GetNodeTransformByNodePathNames(maleRHands[seat], handShadowPathNames1); maleRHandShadow[1, seat] = GetNodeTransformByNodePathNames(maleRHands[seat], handShadowPathNames2); maleRHandShadow[2, seat] = GetNodeTransformByNodePathNames(maleRHands[seat], handShadowPathNames3); } } }
Dictionary <string, ActionDataInfo> GetHandActionDataDict(int seat, PlayerType handStyle, HandDirection handDir) { if (handStyle == PlayerType.FEMALE) { if (handDir == HandDirection.LeftHand) { return(femaleLHandsActionDataInfo[seat]); } else { return(femaleRHandsActionDataInfo[seat]); } } else { if (handDir == HandDirection.LeftHand) { return(maleLHandsActionDataInfo[seat]); } else { return(maleRHandsActionDataInfo[seat]); } } }