private void MoveStep(FVec3 direction) { if (direction.SqrMagnitude() < Fix64.Epsilon) { this.speed = Fix64.Zero; this.velocity = FVec3.zero; return; } Fix64 dt = this.battle.deltaTime; FVec3 desiredDistance = direction * this.naturalSpeed * this.moveSpeedFactor * dt; FVec3 oldPos = this.position, pos = this.position; Fix64 dx = this.battle.maze.MoveDetection(this, desiredDistance.x, 0); pos.x += dx; this.position = pos; Fix64 dz = this.battle.maze.MoveDetection(this, desiredDistance.z, 1); pos.z += dz; this.position = pos; Fix64 moveDistance = (this.position - oldPos).Magnitude(); this.speed = moveDistance / dt; this.velocity = desiredDistance / dt; this.direction = direction; }
public void BeginMove(FVec3 direction) { if (direction.SqrMagnitude() < Fix64.Epsilon) { this.ChangeState(FSMStateType.Idle); } else { this.ChangeState(FSMStateType.Move, false, direction); } this._movingDirection = direction; }
public void GetChampionsNearby(Champion target, TargetType targetType, Fix64 radius, int maxNumber, ref List <Champion> champions) { if (targetType == TargetType.Self) { champions.Add(target); return; } radius *= radius; int count = this._champions.Count; for (int i = 0; i < count; i++) { Champion champion = this._champions[i]; if (targetType == TargetType.Hostile && champion.team == target.team) { continue; } if (targetType == TargetType.Teamate && champion.team != target.team) { continue; } if (champion == target) { champions.Add(target); continue; } FVec3 d = target.position - champion.position; if (d.SqrMagnitude() <= radius) { champions.Add(champion); } if (maxNumber >= 0 && this._champions.Count == maxNumber) { break; } } }