private void Swing() { self = BattleM.SelfSel; var varWnd = WndManager.FindWnd <MineBallSpinWnd>(); if (m_swingInfo != null) { float offset = (m_move.transform.localEulerAngles.z - 180 + 40) / 80 * 100; if (offset < 0) { offset = 0; } else if (offset > 99) { offset = 100; } ClubparameterConfig clubConfig = ClubparameterDao.Inst.GetCfg((uint)self.Club.Type); if (BattleM.BallInAra == AreaType.PuttingGreen) { m_swingInfo.CurAccuracyOffset = 0; if (clubConfig != null) { m_swingInfo.BattingSpeed = MathUtil.RotateRound(BattleM.GetRollSpeedDir() * clubConfig.MinDistance, m_dragPower, m_ballAngle); } m_swingInfo.CurHookAngle = m_greenAngle; } else { m_swingInfo.CurHookAngle = m_ballAngle; m_swingInfo.CurAccuracyOffset = 50 - offset; m_swingInfo.BattingSpeed = self.NeedSpeed * m_dragPower; } m_swingInfo.Ball = self.Ball; m_swingInfo.Club = self.Club; //m_swingInfo.WindSpeed ; if (varWnd != null) { m_swingInfo.CurFBSpin = varWnd.m_CurFBSpin; //self.Club.BackSpin = varWnd.m_underSpin; m_swingInfo.CurLRSpin = varWnd.m_LRspin; //Debug.Log(m_swingInfo.m_dragAngle+".."+ m_swingInfo.m_downSpin+".."+ m_swingInfo.m_upSpin+"..." + m_swingInfo.m_leftSpin+"..."+ m_swingInfo.m_rightSpin); // Destroy(varWnd); } else { m_swingInfo.CurFBSpin = 0; m_swingInfo.CurLRSpin = 0; } movingValue = m_dragGolfPos; dragDis = Vector3.Distance(m_golfPos, m_dragGolfPos); if (m_GolfboxOut != null && m_GolfboxIn != null) { outScale = m_GolfboxOut.transform.localScale.x; inScale = m_GolfboxIn.transform.localScale.x; DOTween.To(() => outScale, x => outScale = x, 0.8f, 0.1f).OnComplete(() => { m_GolfboxOut.SetActive(false); }); DOTween.To(() => inScale, x => inScale = x, 0.6f, 0.1f).OnComplete(() => { m_GolfboxIn.SetActive(false); }); } DOTween.To(() => movingValue, x => movingValue = x, m_golfPos, 0.1f); isDrag = true; WndManager.DestoryWnd <SwingModeWnd>(0.2f); WndManager.DestoryWnd <BattleMainWnd>(0.2f); } BattleM.SetBattleStatus(BattleStatus.Round_FireBall, m_swingInfo); }
void Update() { if (isDrag) { if (m_GolfboxOut != null && m_GolfboxIn != null && m_golf != null) { m_golf.transform.position = movingValue; m_GolfboxOut.transform.localScale = new Vector3(outScale, outScale, outScale); m_GolfboxIn.transform.localScale = new Vector3(inScale, inScale, inScale); } } if (m_isDrag && m_dragPower > 0.3) { if (m_backGround.gameObject.activeSelf != true) { if (m_backGround != null && m_ring != null && m_arrow != null) { if (BattleM.BallInAra == AreaType.PuttingGreen) { m_move = m_arrowGreenMove; m_backGround.gameObject.SetActive(false); m_ring.gameObject.SetActive(false); m_arrow.gameObject.SetActive(false); m_arrowGreen.gameObject.SetActive(true); m_arrowGreenMove.gameObject.SetActive(true); } else { m_move = m_arrow; m_backGround.gameObject.SetActive(true); m_ring.gameObject.SetActive(true); m_arrow.gameObject.SetActive(true); m_arrowGreen.gameObject.SetActive(false); m_arrowGreenMove.gameObject.SetActive(false); } } } float moveSpeed = 1; if (m_dragPower <= 1.1) { moveSpeed = 1; } else { moveSpeed *= m_dragPower * 2; } rotate += (m_isRotateLeft ? 100 : -100) * Time.deltaTime * speed * moveSpeed; if (rotate > 40) { m_isRotateLeft = false; } else if (rotate < -40) { m_isRotateLeft = true; } m_move.transform.localEulerAngles = new Vector3(0, 0, 180 + rotate); if (m_move == m_arrowGreenMove) { if (m_swingInfo != null) { float offset = (m_move.transform.eulerAngles.z - 180 + 40) / 80 * 100; if (offset < 0) { offset = 0; } else if (offset > 99) { offset = 100; } m_swingInfo.CurAccuracyOffset = offset - 100; self = BattleM.SelfSel; m_swingInfo.Ball = self.Ball; m_swingInfo.Club = self.Club; ClubparameterConfig clubConfig = ClubparameterDao.Inst.GetCfg((uint)self.Club.Type); if (clubConfig != null) { m_swingInfo.BattingSpeed = BattleM.GetRollSpeedDir() * clubConfig.MinDistance * m_dragPower; } m_swingInfo.CurHookAngle = m_greenAngle; //m_swingInfo.WindSpeed ; m_swingInfo.CurFBSpin = 0; m_swingInfo.CurLRSpin = 0; BattleM.SetRollOperation(m_swingInfo); } } else { m_move.GetComponent <RectTransform>().localScale = new Vector3(2, 0.7f + m_dragPower * 0.3f, 1); } // Debug.Log(m_arrow.transform.eulerAngles.z); //if(m_arrow.transform.eulerAngles.z > 179.9&& m_arrow.transform.eulerAngles.z < 180.1 ) //{ // Debug.Log("1"); } else { if (m_arrow != null) { m_arrow.transform.eulerAngles = new Vector3(0, 0, 180); m_arrow.GetComponent <RectTransform>().localScale = new Vector3(2, 0.7f, 1); } if (m_backGround != null && m_ring != null && m_arrow != null) { m_backGround.gameObject.SetActive(false); m_ring.gameObject.SetActive(false); m_arrow.gameObject.SetActive(false); m_arrowGreen.gameObject.SetActive(false); m_arrowGreenMove.gameObject.SetActive(false); } } }