public bool Execute(AIActionList.Token token) { if (wallOffsetSet) { wallOffsetSet = false; token.Source.Rigidbody.position += wallOffset; } token.Source.Rigidbody.rotation = angle; token.Source.MovementExecution.AddPosition(new Vector2(0f, speed * Time.fixedDeltaTime)); return(true); }
public bool Execute(AIActionList.Token token) { if (moveTimer > 0f) { moveTimer -= Time.fixedDeltaTime; if (StrictMovementCheck(currentChecks)) { switch (direction) { case CharacterInput.Direction.Right: MovementAndJumpExecution(RightSide, out token.Source.Character.Input.Dir, ref token.Source.Character.Input.JumpRequest); break; default: MovementAndJumpExecution(LeftSide, out token.Source.Character.Input.Dir, ref token.Source.Character.Input.JumpRequest); break; } if (moveTimer <= 0f) { direction = CharacterInput.Direction.None; } } else { moveTimer = 0f; direction = CharacterInput.Direction.None; } return(true); } else if (directionTimer > 0f) { directionTimer -= Time.fixedDeltaTime; if (directionTimer <= 0f) { SetMove( Random.Range(MinMoveTime, MaxMoveTime), Random.Range(0, 2) == 0 ? CheckMovementDirection(RightSide, LeftSide, CharacterInput.Direction.Right, CharacterInput.Direction.Left) : CheckMovementDirection(LeftSide, RightSide, CharacterInput.Direction.Left, CharacterInput.Direction.Right) ); } return(false); } else { directionTimer = Random.Range(MinNewDirectionTime, MaxNewDirectionTime); token.Source.Character.Input.Dir = CharacterInput.Direction.None; return(false); } }