override public void OnEnter(PlayerState lastState) { base.OnEnter(lastState); stealTarget = null; ratio = IM.Number.zero; if (m_ball != null) { m_player.FaceTo(m_ball.position); } bool bValid; m_success = _StealBall(out bValid); if (m_success) { SkillSpec stealSkill = m_player.GetSkillSpecialAttribute(SkillSpecParam.eSteal_get_ball_rate); m_bGetBall = IM.Random.value < stealSkill.value; } ++m_player.mStatistics.data.steal_times; if (bValid) { ++m_player.mStatistics.data.valid_steal_times; } //m_curAction = m_mapAnimType[m_animType]; m_player.animMgr.Play(m_curAction, true).rootMotion.Reset(); PlaySoundManager.Instance.PlaySound(MatchSoundEvent.Steal); }
public static void GetHeightRange(Player player, out IM.Number minHeight, out IM.Number maxHeight, SkillInstance skillInst = null) { minHeight = new IM.Number(1, 600); SkillSpec skillspec = player.GetSkillSpecialAttribute(SkillSpecParam.eRebound_height, skillInst); maxHeight = skillspec.value; }
bool _MatchArea(GameMatch match, SkillInstance skillInstance) { SkillAttr skill = skillInstance.skill; if (skill.area.Count == 0) { return(true); } PlayGround playground = match.mCurScene.mGround; IM.Number fPlayerToNet = GameUtils.HorizonalDistance(match.mCurScene.mBasket.m_vShootTarget, m_player.position); if (skill.action_type == 2) //layup { Area eArea = playground.GetLayupArea(m_player); if (!skill.area.Contains((uint)eArea)) { return(false); } SkillSpec spc = m_player.GetSkillSpecialAttribute(SkillSpecParam.eLayup_dist_min, skillInstance); if (fPlayerToNet < spc.value) { return(false); } spc = m_player.GetSkillSpecialAttribute(SkillSpecParam.eLayup_dist_max, skillInstance); if (fPlayerToNet > spc.value) { return(false); } } else if (skill.action_type == 3) //dunk { Area eArea = playground.GetDunkArea(m_player); if (!skill.area.Contains((uint)eArea)) { return(false); } SkillSpec spc = m_player.GetSkillSpecialAttribute(SkillSpecParam.eDunk_dist_min, skillInstance); if (fPlayerToNet < spc.value) { return(false); } spc = m_player.GetSkillSpecialAttribute(SkillSpecParam.eDunk_dist_max, skillInstance); if (fPlayerToNet > spc.value) { return(false); } } else { Area eArea = playground.GetArea(m_player); if (!skill.area.Contains((uint)eArea)) { return(false); } } return(true); }
public SkillConfig this[SkillSpec x] { get { foreach (var i in data) { if (i.spec.SameSkill(x)) { return(i); } } return(none); } }
override public void OnEnter(PlayerState lastState) { base.OnEnter(lastState); m_player.animMgr.CrossFade(m_curAction, false); m_player.model.SetMainColor(Color.red, false); m_player.m_stamina.m_bEnableRecover = false; m_player.model.EnableGrey(false); m_player.m_moveType = MoveType.eMT_PickAndRoll; SkillSpec skillSpec = m_player.GetSkillSpecialAttribute(SkillSpecParam.ePickAndRoll_range); m_fInfluRadius = skillSpec.value; m_bEnablePickAndRoll = true; m_bOnCollide = false; prNoMove.stop = false; m_bFrozen = true; }
public static bool InBlockArea(Player shooter, Player blocker, IM.Vector3 vNet) { IM.Number fDistance = GameUtils.HorizonalDistance(shooter.position, blocker.position); List <SkillInstance> blocks = blocker.m_skillSystem.GetBasicSkillsByCommand(Command.Block); SkillSpec skillSpec = blocker.GetSkillSpecialAttribute(SkillSpecParam.eBlock_back_dist, blocks[0]); if (fDistance < skillSpec.value) { return(true); } skillSpec = blocker.GetSkillSpecialAttribute(SkillSpecParam.eBlock_front_dist, blocks[0]); if (fDistance > skillSpec.value) { return(false); } IM.Vector3 dirShootToNet = GameUtils.HorizonalNormalized(vNet, shooter.position); IM.Vector3 dirShootToBlocker = GameUtils.HorizonalNormalized(blocker.position, shooter.position); return(IM.Vector3.Angle(dirShootToNet, dirShootToBlocker) < new IM.Number(90)); }
bool _CalcBlockLayup(Player shooter, out bool bBlockable, out bool bBlockInRange, out IM.Number fBlockRate, out IM.Number fBlockValue, out IM.Vector3 attackerPos, out IM.Vector3 vBallDir, out bool bValid) { bBlockable = false; attackerPos = IM.Vector3.zero; fBlockRate = IM.Number.zero; fBlockValue = IM.Number.zero; bBlockInRange = false; vBallDir = GetBallVelocity(); bValid = false; if (shooter == null) { m_failReason = FailReason.NoShooter; return(false); } attackerPos = shooter.position; if (!shooter.m_blockable.blockable) { Debugger.Instance.m_steamer.message = "Out of block range."; Debug.Log("Out of block range."); if (shooter.m_blockable.tooEarly) { m_failReason = FailReason.TooEarly; } else if (shooter.m_blockable.tooLate) { m_failReason = FailReason.TooLate; } return(false); } bBlockable = true; /* * AOD.Zone zone = shooter.m_AOD.GetStateByPos(m_player.position); * if( zone == AOD.Zone.eInvalid ) * { * bBlockInRange = false; * Debugger.Instance.m_steamer.message = "Block failed, not in AOD"; * return false; * } */ if (!InBlockArea(shooter, m_player, m_basket.m_vShootTarget)) { Debugger.Instance.m_steamer.message = "Block failed, not in AOD"; m_failReason = FailReason.InvalidArea; return(false); } bBlockInRange = true; IM.Number fSideEffect = IM.Number.zero; SkillSideEffect effect; if (!m_curExecSkill.skill.side_effects.TryGetValue((int)SkillSideEffect.Type.eBlockRate, out effect)) { Debug.Log("No side effect data."); } else { fSideEffect = effect.value; } Dictionary <string, uint> data = shooter.m_finalAttrs; Dictionary <string, uint> shooterSkillAttr = shooter.GetSkillAttribute(); IM.Number blockAttr = new IM.Number((int)m_player.m_finalAttrs["block"]); IM.Number reduceScale = m_match.GetAttrReduceScale("block", m_player); blockAttr *= reduceScale; SkillInstance shooterSkill = shooter.m_StateMachine.m_curState.m_curExecSkill; { if ((Command)shooterSkill.skill.action_type == Command.Layup) { uint anti_block = 0; shooter.m_skillSystem.HegdingToValue("addn_anti_block", ref anti_block); IM.Number fAntiBlock = new IM.Number((int)(data["anti_block"] + anti_block)); switch (shooterSkill.skill.area[0]) { case 3: //near fBlockRate = layupNearHedging.Calc(blockAttr, fAntiBlock); break; case 2: //middle fBlockRate = layupMiddleHedging.Calc(blockAttr, fAntiBlock); break; default: break; } fBlockRate += fSideEffect; } } SkillSpec skill = m_player.GetSkillSpecialAttribute(SkillSpecParam.eBlock_rate); if (skill.paramOp == SkillSpecParamOp.eAdd) { fBlockRate += skill.value; } else if (skill.paramOp == SkillSpecParamOp.eMulti) { fBlockRate *= skill.value; } SkillSpec skillSpc = shooter.GetSkillSpecialAttribute(SkillSpecParam.eLayup_antiBlock); if (skillSpc.paramOp == SkillSpecParamOp.eAdd) { fBlockRate += skillSpc.value; } else if (skillSpc.paramOp == SkillSpecParamOp.eMulti) { fBlockRate *= skillSpc.value; } fBlockRate = m_match.AdjustBlockRate(shooter, m_player, fBlockRate); bool sumValue = random[shooter].AdjustRate(ref fBlockRate); bValid = true; fBlockValue = IM.Random.value; if (fBlockValue > fBlockRate) { m_failReason = FailReason.Random; return(false); } if (sumValue) { random[shooter].SumValue(); } return(true); }
override public void OnEnter(PlayerState lastState) { base.OnEnter(lastState); Player passTarget = m_player.m_passTarget; if (passTarget == null) { m_stateMachine.SetState(State.eStand); return; } m_interceptor = null; /* * SkillInstance passBasicSkill = m_player.m_skillSystem.GetBasicSkillsByCommand(Command.Pass)[0]; * if( m_curExecSkill.skill.id == passBasicSkill.skill.id ) * { * float fDistance = GameUtils.HorizonalDistance(passTarget.position, m_player.position); * if( fDistance < 10.0f ) * m_animType = AnimType.B_TYPE_0; * else * m_animType = AnimType.B_TYPE_1; * m_curAction = m_mapAnimType[m_animType]; * } */ m_player.FaceTo(passTarget.position); //Debug.Log("Send pass, player id: " + m_player.m_id + " to player: " + passTarget.m_id ); //find the players out between passer and catchers Player defenseTarget = m_player.m_defenseTarget; if (defenseTarget != null) { List <Player> defensers = defenseTarget.m_team.GetSortedPlayersByDistance(m_player, true); foreach (Player defenser in defensers) { Debug.Log("defenser: " + defenser.m_id); } foreach (Player defenser in defensers) { SkillInstance interceptionSkill = null; List <SkillInstance> lstSkillInstances = defenser.m_skillSystem.GetSkillList(SkillType.ACTIVE); foreach (SkillInstance skillInst in lstSkillInstances) { Command type = (Command)skillInst.skill.action_type; if (type == Command.Interception) { interceptionSkill = skillInst; break; } } if (interceptionSkill == null) { continue; } //传球者到接球者方向 IM.Vector3 dirPasserToTarget = GameUtils.HorizonalNormalized(passTarget.position, m_player.position); //防守者在传球者身后 IM.Vector3 dirPasserToDef = GameUtils.HorizonalNormalized(defenser.position, m_player.position); IM.Number proj = IM.Vector3.Dot(dirPasserToDef, dirPasserToTarget); if (proj < IM.Number.zero) { continue; } //防守者在接球者身后 IM.Vector3 dirTargetToDef = GameUtils.HorizonalNormalized(defenser.position, passTarget.position); proj = IM.Vector3.Dot(dirTargetToDef, -dirPasserToTarget); if (proj < IM.Number.zero) { continue; } //计算防守者与传球线垂直距离 IM.Number angle = IM.Vector3.AngleRad(dirPasserToTarget, dirPasserToDef); //传球方向与防守者方向夹角 IM.Number distDefenser = GameUtils.HorizonalDistance(defenser.position, m_player.position); //防守者距离 IM.Number fVDist = distDefenser * IM.Math.Sin(angle); //垂直距离 SkillSpec skillParam = defenser.GetSkillSpecialAttribute(SkillSpecParam.eInterception_dist, interceptionSkill); IM.Number fInterceptionRate = IM.Number.zero; Debug.Log("Player id: " + m_player.m_id + " distance to plane: " + fVDist); if (fVDist > skillParam.value) { continue; } Dictionary <string, uint> passTargetData = m_player.m_finalAttrs; Dictionary <string, uint> defenserData = defenser.m_finalAttrs; uint skillPassValue = 0; m_player.m_skillSystem.HegdingToValue("addn_pass", ref skillPassValue); uint skillInterceptionValue = 0; defenser.m_skillSystem.HegdingToValue("addn_interception", ref skillInterceptionValue); fInterceptionRate = passHedging.Calc(new IM.Number((int)(defenserData["interception"] + skillInterceptionValue)), new IM.Number((int)(passTargetData["pass"] + skillPassValue))); Debug.Log("Interception rate: " + fInterceptionRate); if (IM.Random.value < fInterceptionRate) { SkillSpec passSkillParam = defenser.GetSkillSpecialAttribute(SkillSpecParam.eInterception_get_ball_rate, interceptionSkill); PlayerState_Interception intercetionState = defenser.m_StateMachine.GetState(State.eInterception) as PlayerState_Interception; intercetionState.m_passer = m_player; intercetionState.m_catcher = passTarget; intercetionState.m_bGetBall = IM.Random.value < passSkillParam.value; if (!intercetionState.CanIntercept(interceptionSkill, m_player, passTarget, out m_interceptedPos)) { continue; } defenser.m_toSkillInstance = interceptionSkill; m_interceptor = defenser; intercetionState.m_bSendMsg = true; m_interceptor.m_StateMachine.SetState(intercetionState); defenser.m_toSkillInstance = null; break; } } } Dictionary <string, uint> skillAttr = m_player.GetSkillAttribute(); passTarget.m_catchHelper.SetCatchMotionByPasser(m_player, skillAttr["pass"]); m_player.animMgr.Play(m_curAction, false); AudioClip clip = AudioManager.Instance.GetClip("Misc/Pass_01"); if (clip != null) { AudioManager.Instance.PlaySound(clip); } }
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 static IM.Number GetMaxDist(Player player, SkillInstance skillInst = null) { SkillSpec skillspec = player.GetSkillSpecialAttribute(SkillSpecParam.eRebound_dist, skillInst); return(skillspec.value); }
void _CalcLayupRate() { if (m_bRateFixed) { return; } IM.Number fSideEffect = IM.Number.zero; SkillSideEffect effect; if (m_curExecSkill.skill.side_effects.TryGetValue((int)SkillSideEffect.Type.eShootRate, out effect)) { fSideEffect = effect.value; } //else // Debug.Log("No side effect data."); Dictionary <string, uint> data = m_player.m_finalAttrs; if (data == null) { Debug.LogError("Can not build player: " + m_player.m_name + " ,can not fight state by id: " + m_player.m_id); return; } Dictionary <string, uint> skillAttr = m_player.GetSkillAttribute(); Dictionary <string, uint> playerData = m_player.m_finalAttrs; //m_player.m_roleInfo.skill_slot_info.Find( (SkillSlotProto skillSlot)=>{ return skillSlot.id == m_curExecSkill.skill.id; } ); uint skillValue = 0; IM.Number fDisturb = IM.Number.zero; 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) { Dictionary <string, uint> defenderData = defenser.m_finalAttrs; uint disturb = defenderData["disturb"]; uint disturb_attr = 0; defenser.m_skillSystem.HegdingToValue("addn_disturb", ref disturb_attr); //defenser.m_skillSystem.GetAttrValueByName("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); //m_player.m_skillSystem.GetAttrValueByName("addn_anti_disturb", ref anti_disturb_attr); fAntiDisturb += anti_disturb_attr; if (m_skillArea == Area.eNear) { fDisturb = layupNearHedging.Calc(new IM.Number((int)disturb), new IM.Number((int)fAntiDisturb)); } else if (m_skillArea == Area.eMiddle) { fDisturb = layupMiddleHedging.Calc(new IM.Number((int)disturb), new IM.Number((int)fAntiDisturb)); } m_bRateFixed = true; break; } } } else { m_bRateFixed = true; } if (m_skillArea == Area.eNear) { IM.Number reduceScale = m_match.GetAttrReduceScale("layup_near", m_player); m_player.m_skillSystem.HegdingToValue("layup_near", ref skillValue); //m_player.m_skillSystem.GetAttrValueByName("layup_near", ref skillValue); m_layupRate = ((data["layup_near"] + skillAttr["layup_near"] + skillValue) * layupNearMultiply + layupNearAdd) * reduceScale * (IM.Number.one - fDisturb) + fSideEffect; } else if (m_skillArea == Area.eMiddle) { IM.Number reduceScale = m_match.GetAttrReduceScale("layup_middle", m_player); m_player.m_skillSystem.HegdingToValue("layup_middle", ref skillValue); //m_player.m_skillSystem.GetAttrValueByName("layup_middle", ref skillValue); m_layupRate = ((data["layup_middle"] + skillAttr["layup_middle"] + skillValue) * layupMiddleMultiply + layupMiddleAdd) * reduceScale * (IM.Number.one - fDisturb) + fSideEffect; } SkillSpec skillSpec = m_player.GetSkillSpecialAttribute(SkillSpecParam.eLayup_rate); if (skillSpec.paramOp == SkillSpecParamOp.eAdd) { m_layupRate += skillSpec.value; } else if (skillSpec.paramOp == SkillSpecParamOp.eMulti) { m_layupRate *= skillSpec.value; } m_layupRate = m_match.AdjustShootRate(m_player, m_layupRate); }
void _CalcDunkRate() { if (m_bRateFixed) { return; } IM.Number fSideEffect = IM.Number.zero; SkillSideEffect effect; if (m_curExecSkill.skill.side_effects.TryGetValue((int)SkillSideEffect.Type.eShootRate, out effect)) { fSideEffect = effect.value; } //else // Debug.Log("No side effect data."); Dictionary <string, uint> skillAttr = m_player.GetSkillAttribute(); Dictionary <string, uint> data = m_player.m_finalAttrs; if (data == null) { Debug.LogError("Can not build player: " + m_player.m_name + " ,can not find state by id: " + m_player.m_id); return; } IM.Number fDisturb = IM.Number.zero; 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) { Dictionary <string, uint> defenderData = defenser.m_finalAttrs; uint disturb = defenderData["disturb"]; uint disturb_attr = 0; defenser.m_skillSystem.HegdingToValue("addn_disturb", ref disturb_attr); //defenser.m_skillSystem.GetAttrValueByName("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); //m_player.m_skillSystem.GetAttrValueByName("addn_anti_disturb", ref anti_disturb_attr); fAntiDisturb += anti_disturb_attr; if (m_skillArea == Area.eNear) { fDisturb = dunkNearHedging.Calc(new IM.Number((int)disturb), new IM.Number((int)fAntiDisturb)); } else if (m_skillArea == Area.eMiddle) { fDisturb = dunkMiddleHedging.Calc(new IM.Number((int)disturb), new IM.Number((int)fAntiDisturb)); } m_bRateFixed = true; break; } } } else { m_bRateFixed = true; } uint uDunkData = 0; uint uDunkSkill = 0; if (m_skillArea == Area.eNear) { IM.Number reduceScale = m_match.GetAttrReduceScale("dunk_near", m_player); data.TryGetValue("dunk_near", out uDunkData); m_player.m_skillSystem.HegdingToValue("dunk_near", ref uDunkSkill); //m_player.m_skillSystem.GetAttrValueByName("dunk_near", ref uDunkSkill); m_dunkRate = ((uDunkData + uDunkSkill) * dunkNearMultiply + dunkNearAdd) * reduceScale * (IM.Number.one - fDisturb) + fSideEffect; } else if (m_skillArea == Area.eMiddle) { IM.Number reduceScale = m_match.GetAttrReduceScale("dunk_middle", m_player); data.TryGetValue("dunk_middle", out uDunkData); m_player.m_skillSystem.HegdingToValue("dunk_middle", ref uDunkSkill); //m_player.m_skillSystem.GetAttrValueByName("dunk_middle", ref uDunkSkill); m_dunkRate = ((uDunkData + uDunkSkill) * dunkMiddleMultiply + dunkMiddleAdd) * reduceScale * (IM.Number.one - fDisturb) + fSideEffect; } SkillSpec skillSpec = m_player.GetSkillSpecialAttribute(SkillSpecParam.eDunk_rate); if (skillSpec.paramOp == SkillSpecParamOp.eAdd) { m_dunkRate += skillSpec.value; } else if (skillSpec.paramOp == SkillSpecParamOp.eMulti) { m_dunkRate *= skillSpec.value; } m_dunkRate = IM.Math.Max(m_dunkRate, IM.Number.zero); m_dunkRate = m_match.AdjustShootRate(m_player, m_dunkRate); }
bool _MatchSkillSpecParam(SkillInstance skillInstance) { Command cmdType = (Command)skillInstance.skill.action_type; if (cmdType == Command.Pass) { if (m_player.m_passTarget == null) { return(false); } SkillSpec passSkillSpec = m_player.GetSkillSpecialAttribute(SkillSpecParam.ePass_dist_min, skillInstance); IM.Number fMinDistance = passSkillSpec.value; passSkillSpec = m_player.GetSkillSpecialAttribute(SkillSpecParam.ePass_dist_max, skillInstance); IM.Number fMaxDistance = passSkillSpec.value; IM.Number fDistance = GameUtils.HorizonalDistance(m_player.position, m_player.m_passTarget.position); if (fDistance > fMaxDistance || fDistance < fMinDistance) { return(false); } } if (cmdType == Command.Dunk || cmdType == Command.Layup) { if (m_player.m_defenseTarget != null) { Player nearestValidDefender = null; IM.Number fNearestDist = IM.Number.max; foreach (Player pl in m_player.m_defenseTarget.m_team) { if (m_player.m_AOD.GetStateByPos(pl.position) != AOD.Zone.eInvalid) { IM.Number fDist = GameUtils.HorizonalDistance(m_player.position, pl.position); if (fDist > fNearestDist) { continue; } fNearestDist = fDist; nearestValidDefender = pl; } } if (nearestValidDefender != null) { IM.Number fDist = GameUtils.HorizonalDistance(m_player.position, nearestValidDefender.position); if (fDist < skillInstance.skill.attrange) { return(false); } } } } GameMatch match = GameSystem.Instance.mClient.mCurMatch; UBasketball ball = match.mCurScene.mBall; if (cmdType == Command.Block) { Player attacker = ball.m_actor; if (attacker == null) { attacker = ball.m_owner; } if (attacker == null) { return(false); } IM.Number fDistance = GameUtils.HorizonalDistance(attacker.position, m_player.position); IM.Vector3 dirAttackerToPlayer = GameUtils.HorizonalNormalized(m_player.position, attacker.position); IM.Number ret = IM.Vector3.Dot(attacker.forward, dirAttackerToPlayer); if (ret < IM.Number.zero) { SkillSpec blockBackDist = m_player.GetSkillSpecialAttribute(SkillSpecParam.eBlock_back_dist, skillInstance); if (fDistance > blockBackDist.value) { return(false); } } else { SkillSpec blockFrontDist = m_player.GetSkillSpecialAttribute(SkillSpecParam.eBlock_front_dist, skillInstance); if (fDistance > blockFrontDist.value) { return(false); } } } if (cmdType == Command.Rebound) { IM.Number fDistance = GameUtils.HorizonalDistance(ball.position, m_player.position); IM.Number fHeight = ball.position.y; SkillSpec heightSpec = m_player.GetSkillSpecialAttribute(SkillSpecParam.eRebound_height, skillInstance); SkillSpec distSpec = m_player.GetSkillSpecialAttribute(SkillSpecParam.eRebound_dist, skillInstance); if (fHeight > heightSpec.value) { return(false); } if (fDistance > distSpec.value) { return(false); } } return(true); }
bool _StealBall(out bool bVaild) { bVaild = false; if (m_ball.m_owner == null) { return(false); } stealTarget = m_ball.m_owner; if (!stealTarget.m_bOnGround) { return(false); } PlayerState.State ps = stealTarget.m_StateMachine.m_curState.m_eState; ratio = GameSystem.Instance.StealConfig.GetRatio(ps); if (ratio == IM.Number.zero) { Debug.Log("Steal failed, state: " + ps); return(false); } if (m_ball.m_ballState != BallState.eUseBall) { return(false); } Dictionary <string, uint> targetData = stealTarget.m_finalAttrs; Dictionary <string, uint> playerData = m_player.m_finalAttrs; //if (m_ball.m_owner == stealTarget) //{ // //ÔÚÉÈÐÎÇøÓòÄÚÀ½üµ½³ÖÇòÕßÉíÇ° // AOD.Zone zone = stealTarget.m_AOD.GetStateByPos(m_player.position); // if (zone != AOD.Zone.eInvalid) // { // //Vector3 newPos = new Vector3(stealTarget.position.x,stealTarget.position.y,stealTarget.position.z); // //Vector3 newPos; // //newPos.x = stealTarget.position.x + 1.5f * stealTarget.forward.normalized.x; // //newPos.y = stealTarget.position.y + 1.5f * stealTarget.forward.normalized.y; // //newPos.z = stealTarget.position.z + 1.5f * stealTarget.forward.normalized.z; // //m_player.position = newPos; // m_player.m_moveHelper.MoveTo(stealTarget.position); // } //} if (!InStealPosition(m_player, m_ball)) { Debug.Log("Steal failed."); return(false); } uint stealValue = 0; m_player.m_skillSystem.HegdingToValue("addn_steal", ref stealValue); uint control = 0; stealTarget.m_skillSystem.HegdingToValue("addn_control", ref control); IM.Number antiStealRate = (targetData["control"] + control) * m_match.GetAttrReduceScale("control", stealTarget); IM.Number playerStealRate = (playerData["steal"] + stealValue) * m_match.GetAttrReduceScale("steal", m_player); IM.Number stealRate = hedging.Calc(playerStealRate, antiStealRate); SkillSpec skillSpec = m_player.GetSkillSpecialAttribute(SkillSpecParam.eSteal_rate); if (skillSpec.paramOp == SkillSpecParamOp.eAdd) { stealRate += skillSpec.value; } else if (skillSpec.paramOp == SkillSpecParamOp.eMulti) { stealRate *= skillSpec.value; } stealRate = stealRate * ratio; bool sumValue = random[stealTarget].AdjustRate(ref stealRate); Debugger.Instance.m_steamer.message = " Steal ball: stealRate: " + stealRate; IM.Number fRandomValue = IM.Random.value; Debugger.Instance.m_steamer.message += " Random value: " + fRandomValue; bVaild = true; if (fRandomValue > stealRate) { Debugger.Instance.m_steamer.message += "steal failed."; return(false); } if (sumValue) { random[stealTarget].SumValue(); } Debugger.Instance.m_steamer.message += ", steal success."; return(true); }
bool _CalcBlockDunk(Player shooter, out bool bBlockable, out bool bBlockInRange, out IM.Number fBlockRate, out IM.Number fBlockValue, out IM.Vector3 attackerPos, out IM.Vector3 vBallDir, out bool bValid) { bBlockable = false; attackerPos = IM.Vector3.zero; fBlockRate = IM.Number.zero; fBlockValue = IM.Number.zero; bBlockInRange = false; bValid = false; //vBallDir = GameUtils.HorizonalNormalized( shooter.position, m_player.position ); vBallDir = GetBallVelocity(); Player dunker = m_ball.m_owner; IM.Vector3 dirDunker2Player = m_player.position - dunker.position; dirDunker2Player.y = IM.Number.zero; if (!dunker.m_blockable.blockable) { Debugger.Instance.m_steamer.message = "Out of block range."; if (dunker.m_blockable.tooEarly) { m_failReason = FailReason.TooEarly; } else if (dunker.m_blockable.tooLate) { m_failReason = FailReason.TooLate; } return(false); } /* * AOD.Zone zone = shooter.m_AOD.GetStateByPos(m_player.position); * if( zone == AOD.Zone.eInvalid ) * { * bBlockInRange = false; * Debugger.Instance.m_steamer.message = "Block failed, not in AOD"; * return false; * } */ if (!InBlockArea(shooter, m_player, m_basket.m_vShootTarget)) { Debugger.Instance.m_steamer.message = "Block failed, not in AOD"; m_failReason = FailReason.InvalidArea; return(false); } bBlockInRange = true; Dictionary <string, PlayerAnimAttribute.AnimAttr> blocks = m_player.m_animAttributes.m_block; int blockKey = blocks[m_curAction].GetKeyFrame("OnBlock").frame; IM.Number fEventBlockTime = blockKey / m_player.animMgr.GetFrameRate(m_curAction); SkillInstance dunkSkill = dunker.m_StateMachine.m_curState.m_curExecSkill; string dunk_id = dunker.m_skillSystem.ParseAction(dunkSkill.curAction.action_id, dunkSkill.matchedKeyIdx, Command.Dunk); PlayerAnimAttribute.AnimAttr dunkAnims = dunker.m_animAttributes.GetAnimAttrById(Command.Dunk, dunk_id); int dunkInKey = dunkAnims.GetKeyFrame("OnDunk").frame; IM.Number fEventDunkInTime = dunkInKey / dunker.animMgr.GetFrameRate(dunk_id); IM.Number fDunkEclipseTime = dunker.animMgr.curPlayInfo.time; IM.Number fDunkFlyTime = fEventDunkInTime - fDunkEclipseTime; if (fDunkFlyTime < fEventBlockTime) { Debugger.Instance.m_steamer.message = "block too late, dunk goal!"; m_failReason = FailReason.InvalidBallShotState; return(false); } IM.Number fSideEffect = IM.Number.zero; SkillSideEffect effect; if (!m_curExecSkill.skill.side_effects.TryGetValue((int)SkillSideEffect.Type.eBlockRate, out effect)) { Debug.Log("No side effect data."); } else { fSideEffect = effect.value; } Dictionary <string, uint> data = dunker.m_finalAttrs; Dictionary <string, uint> dunkerSkillAttr = dunker.GetSkillAttribute(); IM.Number blockAttr = new IM.Number((int)(m_player.m_finalAttrs["block"])); IM.Number reduceScale = m_match.GetAttrReduceScale("block", m_player); blockAttr *= reduceScale; if ((Command)dunkSkill.skill.action_type == Command.Dunk) { uint anti_block = 0; shooter.m_skillSystem.HegdingToValue("addn_anti_block", ref anti_block); IM.Number fAntiBlock = new IM.Number((int)(data["anti_block"] + anti_block)); switch (dunkSkill.skill.area[0]) { case 3: //near fBlockRate = dunkNearHedging.Calc(blockAttr, fAntiBlock); break; case 2: //middle fBlockRate = dunkMiddleHedging.Calc(blockAttr, fAntiBlock); break; } fBlockRate += fSideEffect; } SkillSpec skillSpc = shooter.GetSkillSpecialAttribute(SkillSpecParam.eDunk_antiBlock); if (skillSpc.paramOp == SkillSpecParamOp.eAdd) { fBlockRate += skillSpc.value; } else if (skillSpc.paramOp == SkillSpecParamOp.eMulti) { fBlockRate *= skillSpc.value; } skillSpc = m_player.GetSkillSpecialAttribute(SkillSpecParam.eBlock_rate); if (skillSpc.paramOp == SkillSpecParamOp.eAdd) { fBlockRate += skillSpc.value; } else if (skillSpc.paramOp == SkillSpecParamOp.eMulti) { fBlockRate *= skillSpc.value; } fBlockRate = m_match.AdjustBlockRate(shooter, m_player, fBlockRate); bool sumValue = random[shooter].AdjustRate(ref fBlockRate); fBlockValue = IM.Random.value; Debugger.Instance.m_steamer.message = "block rate: " + fBlockRate; Debugger.Instance.m_steamer.message += "probability: " + fBlockValue; bValid = true; m_ball.m_bBlockSuccess = fBlockValue < fBlockRate; if (!m_ball.m_bBlockSuccess) { m_failReason = FailReason.Random; } if (m_ball.m_bBlockSuccess && sumValue) { random[shooter].SumValue(); } return(m_ball.m_bBlockSuccess); }
bool _CalcBlockShoot(Player shooter, out bool bBlockable, out bool bBlockInRange, out IM.Number fBlockRate, out IM.Number fBlockValue, out IM.Vector3 attackerPos, out IM.Vector3 vBallDir, out bool bValid) { bBlockable = false; attackerPos = IM.Vector3.zero; fBlockRate = IM.Number.zero; fBlockValue = IM.Number.zero; bBlockInRange = false; vBallDir = GetBallVelocity(); bValid = false; if (shooter == null) { Debug.Log("Block failed, shooter is null."); m_failReason = FailReason.NoShooter; return(false); } attackerPos = shooter.position; if (!shooter.m_blockable.blockable) { if (shooter.m_blockable.tooEarly) { m_failReason = FailReason.TooEarly; } else if (shooter.m_blockable.tooLate) { m_failReason = FailReason.TooLate; } Debugger.Instance.m_steamer.message = "Out of block range."; return(false); } bBlockable = true; /* * AOD.Zone zone = shooter.m_AOD.GetStateByPos(m_player.position); * if( zone == AOD.Zone.eInvalid ) * { * Debugger.Instance.m_steamer.message = "Block failed, not in AOD"; * return false; * } */ if (!InBlockArea(shooter, m_player, m_basket.m_vShootTarget)) { Debugger.Instance.m_steamer.message = "Block failed, not in AOD"; m_failReason = FailReason.InvalidArea; return(false); } bBlockInRange = true; Dictionary <string, PlayerAnimAttribute.AnimAttr> blocks = m_player.m_animAttributes.m_block; int blockKey = blocks[m_player.animMgr.GetOriginName(m_curAction)].GetKeyFrame("OnBlock").frame; IM.Number fEventBlockTime = blockKey / m_player.animMgr.GetFrameRate(m_curAction); Dictionary <string, PlayerAnimAttribute.AnimAttr> shootAnims = shooter.m_animAttributes.m_shoot; SkillInstance shooterSkill = shooter.m_StateMachine.m_curState.m_curExecSkill; string shoot_id = shooter.m_skillSystem.ParseAction(shooterSkill.curAction.action_id, shooterSkill.matchedKeyIdx, Command.Shoot); int shootOutKey = shootAnims[shooter.animMgr.GetOriginName(shoot_id)].GetKeyFrame("OnShoot").frame; IM.Number fEventShootOutTime = shootOutKey / shooter.animMgr.GetFrameRate(shoot_id); IM.Number fShootEclipseTime = shooter.animMgr.curPlayInfo.time; if (fShootEclipseTime > fEventShootOutTime) { Debug.Log("PlayerState_Block: block failed, ball has been shot."); m_failReason = FailReason.InvalidBallShotState; return(false); } IM.Number fBallFlyTime = fEventBlockTime - (fEventShootOutTime - fShootEclipseTime); if (fBallFlyTime < IM.Number.zero) { Debug.Log("PlayerState_Block: block failed, ball will not be shot when block time."); m_failReason = FailReason.InvalidBallShotState; return(false); } IM.Number fSideEffect = IM.Number.one; SkillSideEffect effect; if (!m_curExecSkill.skill.side_effects.TryGetValue((int)SkillSideEffect.Type.eBlockRate, out effect)) { Debug.Log("No side effect data."); } else { fSideEffect = effect.value; } Dictionary <string, uint> data = shooter.m_finalAttrs; uint uBlockSkill = 0; m_player.m_skillSystem.HegdingToValue("addn_block", ref uBlockSkill); IM.Number blockAttr = new IM.Number((int)(m_player.m_finalAttrs["block"] + uBlockSkill)); IM.Number reduceScale = m_match.GetAttrReduceScale("block", m_player); blockAttr *= reduceScale; if ((Command)shooterSkill.skill.action_type == Command.Shoot) { uint anti_block = 0; shooter.m_skillSystem.HegdingToValue("addn_anti_block", ref anti_block); IM.Number fAntiBlock = new IM.Number((int)(data["anti_block"] + anti_block)); switch (shooterSkill.skill.area[0]) { case 3: //near fBlockRate = shootNearHedging.Calc(blockAttr, fAntiBlock); break; case 2: //middle fBlockRate = shootMiddleHedging.Calc(blockAttr, fAntiBlock); break; case 1: //far fBlockRate = shootFarHedging.Calc(blockAttr, fAntiBlock); break; default: break; } fBlockRate += fSideEffect; } SkillSpec skillSpc = shooter.GetSkillSpecialAttribute(SkillSpecParam.eShoot_antiBlock); if (skillSpc.paramOp == SkillSpecParamOp.eAdd) { fBlockRate += skillSpc.value; } else if (skillSpc.paramOp == SkillSpecParamOp.eMulti) { fBlockRate *= skillSpc.value; } SkillSpec skill = m_player.GetSkillSpecialAttribute(SkillSpecParam.eBlock_rate); if (skill.paramOp == SkillSpecParamOp.eAdd) { fBlockRate += skill.value; } else if (skill.paramOp == SkillSpecParamOp.eMulti) { fBlockRate *= skill.value; } fBlockRate = m_match.AdjustBlockRate(shooter, m_player, fBlockRate); bool sumValue = random[shooter].AdjustRate(ref fBlockRate); bValid = true; if (shooterSkill.curAction.block_key != null) { Debug.Log("m_curExecSkill.curInput.moveDir: " + m_curExecSkill.curInput.moveDir); Debug.Log("shooterSkill.curAction.block_key.moveDir: " + shooterSkill.curAction.block_key.moveDir); if (m_curExecSkill.curInput.moveDir == shooterSkill.curAction.block_key.moveDir) { fBlockRate *= GlobalConst.MATCHED_KEY_BLOCK_RATE_ADJUST; Debug.Log("Match block key."); } } fBlockValue = IM.Random.value; if (fBlockValue > fBlockRate) { m_failReason = FailReason.Random; return(false); } if (sumValue) { random[shooter].SumValue(); } return(true); }
private void ReadSkillLevelConfig() { string text = ResourceLoadManager.Instance.GetConfigText(name3); if (text == null) { Debug.LogError("LoadConfig failed: " + name3); return; } //读取以及处理XML文本的类 XmlDocument xmlDoc = CommonFunction.LoadXmlConfig(name3, text); //解析xml的过程 XmlNodeList nodelist = xmlDoc.SelectSingleNode("Data").ChildNodes; Debug.Log("Start ReadSkilLevelConfig Parsing!"); foreach (XmlElement xe in nodelist) { XmlNode comment = xe.SelectSingleNode(GlobalConst.CONFIG_SWITCH_COLUMN); if (comment != null && comment.InnerText == GlobalConst.CONFIG_SWITCH) { continue; } uint skill_id = 0; SkillLevel level = new SkillLevel(); foreach (XmlElement xel in xe) { if (xel.Name == "id") { uint.TryParse(xel.InnerText, out skill_id); } else if (xel.Name == "level") { uint.TryParse(xel.InnerText, out level.level); } else if (xel.Name == "consume") { SkillConsumable consumable = new SkillConsumable(); string[] array = xel.InnerText.Split('&'); foreach (string items in array) { string[] item = items.Split(':'); if (item.Length == 2) { uint id, v; uint.TryParse(item[0], out consumable.consumable_id); uint.TryParse(item[1], out consumable.consumable_quantity); } } level.consumables.Add(consumable); } else if (xel.Name == "addn_attr") { string[] array = xel.InnerText.Split('&'); foreach (string items in array) { string[] item = items.Split(':'); if (item.Length == 2) { uint id, v; uint.TryParse(item[0], out id); uint.TryParse(item[1], out v); level.additional_attrs.Add(GameSystem.Instance.AttrNameConfigData.GetAttrSymbol(id), v); } } } else if (xel.Name == "stama") { if (xel.InnerText == "") { level.stama = 0; } else { level.stama = uint.Parse(xel.InnerText); } } else if (xel.Name == "weight") { if (xel.InnerText == "") { level.weight = 0; } else { level.weight = uint.Parse(xel.InnerText); } } else if (xel.Name == "special_parameter") { string[] array = xel.InnerText.Split('&'); foreach (string items in array) { string[] item = items.Split(':'); if (item.Length == 2) { SkillSpec skillSpec = new SkillSpec(); skillSpec.paramOp = SkillSpecParamOp.eAdd; //float v = 0.0f; uint.TryParse(item[0], out skillSpec.paramId); if (!item[1].Contains("%")) { //bool resu = float.TryParse(item[1], out v); //Debug.Log("NOT %:str[" + item[1] + "]Result:" + resu); skillSpec.value = IM.Number.Parse(item[1]); } else { item[1].Remove(item[1].Length - 1); skillSpec.paramOp = SkillSpecParamOp.eMulti; string strValue = item[1].TrimEnd('%'); //bool resu = float.TryParse(strValue, out v); //Debug.Log("NOT %:str[" + strValue + "]Result:" + resu); skillSpec.value = IM.Number.Parse(strValue); } level.parameters.Add(skillSpec.paramId, skillSpec); } } } } SkillAttr skill; if (skills.TryGetValue(skill_id, out skill)) { skill.levels.Add(level.level, level); } } Debug.Log("SSS"); }