public void OnShoot() { bool bOpen = false; if (m_player.m_bWithBall) { IM.Number rate_adjustment = IM.Number.zero; if (m_player.shootStrength != null) { m_player.shootStrength.Stop(); rate_adjustment = m_player.shootStrength.rate_adjustment; Debug.Log("Shoot rate adjustment: " + rate_adjustment); } IM.Vector3 target = m_basket.m_vShootTarget; IM.PrecNumber fShootRate = IM.PrecNumber.one; Dictionary <string, uint> data = m_player.m_finalAttrs; Player disturber = null; if (m_player.m_defenseTarget != null) { foreach (Player defenser in m_player.m_defenseTarget.m_team.members) { if (m_player.m_AOD.GetStateByPos(defenser.position) == AOD.Zone.eInvalid) { continue; } disturber = defenser; break; } } IM.Number fSideEffect = IM.Number.zero; SkillSideEffect effect; if (!m_curExecSkill.skill.side_effects.TryGetValue((int)SkillSideEffect.Type.eShootRate, out effect)) { Debug.Log("No side effect data."); } else { fSideEffect = effect.value; } IM.Number fDisturb = IM.Number.zero; if (disturber != null) { Dictionary <string, uint> disturberData = disturber.m_finalAttrs; uint disturb = disturberData["disturb"]; uint disturb_attr = 0; disturber.m_skillSystem.HegdingToValue("addn_disturb", ref disturb_attr); disturb += disturb_attr; uint fAntiDisturb = data["anti_disturb"]; uint anti_disturb_attr = 0; m_player.m_skillSystem.HegdingToValue("addn_anti_disturb", ref anti_disturb_attr); fAntiDisturb += anti_disturb_attr; if (m_skillArea == Area.eFar) { fDisturb = shootFarHedging.Calc(new IM.Number((int)disturb), new IM.Number((int)fAntiDisturb)); } else if (m_skillArea == Area.eNear) { fDisturb = shootNearHedging.Calc(new IM.Number((int)disturb), new IM.Number((int)fAntiDisturb)); } else if (m_skillArea == Area.eMiddle) { fDisturb = shootMiddleHedging.Calc(new IM.Number((int)disturb), new IM.Number((int)fAntiDisturb)); } if (disturber.m_StateMachine.m_curState.m_eState == PlayerState.State.eDefense) { fDisturb *= IM.Number.one; } else if (disturber.m_StateMachine.m_curState.m_eState == PlayerState.State.eBlock) { fDisturb *= IM.Number.one; } else { fDisturb = IM.Number.zero; //Debug.Log("Can't disturb, state: " + disturber.m_StateMachine.m_curState.m_eState); } } Debugger.Instance.m_steamer.message = " Disturb: " + fDisturb + " "; IM.Number fDistToTarget = GameUtils.HorizonalDistance(m_player.position, m_basket.m_vShootTarget); Debugger.Instance.m_steamer.message += "Distance to basket: " + fDistToTarget; uint uShootData = 0; uint uShootSkill = 0; uint uShootFarData = 0; if (m_skillArea == Area.eFar) { data.TryGetValue("shoot_far_dist", out uShootFarData); IM.Number maxDistance = uShootFarData * new IM.Number(0, 005) + new IM.Number(9, 150); //long distance influent IM.Number fLongDistanceInfluent = IM.Number.one; if (fDistToTarget > maxDistance) { fLongDistanceInfluent = new IM.Number(0, 100); } IM.Number reduceScale = m_match.GetAttrReduceScale("shoot_far", m_player); data.TryGetValue("shoot_far", out uShootData); m_player.m_skillSystem.HegdingToValue("shoot_far", ref uShootSkill); //m_player.m_skillSystem.GetAttrValueByName("shoot_far", ref uShootSkill); fShootRate = ((uShootData + uShootSkill) * reduceScale * shootFarMultiply + shootFarAdd) * (IM.Number.one - fDisturb) * fLongDistanceInfluent + fSideEffect; } else if (m_skillArea == Area.eNear) { IM.Number reduceScale = m_match.GetAttrReduceScale("shoot_near", m_player); data.TryGetValue("shoot_near", out uShootData); m_player.m_skillSystem.HegdingToValue("shoot_near", ref uShootSkill); //m_player.m_skillSystem.GetAttrValueByName("shoot_near", ref uShootSkill); fShootRate = ((uShootData + uShootSkill) * shootNearMultiply + shootNearAdd) * reduceScale * (IM.Number.one - fDisturb) + fSideEffect; } else if (m_skillArea == Area.eMiddle) { IM.Number reduceScale = m_match.GetAttrReduceScale("shoot_middle", m_player); data.TryGetValue("shoot_middle", out uShootData); m_player.m_skillSystem.HegdingToValue("shoot_middle", ref uShootSkill); //m_player.m_skillSystem.GetAttrValueByName("shoot_middle", ref uShootSkill); fShootRate = ((uShootData + uShootSkill) * shootMiddleMultiply + shootMiddleAdd) * reduceScale * (IM.Number.one - fDisturb) + fSideEffect; } fShootRate = IM.Math.Max(fShootRate + rate_adjustment, IM.Number.zero); SkillSpec skillSpec = m_player.GetSkillSpecialAttribute(SkillSpecParam.eShoot_rate); if (skillSpec.paramOp == SkillSpecParamOp.eAdd) { fShootRate += skillSpec.value; } else if (skillSpec.paramOp == SkillSpecParamOp.eMulti) { fShootRate *= skillSpec.value; } fShootRate = m_match.AdjustShootRate(m_player, (IM.Number)fShootRate); //bool sumValue = false; //if (!m_ball.m_bBlockSuccess) // sumValue = m_stateMachine.attackRandom.AdjustRate(ref fShootRate, m_match.GetScore(m_skillArea == Area.eFar ? 3 : 2)); //if (!m_ball.m_bBlockSuccess && solution.m_bSuccess && sumValue) // m_stateMachine.attackRandom.SumValue(m_match.GetScore(m_skillArea == Area.eFar ? 3 : 2)); bOpen = _CheckOpenShoot(); if (bOpen) { fShootRate *= new IM.Number(1, 300); fShootRate = IM.Math.Min(fShootRate, IM.Number.one); if (m_skillArea == Area.eFar) { ++m_player.mStatistics.data.far_open_shoot; } else if (m_skillArea == Area.eNear) { ++m_player.mStatistics.data.near_open_shoot; } else if (m_skillArea == Area.eMiddle) { ++m_player.mStatistics.data.mid_open_shoot; } } if (m_match.m_bTimeUp) { fShootRate = IM.Number.zero; } Debug.LogWarning("shoot rate==>>>" + fShootRate.ToString()); ShootSolution solution; if (m_ball.m_bBlockSuccess && m_ball.m_shootSolution != null) { solution = m_ball.m_shootSolution; } else { solution = m_match.GetShootSolution(m_match.mCurScene.mBasket, m_skillArea, m_player, fShootRate, ShootSolution.Type.Shoot); } m_ball.m_shootSolution = solution; Debug.Log("shoot ball success: " + solution.m_bSuccess); IM.Vector3 vPos = m_ball.position; uint ballId = m_ball.m_id; UBasketball curBall = m_ball; m_player.DropBall(curBall); curBall.position = vPos; curBall.OnShoot(m_player, m_skillArea, false); ShootSolution.SShootCurve shootCurve = curBall.m_shootSolution.m_ShootCurveList[0]; IM.Number fFlyTime = shootCurve.fTime; curBall.m_castedSkill = m_curExecSkill; Debugger.Instance.m_steamer.message = " Final shoot rate: " + fShootRate; } m_player.eventHandler.NotifyAllListeners(PlayerActionEventHandler.AnimEvent.eShoot, (System.Object)bOpen); if (m_skillArea == Area.eFar) { PlaySoundManager.Instance.PlaySound(MatchSoundEvent.Shot3Pt); } else { PlaySoundManager.Instance.PlaySound(MatchSoundEvent.Shot2Pt); } PlaySoundManager.Instance.PlaySound(MatchSoundEvent.Shoot); }
public void OnLayup() { m_turningSpeed = IM.Number.zero; bool bShootOut = false; bool bOpen = false; if (m_player.m_bWithBall) { /* * bool sumValue = false; * if (!m_ball.m_bBlockSuccess) * sumValue = m_stateMachine.attackRandom.AdjustRate(ref m_layupRate, m_match.GetScore(2)); */ ShootSolution solution; if (m_ball.m_bBlockSuccess && m_ball.m_shootSolution != null) { solution = m_ball.m_shootSolution; } else { solution = m_match.GetShootSolution(m_match.mCurScene.mBasket, m_skillArea, m_player, m_layupRate, ShootSolution.Type.Layup); } //if (!m_ball.m_bBlockSuccess && solution.m_bSuccess && sumValue) // m_stateMachine.attackRandom.SumValue(m_match.GetScore(2)); m_ball.m_shootSolution = solution; IM.Vector3 vPos = m_ball.position; uint uBallId = m_ball.m_id; UBasketball curBall = m_ball; m_player.DropBall(curBall); curBall.position = vPos; curBall.m_castedSkill = m_curExecSkill; curBall.OnShoot(m_player, m_skillArea, true); ShootSolution.SShootCurve shootCurve = curBall.m_shootSolution.m_ShootCurveList[0]; IM.Number fFlyTime = shootCurve.fTime; bShootOut = true; bOpen = _CheckOpenShoot(); if (bOpen) { //m_layupRate *= 1.3f; //m_layupRate = Mathf.Min(m_layupRate, 1.0f); if (m_skillArea == Area.eNear) { ++m_player.mStatistics.data.layup_near_open_shoot; } else if (m_skillArea == Area.eMiddle) { ++m_player.mStatistics.data.layup_mid_open_shoot; } } Debugger.Instance.m_steamer.message = " Final shoot rate: " + m_layupRate; } m_bRateFixed = true; m_player.eventHandler.NotifyAllListeners(PlayerActionEventHandler.AnimEvent.eLayup, (System.Object)bOpen); if (bShootOut) { AudioClip clip = AudioManager.Instance.GetClip("Misc/3point_01"); if (clip != null) { AudioManager.Instance.PlaySound(clip); } } }