public override void enter(FBActor actor) { FixVector2 targetPosition = actor.world.ball.particlePosition + actor.world.ball.particleVelocity * actor.configuration.tcb_normalTime; //Debuger.Log("TigerCatchingBall currentBallPos:" // + (UnityEngine.Vector2)actor.world.ball.particlePosition // + " TargetPostion " + targetPosition // + " NeedTime:" + (float)actor.configuration.tcb_normalTime // + " actor.world.ball.particleVelocity:" + (UnityEngine.Vector2)actor.world.ball.particleVelocity); actor.world.ball.willCatchBall(actor, targetPosition, actor.configuration.tcb_normalTime); FixVector2 targetPositionVelocity = targetPosition - actor.getPosition(); Fix64 distance = targetPositionVelocity.length; targetPositionVelocity = targetPositionVelocity / distance; actor.m_stateVector = targetPositionVelocity * (distance / actor.configuration.tcb_normalTime); actor.particle.dampingAcceleration = Fix64.Zero; actor.direction = targetPositionVelocity; actor.m_stateSubState = (int)SubState.kBeforeCatching; actor.m_timer = actor.configuration.tcb_normalTime; actor.world.onActorTigerCatchingBallBegin(actor); }
private bool processCatchBallHelper(FBActor actor, ref FixVector2 moveDirection) { if (!actor.catchBallHelperEnabled || actor.world.ball.owner != null) { return(false); } if (actor.world.ball.particleHeight > actor.m_configuration.maxCatchingBallHelperHeight) { return(false); } var v = actor.world.ball.particlePosition - actor.m_particle.position; var sd = v.squareLength; if (sd > actor.m_configuration.catchBallHelper_Raidus * actor.m_configuration.catchBallHelper_Raidus) { return(false); } var vu = v / Fix64.Sqrt(sd); if (FixVector2.dot(actor.m_direction, vu) < actor.m_configuration.catchBallHelper_MaxFanAngleCos) { return(false); } if (FixVector2.dot(moveDirection, vu) < actor.m_configuration.catchBallHelper_MaxAngleCos) { return(false); } if (actor.world.ball.particleVelocity.squareLength > actor.m_configuration.catchBallHelper_BallMaxSpeed.square) { return(false); } moveDirection = vu; return(true); }
//开始坠落 void _falling(FBActor actor, Fix64 deltaTime) { actor.m_timer -= deltaTime; actor.m_timeElapsedWhenFalling += deltaTime; actor.height = actor.m_heightWhenFalling - (Fix64)0.5f * actor.configuration.fallingAcceleration * actor.m_timeElapsedWhenFalling * actor.m_timeElapsedWhenFalling; if (actor.height < Fix64.Zero) { actor.height = Fix64.Zero; } if (actor.m_timer <= Fix64.Zero) { actor.m_stateSubState = (int)SubState.kAfterFalling; actor.m_timer = actor.m_configuration.dkcb_afterFallingGlideTime[actor.m_stateDataIndex]; if (actor.m_configuration.dkcb_afterFallingGlideTime[actor.m_stateDataIndex] > Fix64.Zero) { actor.m_glidingDamping = actor.m_cathingBallStateMovingVelocity.length / actor.m_configuration.dkcb_afterFallingGlideTime[actor.m_stateDataIndex]; } actor.height = Fix64.Zero; //播放球员起身动画 actor.world.onDoorKeeperBeginToGetup(actor); //Debuger.Log("begin getup: frameID:" + actor.world.world.frameCount); return; } actor.particle.velocity = actor.m_cathingBallStateMovingVelocity; }
//检测源和目标之间是否被阻挡 bool checkBlocked(FBActor src, FBActor target) { FixVector2 a = (target.getPosition() - src.getPosition()).normalized; for (int i = 0; i < m_actors.Count; i++) { var actor = m_actors[i]; if (actor == src || actor == target) { continue; } FixVector2 c = actor.getPosition() - src.getPosition(); Fix64 dotData = FixVector2.dot(c, a); if (dotData <= Fix64.Zero) { continue; } Fix64 d = c.squareLength - Fix64.FastAbs(dotData * dotData); if (d < ball.configuration.radius * ball.configuration.radius) { return(true); } } return(false); }
// 处理获取球 void _processCatchBallWhenMoving() { FBActor best = null; Fix64 bestWeight = Fix64.MinValue; foreach (var actor in m_actors) { Fix64 weight; if (actor.checkBallCatchingWhenMoving(m_ball, out weight)) { if (weight > bestWeight) { best = actor; bestWeight = weight; } } } if (best != null) { ball.transfer(best); //best.attachPosition = ball.particle.position; //best.ballAttached = true; //Debuger.Log("=============================================Ball Attached CurrentFrameNumber :" + world.frameCount); } }
//某个角色开始传球 //短传0,长传1 public void beginPassBall(FBActor actor, FixVector2 passBallDirection, int index) { //Debuger.Log("beginPassBall..........."); Fix64 maxR = m_ball.owner.configuration.passBallMaxR[index]; Fix64 minR = m_ball.owner.configuration.passBallMinR[index]; Fix64 angle = m_ball.owner.configuration.passBallFov[index]; Fix64 bestR = m_ball.owner.configuration.passBallBestR[index]; //没有键入方向,使用角色朝向 if (passBallDirection == FixVector2.kZero) { passBallDirection = actor.direction; } FBActor target = findTarget(m_ball.owner, passBallDirection, index, (int)m_ball.owner.team, m_ball.owner); if (target != null) { passBallDirection = target.getPosition() - m_ball.owner.getPosition(); passBallDirection = passBallDirection.normalized; } FixVector2 actorFaceDirection = getAjustedDirection(actor.direction, passBallDirection, actor.configuration.passBallAngleTorelance[index]); actor.doPassBall(index, actorFaceDirection); //保存传球对象 passBallType = index; passBallTarget = target; passBallDir = passBallDirection; }
void _beforeFlyCatching(FBActor actor, Fix64 deltaTime) { actor.m_timer -= deltaTime; if (actor.m_timer <= Fix64.Zero) { //Debuger.Log("_beforeFlyCatching end begin move frameNumber:" + actor.world.world.frameCount); actor.m_timer = actor.m_cathingBallStateAniWaitTime; if (actor.m_stateBool && (actor.m_stateDataIndex == 3 || actor.m_stateDataIndex == 4)) { actor.m_stateInt = 0;//接不到球 } else { actor.m_stateInt = 1;//接到球 } Fix64 verticleSpeed = _getActorVelocity(actor, actor.m_timer, out actor.m_cathingBallStateMovingVelocity); actor.particle.dampingAcceleration = Fix64.Zero; actor.m_stateSubState = (int)SubState.kFlyCatching; actor.m_cathingBallStateVerticleSpeed = verticleSpeed; //开始播放接球动画 actor.world.onDoorKeeperCatchingBall(actor, actor.m_stateDataIndex, FixVector2.cross(actor.direction, actor.m_stateVector - actor.getPosition()) < Fix64.Zero); return; } }
public override void enter() { game.changeCampState(game.goalTeam); FBActor mainActor = game.fbWorld.getMainActor(); var team = mainActor == null ? FBTeam.kBlue : mainActor.team; var camp = game.getCampType(team); game.onGameReady(camp); game.playersAITakeOver(false); game.resetPlayerState(); game.resetPosition(); game.changeCampState(game.goalTeam); game.fbWorld.setEnableBT(false); game.onEnableRecordInput(false); subState = SubState.Wait; if (game.preStateType == GameState.Replay) { waitTime = game.fbWorld.config.replayWaitTime; countdownTime = Fix64.Zero; } else { waitTime = Fix64.One; countdownTime = game.fbWorld.config.readyTime; if (WithoutEnterShow_4Test_EditorOnly.instance != null) { countdownTime = Fix64.Zero; } LogicEvent.fire2Lua("onFirstRound"); } }
public override void enter(FBActor actor) { actor.world.ball.willCatchPassingBall(actor); //Debuger.Log("QuickGetPassingBall enter:" + actor.world.world.frameCount); actor.m_particle.dampingAcceleration = Fix64.Zero; actor.m_timer = actor.m_stateValue; }
public override void leave(FBActor actor) { base.leave(actor); actor.shootBallEvent = false; actor._shootBallPressed = false; actor._shootBallTimeSum = Fix64.Zero; }
public void onShootBallOut(FBActor actor, FixVector3 velocity, Fix64 angle, FixVector3 target) { //jlx2017.05.26-log:因为行为树也要使用这个消息,所以使用fire,而不使用fire2Rendering LogicEvent.fire("onShootBallOut", actor.id); fbGame.generateRenderAction <RAL.BallShootAction>(actor.id, actor.shootingType, velocity.toVector3(), (float)angle, target.toVector3()); }
void _beforeShooting(FBActor actor, Fix64 deltaTime) { actor.m_particle.dampingAcceleration = actor.m_configuration.m1_stopDampingAcceleration_ball; actor.m_timer -= deltaTime; if (actor.m_timer < Fix64.Zero) { if (actor.m_direction != actor.m_stateVector) { actor.m_direction = actor.m_stateVector; actor.m_particle.velocity = actor.m_direction * actor.m_particle.velocity.length; } actor.m_stateSubState = (int)SubState.kAfterShooting; actor.m_timer = actor.m_configuration.sb_afterShootingTime[actor.m_stateDataIndex]; if (actor.m_stateDataIndex == (int)(ShootType.Killer)) { actor.world.fbGame.logicTimeScale = (Fix64)1.0f; } actor.world.shootBallOutEvent = true; return; } if (actor.m_direction != actor.m_stateVector) { var angle = actor.m_stateValue * (actor.m_timer / actor.m_configuration.sb_beforeShootingTime[actor.m_stateDataIndex]); var cos = Fix64.Cos(angle); var sin = Fix64.Sin(angle); actor.m_direction.x = FixVector2.dot(actor.m_stateVector, new FixVector2(cos, -sin)); actor.m_direction.y = FixVector2.dot(actor.m_stateVector, new FixVector2(sin, cos)); actor.m_particle.velocity = actor.m_direction * actor.m_particle.velocity.length; } }
SkillContext createNewSkillContext(FBActor actor, NodeMapInfo nodeMapInfo) { var context = new SkillContext(this, nodeMapInfo); context.globalData.add(actor != null ? actor.skillActor : null); return(context); }
public override void enter(FBActor actor) { actor.m_stateSubState = (int)SubState.kBeforePassing; actor.m_timer = actor.m_configuration.pb_beforePassingTime[actor.m_stateDataIndex]; var cos = FixVector2.dot(actor.m_direction, actor.m_stateVector); Fix64 ralativeDirection = Fix64.Zero; if (cos < Fix64.One) { var sin = Fix64.Sqrt(Fix64.One - cos * cos); ralativeDirection = FixVector2.cross(actor.m_direction, actor.m_stateVector); if (ralativeDirection >= Fix64.Zero) { sin = -sin; } actor.m_stateValue = Fix64.Atan2(sin, cos); } else { actor.m_stateValue = Fix64.Zero; } int passBallFoot = actor.getKickBallFoot(actor.m_stateVector, actor.m_direction); actor.world.onPassBallBegin(actor, actor.m_stateDataIndex == 0, passBallFoot == 1); }
public bool doSkill(FBActor actor, int id) { if (actor != null) { } NodeMapInfo map; if (!m_skills.TryGetValue(id, out map)) { string[] skills = new string[] { "test" }; //临时 UnityEngine.TextAsset ta = UnityEngine.Resources.Load <UnityEngine.TextAsset>("Skill/" + skills[id]); System.IO.MemoryStream ms = new System.IO.MemoryStream(ta.bytes); System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); map = (NodeMapInfo)formatter.Deserialize(ms); m_skills.Add(id, map); } SkillContext context = createNewSkillContext(actor, map); context.startup(); if (context.activedObjectCount != 0) { skillContexts.AddLast(context.updater); } return(true); }
public FBPlayerAgent(FBActor actor, behaviac.Workspace workspace) { this.actor = actor; behaviour = createBehaviour(workspace); LogicEvent.add("onShootBallOut", this, "onShootBallOut"); LogicEvent.add("onPlayTaunt", this, "onPlayTaunt"); }
public void willCatchBall(FBActor actor, FixVector2 target, Fix64 time) { m_willBeCatched = true; m_willBeCatchedActor = actor; m_particle.notify_willCatchInLand(target, time); }
// 球被某个球员直接获得 public void transfer(FBActor actor) { if (actor == null || actor == m_owner) { return; } var old = m_owner; m_owner = actor; if (old != null) { world.onOwnerDetached(old); if (old.team != actor.team) { setEnergy(energy.changeTarget); } } else { world.world.removeParticle(m_particle); m_particle.notify_catched(); if (m_kicker != null && m_kicker.team != actor.team) { setEnergy(energy.changeTarget); } } m_willBeCatched = false; m_willBeCatchedActor = null; transferTarget = null; m_kicker = null; world.onOwnerAttached(m_owner); ballState = m_owner.isDoorKeeper() ? BallState.GoalKeeper : BallState.Player; }
void processRotation(FBActor actor, FixVector2 moveDirection, bool tween, Fix64 maxAngle) { var speed = actor.m_particle.velocity.length; if (tween) { var cos = FixVector2.dot(actor.m_direction, moveDirection); var cos_max = Fix64.Cos(maxAngle); if (cos >= cos_max) { actor.m_direction = moveDirection; } else { var sin_max = FixVector2.cross(actor.m_direction, moveDirection) >= Fix64.Zero ? Fix64.Sin(maxAngle) : Fix64.Sin(-maxAngle); actor.m_direction = new FixVector2() { x = FixVector2.dot(actor.m_direction, new FixVector2(cos_max, -sin_max)), y = FixVector2.dot(actor.m_direction, new FixVector2(sin_max, cos_max)) }; } } else { actor.m_direction = moveDirection; } actor.m_particle.velocity = actor.m_direction * speed; }
public bool checkSlidingTarget(FBActor actor) { if (actor == this || actor.ignoreCollision) { return(false); } if (actor.team == this.team) { return(false); } if (actor.isDoorKeeper()) { return(false); } if (m_slidingTargets.Contains(actor)) { return(false); } //var s = actor.m_particle.radius + m_particle.radius; var s = actor.m_particle.radius + m_particle.radius + (Fix64)0.1f; if (m_particle.position.squareDistance(actor.m_particle.position) <= s * s) { m_slidingTargets.Add(actor); return(true); } return(false); }
void _prepareShooting(FBActor actor, Fix64 deltaTime) { if (actor.shootBallEvent) { actor.m_stateSubState = (int)SubState.kBeforeShooting; actor.m_timer = actor.m_configuration.sb_beforeShootingTime[actor.m_stateDataIndex]; var cos = FixVector2.dot(actor.m_direction, actor.m_stateVector); if (cos < Fix64.One) { var sin = Fix64.Sqrt(Fix64.One - cos * cos); if (FixVector2.cross(actor.m_direction, actor.m_stateVector) >= Fix64.Zero) { sin = -sin; } actor.m_stateValue = Fix64.Atan2(sin, cos); } else { actor.m_stateValue = Fix64.Zero; } if (actor.m_stateDataIndex == (int)(ShootType.Killer)) { actor.world.fbGame.logicTimeScale = (Fix64)0.01f; } // actor.world.onShootBallReady(actor); return; } actor.m_particle.dampingAcceleration = actor.m_configuration.m1_stopDampingAcceleration_ball; if (actor.m_direction != actor.m_stateVector) { var cos = FixVector2.dot(actor.m_direction, actor.m_stateVector); var maxAngle = actor.m_configuration.sb_angularSpeed * deltaTime; var cos_max = Fix64.Cos(maxAngle); var speed = actor.m_particle.velocity.length; if (cos >= cos_max) { actor.m_direction = actor.m_stateVector; } else { var sin_max = FixVector2.cross(actor.m_direction, actor.m_stateVector) >= Fix64.Zero ? Fix64.Sin(maxAngle) : Fix64.Sin(-maxAngle); actor.m_direction = new FixVector2() { x = FixVector2.dot(actor.m_direction, new FixVector2(cos_max, -sin_max)), y = FixVector2.dot(actor.m_direction, new FixVector2(sin_max, cos_max)) }; } actor.m_particle.velocity = actor.m_direction * speed; } }
void _afterCatching(FBActor actor, Fix64 deltaTime) { actor.m_timer -= deltaTime; if (actor.m_timer < Fix64.Zero) { actor.m_nextState = MoveWaitingState.instance; } }
public override bool canBreak(FBActor actor, State state) { if (!actor.shootBallEvent && state == BeAttacked.instance) { return(true); } return(false); }
public override void update(FBActor actor, Fix64 deltaTime) { actor.m_particle.velocity = actor.movement != null ? actor.movement.velocity : FixVector2.kZero; if (actor.m_locks.Count == 0) { actor.m_nextState = MoveWaitingState.instance; } }
public override bool canBreak(FBActor actor, State state) { if (state == ShootBall.instance) { return(false); } return(true); }
public override void leave(FBActor actor) { foreach (var lck in actor.m_locks) { lck._released(); } actor.m_locks.Clear(); }