private bool InReboundRange() { UBasketball ball = match.mCurScene.mBall; IM.Vector3 pos; ball.GetPositionInAir(ball.m_fTime + eventTime, out pos); IM.Number ball_height = pos.y; return(minHeight < ball_height && ball_height < maxHeight); }
public override void GameUpdate(IM.Number deltaTime) { base.GameUpdate(deltaTime); if (curStep != null) { stepRunningTime += (float)deltaTime; if (HasCondition(PractiseStepCondition.OnGround)) { ValidateCondition(PractiseStepCondition.OnGround, (param) => { int index = (int)(param[0]); Player player = GetPlayer(index); return(player.m_bOnGround); }); } if (HasCondition(PractiseStepCondition.Wait)) { ValidateCondition(PractiseStepCondition.Wait, (param) => { float waitTime = (float)(param[0]); return(stepRunningTime >= waitTime); }); } if (HasCondition(PractiseStepCondition.InDist)) { ValidateCondition(PractiseStepCondition.InDist, (param) => { int index = (int)(param[0]); Player player = GetPlayer(index); GameObject obj = GetSceneObject((string)(param[1])); float dist = (float)(param[2]); bool value = (bool)(param[3]); return((GameUtils.HorizonalDistance(obj.transform.position, (Vector3)player.position) <= dist) == value); }); } if (HasCondition(PractiseStepCondition.EnterRow)) { ValidateCondition(PractiseStepCondition.EnterRow, (param) => { int index = (int)(param[0]); int rowStart = (int)(param[1]); int rowEnd = (int)(param[2]); Player player = GetPlayer(index); int secIdx = RoadPathManager.Instance.CalcSectorIdx(player.position); if (secIdx == -1) { return(false); } int rowIdx = secIdx / RoadPathManager.Instance.m_angleNum; return(rowStart <= rowIdx && rowIdx <= rowEnd); }); } if (HasCondition(PractiseStepCondition.EnterArea)) { ValidateCondition(PractiseStepCondition.EnterArea, (param) => { int index = (int)(param[0]); Player player = GetPlayer(index); Area area = (Area)(param[1]); return(match.mCurScene.mGround.GetArea(player) == area); }); } if (HasCondition(PractiseStepCondition.EnterState)) { ValidateCondition(PractiseStepCondition.EnterState, (param) => { int index = (int)(param[0]); Player player = GetPlayer(index); PlayerState.State state = (PlayerState.State)(param[1]); return(state == player.m_StateMachine.m_curState.m_eState); }); } if (HasCondition(PractiseStepCondition.BlockTiming)) { ValidateCondition(PractiseStepCondition.BlockTiming, (param) => { Player attacker = ball.m_owner; if (attacker == null) { attacker = ball.m_actor; } if (attacker.m_StateMachine.m_curState.m_eState != PlayerState.State.eShoot && attacker.m_StateMachine.m_curState.m_eState != PlayerState.State.eLayup && attacker.m_StateMachine.m_curState.m_eState != PlayerState.State.eDunk) { return(false); } if (!PlayerState_Block.InBlockArea(attacker, attacker.m_defenseTarget, match.mCurScene.mBasket.m_vShootTarget)) { return(false); } return(attacker.m_blockable.blockable); }); } if (HasCondition(PractiseStepCondition.Blocked)) { ValidateCondition(PractiseStepCondition.Blocked, (param) => { int index = (int)(param[0]); Player player = GetPlayer(index); if (player.m_StateMachine.m_curState.m_eState != PlayerState.State.eBlock) { return(false); } PlayerState_Block blockState = player.m_StateMachine.m_curState as PlayerState_Block; bool success = (bool)(param[1]); return(blockState.m_success == success); }); } if (HasCondition(PractiseStepCondition.BlockInArea)) { ValidateCondition(PractiseStepCondition.BlockInArea, (param) => { int index = (int)(param[0]); Player player = GetPlayer(index); Player attacker = ball.m_owner; if (attacker == null) { attacker = ball.m_actor; } bool inArea = (bool)(param[1]); return(PlayerState_Block.InBlockArea(attacker, player, match.mCurScene.mBasket.m_vShootTarget) == inArea); }); } if (HasCondition(PractiseStepCondition.BlockTooLate)) { ValidateCondition(PractiseStepCondition.BlockTooLate, (param) => { int index = (int)(param[0]); Player player = GetPlayer(index); if (player.m_StateMachine.m_curState.m_eState != PlayerState.State.eBlock) { return(false); } PlayerState_Block blockState = player.m_StateMachine.m_curState as PlayerState_Block; if (blockState.m_success) { return(false); } Player attacker = ball.m_owner; if (attacker == null) { attacker = ball.m_actor; } bool tooLate = (bool)(param[1]); if (tooLate) { return(blockState.m_failReason == PlayerState_Block.FailReason.TooLate); } else { return(blockState.m_failReason == PlayerState_Block.FailReason.TooEarly); } }); } if (HasCondition(PractiseStepCondition.ReboundTiming)) { ValidateCondition(PractiseStepCondition.ReboundTiming, (param) => { if (ball.m_ballState == BallState.eRebound) { IM.Vector3 velocity = ball.curVel; if (velocity.y < IM.Number.zero) { int index = (int)(param[0]); Player player = GetPlayer(index); IM.Number eventTime = PlayerState_Rebound.GetEventTime(player); IM.Vector3 pos; ball.GetPositionInAir(ball.m_fTime + eventTime, out pos); IM.Number ball_height = pos.y; IM.Number minHeight, maxHeight; PlayerState_Rebound.GetDefaultHeightRange(player, out minHeight, out maxHeight); return(minHeight < ball_height && ball_height < maxHeight); } } return(false); }); } if (HasCondition(PractiseStepCondition.Rebound)) { ValidateCondition(PractiseStepCondition.Rebound, (param) => { int index = (int)(param[0]); Player player = GetPlayer(index); if (player.m_StateMachine.m_curState.m_eState != PlayerState.State.eRebound) { return(false); } PlayerState_Rebound reboundState = player.m_StateMachine.m_curState as PlayerState_Rebound; bool success = (bool)(param[1]); if (success) { reboundState.m_toReboundBall = true; } return(reboundState.m_success == success); }); } if (HasCondition(PractiseStepCondition.ReboundInArea)) { ValidateCondition(PractiseStepCondition.ReboundInArea, (param) => { int index = (int)(param[0]); Player player = GetPlayer(index); IM.Number dist2Ball = GameUtils.HorizonalDistance(player.position, ball.position); IM.Number maxDist = PlayerState_Rebound.GetDefaultMaxDist(player); bool inArea = (bool)(param[1]); return((dist2Ball <= maxDist) == inArea); }); } if (HasCondition(PractiseStepCondition.ReboundTooLate)) { ValidateCondition(PractiseStepCondition.ReboundTooLate, (param) => { int index = (int)(param[0]); Player player = GetPlayer(index); if (player.m_StateMachine.m_curState.m_eState != PlayerState.State.eRebound) { return(false); } PlayerState_Rebound reboundState = player.m_StateMachine.m_curState as PlayerState_Rebound; if (reboundState.m_success) { return(false); } bool tooLate = (bool)(param[1]); return(reboundState.tooLate == tooLate); }); } if (HasCondition(PractiseStepCondition.Undefended)) { ValidateCondition(PractiseStepCondition.Undefended, (param) => { int index = (int)(param[0]); Player player = GetPlayer(index); return(!player.IsDefended()); }); } if (HasCondition(PractiseStepCondition.Defended)) { ValidateCondition(PractiseStepCondition.Defended, (param) => { int index = (int)(param[0]); Player player = GetPlayer(index); return(player.IsDefended()); }); } } if (stepFinished) { EndStep(); } if (readyStepID != 0) { curStep = GameSystem.Instance.PractiseStepConfig.GetStep(readyStepID); readyStepID = 0; RunStep(); return; } }