/// <summary> /// Moves the character towards the target if needed /// </summary> protected virtual void Fly() { if (_brain.Target == null) { return; } if (this.transform.position.x < _brain.Target.position.x) { _characterFly.SetHorizontalMove(1f); } else { _characterFly.SetHorizontalMove(-1f); } if (this.transform.position.y < _brain.Target.position.y) { _characterFly.SetVerticalMove(1f); } else { _characterFly.SetVerticalMove(-1f); } if (Mathf.Abs(this.transform.position.x - _brain.Target.position.x) < MinimumDistance) { _characterFly.SetHorizontalMove(0f); } if (Mathf.Abs(this.transform.position.y - _brain.Target.position.y) < MinimumDistance) { _characterFly.SetVerticalMove(0f); } }
/// <summary> /// Moves the character towards the target if needed /// </summary> protected virtual void Fly() { bool vert, horz; vert = Random.Range(1, 100) < 50; horz = Random.Range(1, 100) < 50; if (horz) { _characterFly.SetHorizontalMove(1f); } else { _characterFly.SetHorizontalMove(-1f); } if (vert) { _characterFly.SetVerticalMove(1f); } else { _characterFly.SetVerticalMove(-1f); } }
/// <summary> /// This method initiates all the required checks and moves the character /// </summary> protected virtual void FlyPatrol() { if (_character == null) { return; } if ((_character.ConditionState.CurrentState == CharacterStates.CharacterConditions.Dead) || (_character.ConditionState.CurrentState == CharacterStates.CharacterConditions.Frozen)) { return; } // moves the agent in its current direction CheckForObstacles(); //_direction = Vector2.left; //_direction = _direction.normalized; _characterFly.SetHorizontalMove(_direction.x); _characterFly.SetVerticalMove(_direction.y); if (_direction.x < 0) { hitleft = true; } }
/// <summary> /// This method initiates all the required checks and moves the character /// </summary> protected virtual void FlyPatrol() { if (_character == null) { return; } if ((_character.ConditionState.CurrentState == CharacterStates.CharacterConditions.Dead) || (_character.ConditionState.CurrentState == CharacterStates.CharacterConditions.Frozen)) { return; } // moves the agent in its current direction CheckForObstacles(); _direction = _mmPath.CurrentPoint() - this.transform.position; _direction = _direction.normalized; _characterFly.SetHorizontalMove(_direction.x); _characterFly.SetVerticalMove(_direction.y); }
/// <summary> /// Moves the character towards the target if needed /// </summary> protected virtual void Dive() { if (_brain.Target == null) { return; } //set the distance that the driller will return to after attack returnHeight = this.transform.position.y - (_brain.Target.position.y + 1); _characterFly.FlySpeed = 20f; anim.SetBool("PointDown", true); if (this.transform.position.y < (_brain.Target.position.y + 1.5)) { _characterFly.SetVerticalMove(1f); } else { _characterFly.SetVerticalMove(-1f); } if (Mathf.Abs(this.transform.position.y - (_brain.Target.position.y + 1.5f)) < MinimumDistance) { StartCoroutine(DrillDown()); } }
/// <summary> /// This method initiates all the required checks and moves the character /// </summary> protected virtual void FlyPatrol() { if (_character == null) { return; } if ((_character.ConditionState.CurrentState == CharacterStates.CharacterConditions.Dead) || (_character.ConditionState.CurrentState == CharacterStates.CharacterConditions.Frozen)) { return; } if (_mmPath.CurrentPoint() != _mmPathPointLastFrame) { _waitDelay = _mmPath.PathElements[_mmPathIndexLastFrame].Delay; _mmPathPointLastFrame = _mmPath.CurrentPoint(); _mmPathIndexLastFrame = _mmPath.CurrentIndex(); } if (_waitDelay > 0f) { _waitDelay -= Time.deltaTime; _characterFly.SetHorizontalMove(0f); _characterFly.SetVerticalMove(0f); return; } // moves the agent in its current direction CheckForObstacles(); _direction = _mmPath.CurrentPoint() - this.transform.position; _direction = _direction.normalized; _characterFly.SetHorizontalMove(_direction.x); _characterFly.SetVerticalMove(_direction.y); _mmPathPointLastFrame = _mmPath.CurrentPoint(); _mmPathIndexLastFrame = _mmPath.CurrentIndex(); }