public override void Update(IM.Number fDeltaTime) { base.Update(fDeltaTime); if (stealed && m_player.m_StateMachine.m_curState.m_eState != PlayerState.State.eSteal) { m_system.SetTransaction(AIState.Type.eDefense); } IM.Vector3 dirTargetToMe = m_player.position - m_player.m_defenseTarget.position; dirTargetToMe.y = IM.Number.zero; if (!stealed) { if (dirTargetToMe.magnitude * (IM.Number.one - m_system.AI.devDistFront) < new IM.Number(1, 500)) { m_player.m_toSkillInstance = m_player.m_skillSystem.GetValidSkillInMatch(Command.Steal, true); if (m_player.m_toSkillInstance == null) { Debug.LogWarning("AISkillSystem(" + m_player.m_id + "), no skill for AI Steal"); } (m_player.m_StateMachine.GetState(PlayerState.State.eSteal) as PlayerState_Steal).forcedByAI = true; stealed = true; } else { m_moveTarget = m_player.m_defenseTarget.position; } } }
Type _GetRunAction() { if (m_player.m_team.m_role == GameMatch.MatchRole.eDefense && m_player.m_defenseTarget != null && m_ball.m_owner != null) { Player defenseTarget = m_player.m_defenseTarget; IM.Vector3 dirDefTargetToPlayer = GameUtils.HorizonalNormalized(defenseTarget.position, m_player.position); //debug { IM.Vector3 vPlayer = new IM.Vector3(m_player.position.x, m_player.position.y, m_player.position.z); vPlayer.y = IM.Number.one; Debug.DrawLine((Vector3)vPlayer, (Vector3)vPlayer + (Vector3)dirDefTargetToPlayer * 2f, Color.red); Debug.DrawLine((Vector3)vPlayer, (Vector3)vPlayer + (Vector3)m_player.moveDirection * 2f, Color.blue); Debug.DrawLine((Vector3)vPlayer, (Vector3)vPlayer + (Vector3)m_player.forward * 2, Color.green); } IM.Number fAngleInputToPlayerDef = IM.Vector3.Angle(dirDefTargetToPlayer, m_player.moveDirection.normalized); Type type = Type.eFree; if (fAngleInputToPlayerDef > new IM.Number(135)) { type = Type.eBackward; } return(type); } else { return(Type.eFree); } }
override public void OnEnter(PlayerState lastState) { dirToBasket = GameUtils.HorizonalNormalized(m_match.mCurScene.mBasket.m_vShootTarget, m_player.position); IM.Number cross = IM.Vector3.Cross(dirToBasket, m_player.moveDirection).y; isTurnLeft = (cross < IM.Number.zero); if (m_player.m_eHandWithBall == Player.HandWithBall.eLeft) { m_animType = isTurnLeft ? AnimType.B_TYPE_0 : AnimType.B_TYPE_1; } else if (m_player.m_eHandWithBall == Player.HandWithBall.eRight) { m_animType = isTurnLeft ? AnimType.B_TYPE_2 : AnimType.B_TYPE_3; } m_curAction = m_mapAnimType[m_animType]; PlayerAnimAttribute.AnimAttr attr = m_player.m_animAttributes.GetAnimAttrById(Command.BackToBack, m_curAction); PlayerAnimAttribute.KeyFrame_RotateToBasketAngle keyFrame = attr.GetKeyFrame("RotateToBasketAngle") as PlayerAnimAttribute.KeyFrame_RotateToBasketAngle; if (keyFrame != null) { IM.Vector3 dirFaceTo = IM.Quaternion.AngleAxis(keyFrame.angle, IM.Vector3.up) * dirToBasket; m_player.forward = dirFaceTo; } m_curAction = m_mapAnimType[m_animType]; m_player.animMgr.Play(m_curAction, true).rootMotion.Reset(); }
static int Lua_Div(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(IM.Vector3), typeof(IM.Number))) { IM.Vector3 arg0 = (IM.Vector3)LuaScriptMgr.GetLuaObject(L, 1); IM.Number arg1 = (IM.Number)LuaScriptMgr.GetLuaObject(L, 2); IM.Vector3 o = arg0 / arg1; LuaScriptMgr.PushValue(L, o); return(1); } else if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(IM.Vector3), typeof(IM.Vector3))) { IM.Vector3 arg0 = (IM.Vector3)LuaScriptMgr.GetLuaObject(L, 1); IM.Vector3 arg1 = (IM.Vector3)LuaScriptMgr.GetLuaObject(L, 2); IM.Vector3 o = arg0 / arg1; LuaScriptMgr.PushValue(L, o); return(1); } else { LuaDLL.luaL_error(L, "invalid arguments to method: IM.Vector3.op_Division"); } return(0); }
public int CalcSectorIdx(IM.Vector3 rim, IM.Vector3 pos) { IM.Vector3 dirToShootTarget = pos - rim; dirToShootTarget.y = IM.Number.zero; IM.Number distToShootTarget = dirToShootTarget.magnitude; IM.Number fAngle = IM.Vector3.FromToAngle(IM.Vector3.right, dirToShootTarget.normalized); if (fAngle > IM.Math.HALF_CIRCLE) { fAngle = IM.Math.CIRCLE - fAngle; } int iDistanceIndex = 0; foreach (IM.Number distInSector in m_DistanceList) { if (distToShootTarget < distInSector) { break; } iDistanceIndex++; } int iAngleIndex = 0; foreach (IM.Number angleInSector in m_AngleList) { if (fAngle < angleInSector) { break; } iAngleIndex++; } //if(iAngle > 3 * ANGLE_MODULAR / 4) iAngleIndex = 0; return(iDistanceIndex * (m_AngleList.Count + 1) + iAngleIndex); }
public override void OnEnter(AIState lastState) { m_lastState = lastState; m_player.m_toSkillInstance = m_player.m_skillSystem.GetValidSkillInMatch(Command.CutIn, true); if (m_player.m_toSkillInstance != null) { if (m_player.position.z < m_match.mCurScene.mGround.mHalfSize.y - 1) { Player defenser = m_player.GetNearestDefender(); IM.Vector3 dirPlayerToDefenser = (defenser.position - m_player.position).normalized; IM.Number angle = IM.Vector3.FromToAngle(dirPlayerToDefenser, m_player.right); IM.Number devAngle = m_system.AI.devAngleDefender; angle *= IM.Number.one + IM.Random.Range(-devAngle, devAngle); bool left = angle < new IM.Number(90); m_player.m_toSkillInstance.curActionId = left ? LEFT_ACTION_ID : RIGHT_ACTION_ID; } else { m_player.m_toSkillInstance.curActionId = m_player.position.x > 0 ? LEFT_ACTION_ID : RIGHT_ACTION_ID; } } else { Debug.LogWarning("AISkillSystem(" + m_player.m_id + "), no skill for AI CutIn"); } }
public void OnCollided(Player blockedPlayer) { if (m_bOnCollide) { return; } m_player.m_stamina.ConsumeStamina(new IM.Number((int)m_curExecSkill.skill.levels[m_curExecSkill.level].stama)); m_player.model.RestoreMaterial(); IM.Vector3 player2Blocked = GameUtils.HorizonalNormalized(blockedPlayer.position, m_player.position); IM.Number up = IM.Vector3.Cross(m_player.forward, player2Blocked).y; if (up > IM.Number.zero) { m_animType = AnimType.N_TYPE_0; } else { m_animType = AnimType.N_TYPE_1; } m_bOnCollide = true; m_curAction = m_mapAnimType[m_animType]; m_player.mStatistics.SkillUsageSuccess(m_curExecSkill.skill.id, true); m_player.animMgr.CrossFade(m_curAction, false); }
void _GetDefenseAction() { //if( (Command)m_player.m_toSkillInstance.skill.action_type == Command.Defense ) { IM.Vector3 moveDir = m_player.moveDirection.normalized; if (moveDir == IM.Vector3.zero) { m_animType = AnimType.N_TYPE_0; } else { IM.Number fAngle = IM.Vector3.Angle(m_player.forward, moveDir); if (fAngle > IM.Number.zero && fAngle <= new IM.Number(45)) { m_animType = AnimType.N_TYPE_1; } else if (fAngle > new IM.Number(45) && fAngle <= new IM.Number(90)) { if (IM.Vector3.Cross(moveDir, m_player.forward).y > IM.Number.zero) { m_animType = AnimType.N_TYPE_2; } else { m_animType = AnimType.N_TYPE_3; } } else if (fAngle > new IM.Number(90) && fAngle < IM.Math.HALF_CIRCLE) { m_animType = AnimType.N_TYPE_4; } } } }
bool _IsDefended(Player target) { IM.Number fDistance = GameUtils.HorizonalDistance(m_player.position, target.position); if (fDistance > m_defenseDist) { return(false); } PlayerState.State curState = target.m_StateMachine.m_curState.m_eState; if (curState != State.eRun && curState != State.eRush) { return(false); } IM.Vector3 lhs = m_player.position + m_player.right * m_defenseRadius; IM.Vector3 rhs = m_player.position - m_player.right * m_defenseRadius; IM.Vector3 playerToLhs = GameUtils.HorizonalNormalized(lhs, target.position); IM.Vector3 playerToRhs = GameUtils.HorizonalNormalized(rhs, target.position); if (IM.Vector3.Dot(target.forward, m_player.forward) > IM.Number.zero) { return(false); } IM.Number fCrossRet1 = IM.Vector3.Cross(playerToLhs, target.moveDirection).y; IM.Number fCrossRet2 = IM.Vector3.Cross(playerToRhs, target.moveDirection).y; if (fCrossRet1 * fCrossRet2 > IM.Number.zero) { return(false); } return(true); }
public void AddCurve(IM.Number fTime, IM.Number fX_a, IM.Number fX_b, IM.Number fX_c, IM.Number fY_a, IM.Number fY_b, IM.Number fY_c, IM.Number fZ_a, IM.Number fZ_b, IM.Number fZ_c) { SShootCurve ShootCurve = new SShootCurve(); ShootCurve.fTime = fTime; ShootCurve.fX_a = fX_a; ShootCurve.fX_b = fX_b; ShootCurve.fX_c = fX_c; ShootCurve.fY_a = fY_a; ShootCurve.fY_b = fY_b; ShootCurve.fY_c = fY_c; ShootCurve.fZ_a = fZ_a; ShootCurve.fZ_b = fZ_b; ShootCurve.fZ_c = fZ_c; m_ShootCurveList.Add(ShootCurve); m_fTime += fTime; IM.Vector3 vFinPos = new IM.Vector3(); IM.Vector3 vFinVel = new IM.Vector3(); vFinPos.x = fX_a * fTime * fTime + fX_b * fTime + fX_c; vFinPos.y = fY_a * fTime * fTime + fY_b * fTime + fY_c; vFinPos.z = fZ_a * fTime * fTime + fZ_b * fTime + fZ_c; vFinVel.x = IM.Number.two * fX_a * fTime + fX_b; vFinVel.y = IM.Number.two * fY_a * fTime + fY_b; vFinVel.z = IM.Number.two * fZ_a * fTime + fZ_b; m_vFinPos = vFinPos; m_vFinVel = vFinVel; }
public void BoundInZone(ref IM.Vector3 pos) { foreach (ZoneConstrain zoneConstrain in mZoneConstrain) { zoneConstrain.Constraint(ref pos); } }
public void InitState() { collide = true; collideToDown = false; IM.Number fCrossCollideRate = _CalcCrossCollideRate(crosser, m_player); if (IM.Random.value < fCrossCollideRate) { IM.Vector3 dirTargetToBasket = GameUtils.HorizonalNormalized(m_match.mCurScene.mBasket.m_vShootTarget, targetPos); targetPos = targetPos + dirTargetToBasket * IM.Number.half; //collide = false; } IM.Vector3 vecPlayerToTarget = targetPos - m_player.position; vecPlayerToTarget.y = IM.Number.zero; dirMove = vecPlayerToTarget.normalized; speed = vecPlayerToTarget.magnitude / time; if (IM.Vector3.Dot(m_player.right, dirMove) > IM.Number.zero) //right { m_animType = AnimType.N_TYPE_1; } else { m_animType = AnimType.N_TYPE_0; } m_player.forward = -crosser.forward; }
public override void Update(IM.Number fDeltaTime) { if (m_player.m_StateMachine.assistAI.curCommand != Command.TraceBall || m_ball.m_ballState != BallState.eLoseBall) { m_player.m_StateMachine.assistAI.Disable(); } IM.Vector3 targetPos = m_ball.position; IM.Vector3 vecPlayerToTarget = targetPos - m_player.position; vecPlayerToTarget.y = IM.Number.zero; if (vecPlayerToTarget.magnitude < new IM.Number(0, 100)) { m_player.moveDirection = IM.Vector3.zero; m_player.m_moveType = MoveType.eMT_Stand; } else { int dir; IM.Vector3 vel; IM.Number angle = IM.Vector3.FromToAngle(IM.Vector3.forward, vecPlayerToTarget.normalized); GameUtils.AngleToDir(angle, out dir, out vel); m_player.m_dir = dir; m_player.m_moveType = MoveType.eMT_Rush; } }
override public void Update(IM.Number fDeltaTime) { if (behaviour.GetBehaviour(system.index) != PractiseStepBehaviour.Defense) { system.SetTransaction(AIState.Type.ePractiseGuide_Idle); return; } else { IM.Vector3 dirTarget2Basket = GameUtils.HorizonalNormalized(m_match.mCurScene.mBasket.m_vShootTarget, m_player.m_defenseTarget.position); IM.Vector3 targetPos = m_player.m_defenseTarget.position + dirTarget2Basket * IM.Number.two; if (GameUtils.HorizonalDistance(targetPos, m_player.position) > new IM.Number(0, 100)) { m_moveTarget = targetPos; } else { m_player.m_moveHelper.StopMove(); m_player.m_moveType = fogs.proto.msg.MoveType.eMT_Defense; } List <SkillInstance> basicSkills = m_player.m_skillSystem.GetBasicSkillsByCommand(Command.Defense); if (basicSkills.Count != 0) { m_player.m_toSkillInstance = basicSkills[0]; } } }
static int HorizonalNormalized(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(IM.Vector3), typeof(IM.Vector3))) { IM.Vector3 arg0 = (IM.Vector3)LuaScriptMgr.GetLuaObject(L, 1); IM.Vector3 arg1 = (IM.Vector3)LuaScriptMgr.GetLuaObject(L, 2); IM.Vector3 o = GameUtils.HorizonalNormalized(arg0, arg1); LuaScriptMgr.PushValue(L, o); return(1); } else if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(LuaTable), typeof(LuaTable))) { Vector3 arg0 = LuaScriptMgr.GetVector3(L, 1); Vector3 arg1 = LuaScriptMgr.GetVector3(L, 2); Vector3 o = GameUtils.HorizonalNormalized(arg0, arg1); LuaScriptMgr.Push(L, o); return(1); } else { LuaDLL.luaL_error(L, "invalid arguments to method: GameUtils.HorizonalNormalized"); } return(0); }
public static bool GetNodePosition(SampleNode node, string clip, int frame, out IM.Vector3 position) { AnimData animData = AnimationSampleManager.Instance.GetAnimData(clip); IM.Number time = frame / animData.frameRate; return(GetNodePosition(node, animData, time, out position)); }
public static Player ChoosePassTarget(Player passer) { Player catcher = null; IM.Number minAngle = IM.Number.max; foreach (Player member in passer.m_team.members) { if (member == passer) { continue; } PlayerState ps = member.m_StateMachine.m_curState; if (ps.m_eState == PlayerState.State.eRebound || ps.m_eState == PlayerState.State.eBlock || ps.m_eState == PlayerState.State.eFallGround ) { continue; } IM.Vector3 dirPasser2Member = GameUtils.HorizonalNormalized(member.position, passer.position); IM.Number angle = IM.Vector3.Angle(passer.moveDirection, dirPasser2Member); if (angle > minAngle) { continue; } minAngle = angle; catcher = member; } return(catcher); }
public static bool GetNodePosition(SampleNode node, AnimData animData, IM.Number time, out IM.Vector3 position) { int count = animData.sampleDatas.Count; for (int i = 0; i < count; ++i) { SampleData sample1 = animData.sampleDatas[i]; if (time == sample1.time) { position = sample1.nodes[node].position; return(true); } else if (time > sample1.time && i < count - 1) { SampleData sample2 = animData.sampleDatas[i + 1]; if (time < sample2.time) { IM.Vector3 pos1 = sample1.nodes[node].position; IM.Vector3 pos2 = sample2.nodes[node].position; IM.Number t = (time - sample1.time) / (sample2.time - sample1.time); position = IM.Vector3.Lerp(pos1, pos2, t); return(true); } } } position = IM.Vector3.zero; return(false); }
private GameObject CreatePoint() { GameObject point = new GameObject("Point"); if (totalPointNum++ == 0) { curPointPosition = GameSystem.Instance.MatchPointsConfig.FreeThrowCenter.transform.position; point.transform.localPosition = (Vector3)curPointPosition; //GameObject freeThrowCenter = ResourceLoadManager.Instance.LoadPrefab("Prefab/DynObject/MatchPoints/GrabPoint_Pos") as GameObject; //Transform npc = freeThrowCenter.transform.FindChild("NPC"); //point.transform.localPosition = npc.position; } else { curPointPosition = GeneratePointPosition(); point.transform.localPosition = (Vector3)curPointPosition; } GameObject arrow = Object.Instantiate(ResourceLoadManager.Instance.LoadPrefab("Prefab/Indicator/Position")) as GameObject; arrow.transform.parent = point.transform; arrow.transform.localPosition = new Vector3(0f, 0.01f, 0f); //SphereCollider collider = point.AddComponent<SphereCollider>(); //collider.isTrigger = true; //collider.radius = 0.7f; //SceneTrigger trigger = point.AddComponent<SceneTrigger>(); //trigger.onTrigger += OnGrabPoint; //trigger.oneShot = false; return(point); }
void _DrawSector(Sector sector, Color color) { Gizmos.color = color; if (sector.nonArc) { IM.Vector3 from = m_rim + IM.Quaternion.AngleAxis(sector.range.x, IM.Vector3.up) * IM.Vector3.right * sector.distance.x; IM.Vector3 to = m_rim + IM.Quaternion.AngleAxis(sector.range.x, IM.Vector3.up) * IM.Vector3.right * sector.distance.y; Gizmos.DrawLine((Vector3)from, (Vector3)to); IM.Vector3 from1 = m_rim + IM.Quaternion.AngleAxis(sector.range.y, IM.Vector3.up) * IM.Vector3.right * sector.distance1.x; IM.Vector3 to1 = m_rim + IM.Quaternion.AngleAxis(sector.range.y, IM.Vector3.up) * IM.Vector3.right * sector.distance1.y; Gizmos.DrawLine((Vector3)from1, (Vector3)to1); Gizmos.DrawLine((Vector3)from, (Vector3)from1); Gizmos.DrawLine((Vector3)to, (Vector3)to1); } else { GameUtils.DrawWireArc((Vector3)m_rim, Vector3.up, Quaternion.AngleAxis((float)sector.range.x, Vector3.up) * Vector3.right, (float)m_angle, (float)sector.distance.x, color); GameUtils.DrawWireArc((Vector3)m_rim, Vector3.up, Quaternion.AngleAxis((float)sector.range.x, Vector3.up) * Vector3.right, (float)m_angle, (float)sector.distance.y, color); IM.Vector3 dirRim2Sector1 = m_rim + IM.Quaternion.AngleAxis(sector.range.x, IM.Vector3.up) * IM.Vector3.right * sector.distance.x; IM.Vector3 dirRim2Sector2 = m_rim + IM.Quaternion.AngleAxis(sector.range.x, IM.Vector3.up) * IM.Vector3.right * sector.distance.y; Gizmos.DrawLine((Vector3)dirRim2Sector1, (Vector3)dirRim2Sector2); dirRim2Sector1 = m_rim + IM.Quaternion.AngleAxis(sector.range.y, IM.Vector3.up) * IM.Vector3.right * sector.distance.x; dirRim2Sector2 = m_rim + IM.Quaternion.AngleAxis(sector.range.y, IM.Vector3.up) * IM.Vector3.right * sector.distance.y; Gizmos.DrawLine((Vector3)dirRim2Sector1, (Vector3)dirRim2Sector2); } //Debug.DrawRay(GameUtils.DummyV2Y(sector.center), Vector3.up); }
static int Equals(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(IM.Vector3), typeof(IM.Vector3))) { IM.Vector3 obj = (IM.Vector3)LuaScriptMgr.GetVarObject(L, 1); IM.Vector3 arg0 = (IM.Vector3)LuaScriptMgr.GetLuaObject(L, 2); bool o = obj.Equals(arg0); LuaScriptMgr.Push(L, o); return(1); } else if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(IM.Vector3), typeof(object))) { IM.Vector3 obj = (IM.Vector3)LuaScriptMgr.GetVarObject(L, 1); object arg0 = LuaScriptMgr.GetVarObject(L, 2); bool o = obj.Equals(arg0); LuaScriptMgr.Push(L, o); return(1); } else { LuaDLL.luaL_error(L, "invalid arguments to method: IM.Vector3.Equals"); } return(0); }
//public bool IsBlocked(Vector2 pos) //{ // return true; //} public Sector Bounce(IM.Vector2 pos, Sector collideSector, SectorArea area) { int iCurSector = CalcSectorIdx(pos.x0z); int iColomn = m_AngleList.Count; int iCurColomn = iCurSector % iColomn; GameMatch match = GameSystem.Instance.mClient.mCurMatch; IM.Vector3 dirSectorToBasket = GameUtils.HorizonalNormalized(match.mCurScene.mBasket.m_vShootTarget, collideSector.center.x0z); IM.Vector3 dirSectorToBasketRight = IM.Quaternion.AngleAxis(new IM.Number(90), IM.Vector3.up) * dirSectorToBasket; IM.Vector2 curRight = dirSectorToBasketRight.xz; IM.Vector2 dirSector2Pos = (collideSector.center - pos).normalized; int iNewCol = iCurColomn; if (IM.Vector2.Dot(dirSector2Pos, curRight) > IM.Number.zero) { iNewCol = Mathf.Clamp(iCurColomn + IM.Random.Range(3, 6), (int)area.start.x, (int)area.start.x + (int)area.range.x - 1); } else { iNewCol = Mathf.Clamp(iCurColomn - IM.Random.Range(3, 6), (int)area.start.x, (int)area.start.x + (int)area.range.x - 1); } int iNewRow = Mathf.Clamp((int)area.start.y + IM.Random.Range(0, (int)area.range.y), (int)area.start.y, (int)area.start.y + (int)area.range.y - 1); int index = iNewRow * iColomn + iNewCol; return(m_Sectors[index]); //AddDrawSector("targetSector", targetSector); }
public void OnPass() { //if( m_ball.m_interceptor != null ) // return; Player catchPlayer = m_player.m_passTarget; if (catchPlayer == null) { return; } if (!m_player.m_bWithBall) { return; } IM.Vector3 startPos = m_ball.position; m_player.DropBall(m_ball); m_ball.position = startPos; m_ball.OnPass(m_player, catchPlayer, m_interceptedPos, m_interceptor); m_ball.m_castedSkill = m_curExecSkill; m_player.eventHandler.NotifyAllListeners(PlayerActionEventHandler.AnimEvent.ePass); }
override public void OnEnter(PlayerState lastState) { base.OnEnter(lastState); if (m_player.m_eHandWithBall == Player.HandWithBall.eLeft) { m_animType = AnimType.B_TYPE_0; } else if (m_player.m_eHandWithBall == Player.HandWithBall.eRight) { m_animType = AnimType.B_TYPE_1; } m_curAction = m_mapAnimType[m_animType]; m_dirPlayerToBasket = GameUtils.HorizonalNormalized(m_basket.m_vShootTarget, m_player.position); PlayerAnimAttribute.AnimAttr attr = m_player.m_animAttributes.GetAnimAttrById(Command.BackToBack, m_curAction); if (attr != null) { PlayerAnimAttribute.KeyFrame_RotateToBasketAngle keyFrame = attr.GetKeyFrame("RotateToBasketAngle") as PlayerAnimAttribute.KeyFrame_RotateToBasketAngle; IM.Number frameRate = m_player.animMgr.GetFrameRate(m_curAction); m_dirPlayerToBasket = GameUtils.HorizonalNormalized(m_basket.m_vShootTarget, m_player.position); IM.Vector3 dirFaceTo = IM.Quaternion.AngleAxis(keyFrame.angle, IM.Vector3.up) * m_dirPlayerToBasket; IM.Number fAngle = IM.Vector3.Angle(m_player.forward, dirFaceTo); m_relAngle = keyFrame.angle; m_turningSpeed = IM.Math.Deg2Rad(fAngle) / (keyFrame.frame / frameRate); m_rotateTo = RotateTo.eBasket; m_rotateType = RotateType.eSmooth; m_bMoveForward = false; } m_player.animMgr.CrossFade(m_curAction, false); m_player.m_stamina.m_bEnableRecover = false; }
override public void OnEnter(AIState lastState) { IM.Vector3 dirShoot = IM.Quaternion.AngleAxis(IM.Random.Range(-new IM.Number(90), new IM.Number(90)), IM.Vector3.up) * (-IM.Vector3.forward); IM.Vector3 moveTarget = m_basket.m_vShootTarget + dirShoot * new IM.Number(3); moveTarget.y = IM.Number.zero; m_moveTarget = moveTarget; }
public void MoveTo(IM.Vector3 vTarget) { IM.Math.CheckRange(vTarget); targetPosition = vTarget; _bMoveToTarget = true; _owner.m_moveType = MoveType.eMT_Run; }
private void RefreshBalls() { for (uint i = 0; i < refresh_infos[refreshTimeNum].normal; ++i) { UBasketball ball = mCurScene.CreateBall(); IM.Vector3 tempPos = GenerateIn3PTPosition(); tempPos.y = ball.m_ballRadius; ball.SetInitPos(tempPos); ball.m_ballState = BallState.eLoseBall; } for (uint i = 0; i < refresh_infos[refreshTimeNum].special; ++i) { UBasketball ball = mCurScene.CreateBall(); IM.Vector3 tempPos = GenerateIn3PTPosition(); tempPos.y = ball.m_ballRadius; ball.SetInitPos(tempPos); ball.m_special = true; ball.onGrab += OnGrab; ball.m_ballState = BallState.eLoseBall; } ++refreshTimeNum; if (refreshTimeNum < 3) { timer.SetTimer(refresh_infos[refreshTimeNum].interval); timer.stop = false; } else { timer.stop = true; } }
static int Convert(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 1 && LuaScriptMgr.CheckTypes(L, 1, typeof(IM.Vector3))) { IM.Vector3 arg0 = (IM.Vector3)LuaScriptMgr.GetLuaObject(L, 1); fogs.proto.msg.SVector3 o = GameUtils.Convert(arg0); LuaScriptMgr.PushObject(L, o); return(1); } else if (count == 1 && LuaScriptMgr.CheckTypes(L, 1, typeof(LuaTable))) { Vector3 arg0 = LuaScriptMgr.GetVector3(L, 1); fogs.proto.msg.SVector3 o = GameUtils.Convert(arg0); LuaScriptMgr.PushObject(L, o); return(1); } else { LuaDLL.luaL_error(L, "invalid arguments to method: GameUtils.Convert"); } return(0); }
bool _ValidDefender(Player defender) { if (defender == null) { return(false); } //if( m_player.m_AOD.GetStateByPos(defender.position) == AOD.Zone.eInvalid ) // return false; IM.Number angle = new IM.Number(55); IM.Number range = new IM.Number(2, 600); IM.Vector3 dirPlayerToDefender = GameUtils.HorizonalNormalized(defender.position, m_player.position); IM.Number fDistance = GameUtils.HorizonalDistance(defender.position, m_player.position); if (IM.Vector3.Angle(m_player.forward, dirPlayerToDefender) > angle || fDistance > range) { return(false); } if (defender.m_StateMachine.m_curState.m_eState != State.eStand && defender.m_StateMachine.m_curState.m_eState != State.eDefense && defender.m_StateMachine.m_curState.m_eState != State.eRun && defender.m_StateMachine.m_curState.m_eState != State.eRush) { return(false); } return(true); }
static bool InFrontOfBallOwner(Player player, UBasketball ball, IM.Number distThreshold) { if (ball.m_owner == null) { return(false); } //distance IM.Number dist = GameUtils.HorizonalDistance(player.position, ball.position); if (dist > distThreshold) { Debug.Log("Steal distance: " + dist + " greater than " + distThreshold); return(false); } //is in front of target IM.Vector3 dir = player.position - ball.m_owner.position; dir.Normalize(); IM.Number angle = IM.Vector3.Angle(ball.m_owner.forward, dir); if (angle > new IM.Number(90)) { Debug.Log("Steal angle " + angle); return(false); } return(true); }