public override void OnStart() { base.OnStart(); this._timer = this.moveTime; Vector3 faceDirection = base._aiEntity.FaceDirection; switch (this.angelType) { case AngelType.Local: faceDirection = base._aiEntity.FaceDirection; break; case AngelType.TargetRelative: if ((base._aiEntity.AttackTarget != null) && base._aiEntity.AttackTarget.IsActive()) { faceDirection = this.GetTargetDirection(); break; } this._timer = -1f; break; case AngelType.World: faceDirection = Vector3.forward; break; } if (this.moveType == MoveType.ConstantDirection) { this.SetDirectionFromAngle(this.angel.Value, faceDirection); } else if (this.moveType == MoveType.RandomDirection) { this.SetRandomDirectionWithWallcheck(faceDirection); } else if (this.moveType == MoveType.ChooseDirection) { if (UnityEngine.Random.value > 0.5f) { this.angel = this.chooseAngel_1; } else { this.angel = this.chooseAngel_2; } this.SetDirectionFromAngle(this.angel.Value, faceDirection); } if (this.speedDirection == SpeedDirection.WanderLR) { this.GetRandomWanDerDirectionLR(); this._wanderTimer = this.wanderIntervalTime; this._wanderHitWallTimer = 1f; } else { this._currentDirection = this.speedDirection; } }
protected override TaskStatus OnMoveUpdate() { this.UpdateTargetDistance(); if (this._timer >= 0f) { this._timer -= Time.deltaTime * base._aiEntity.TimeScale; if (base.CheckCollided()) { return(TaskStatus.Success); } if ((base._aiEntity.AttackTarget == null) || !base._aiEntity.AttackTarget.IsActive()) { return(TaskStatus.Success); } if (!this._isAutoDirectionSet && (this.speedDirection == SpeedDirection.Auto)) { BaseMonoEntity attackTarget = base._aiEntity.AttackTarget; Vector3 xZPosition = base._aiEntity.XZPosition; Vector3 b = attackTarget.XZPosition; if (Vector3.Distance(xZPosition, b) <= this.autoDistanceThreshold) { this.speedDirection = SpeedDirection.Back; } else { this.speedDirection = SpeedDirection.Forward; } this._isAutoDirectionSet = true; } Vector3 targetDirection = this.GetTargetDirection(); base._aiController.TrySteer(targetDirection, this.GetSteerRatio()); if (this.speedDirection == SpeedDirection.Back) { if (!string.IsNullOrEmpty(this.backSpeedKey.Value)) { base._aiController.TryMove(-this._backSpeed); } else { base.DoMoveBack(); } } else if (this.speedDirection == SpeedDirection.Forward) { base.DoMoveForward(); } if (Mathf.Abs(Miscs.AngleFromToIgnoreY(base._aiEntity.FaceDirection, targetDirection)) >= this.angelThreshold) { base._aiController.TrySteer(targetDirection, this.GetSteerRatio()); return(TaskStatus.Running); } } return(TaskStatus.Success); }
private void GetRandomWanDerDirectionLR() { if (UnityEngine.Random.value > 0.5f) { this._currentDirection = SpeedDirection.Left; } else { this._currentDirection = SpeedDirection.Right; } }
private void ReverseDirectionLR() { if (this._currentDirection == SpeedDirection.Left) { this._currentDirection = SpeedDirection.Right; } else if (this._currentDirection == SpeedDirection.Right) { this._currentDirection = SpeedDirection.Left; } }
public void BlockSpeedSetup() { CurrentSpeedDirection = (SpeedDirection)Random.Range(0, 2); var changedSpeedWithDifficulty = _blockSpeed * (Controller.BlockCount / 6 + 1) * 0.4f; switch (CurrentSpeedDirection) { case SpeedDirection.Forward: _blockSpeed = changedSpeedWithDifficulty; break; case SpeedDirection.Backward: _blockSpeed = changedSpeedWithDifficulty * Negative; break; } }