Ejemplo n.º 1
0
    // ------------------------------------------------------------------------
    // ------------------------------------------------------------------------
    public void enablePathfinding(PathFinding globalPathFinding, PathfindingVisualization pfVis)
    {
        // setup pathfinding and the rigidbody reference
        this.movementComponent = MovementComponent.Create(this.gameObject);
        this.particles         = this.GetComponentInChildren <ParticleSystem>();

        // init(Vector2 newPosition, Rigidbody parentRigidbody, Vector3 newMoveForceVector, float newTurningRate, float newPathfindingUpdateInterval, int newMaxPathfindingChecks){
        int pfMaxChecks = PlayerPrefs.GetInt(Constants.PREFERENCE_PATHFINDING_MAX_CHECKS, Constants.PATHFINDING_CONFIG_DEFAULT_MAX_CHECKS);

        this.movementComponent.init(Vector2.right * Constants.PHYSICS_ANIMAL_MOVE_FORCE, Constants.PHYSICS_ANIMAL_TURNING_RATE, Constants.PATHFINDING_ANIMAL_UPDATE_INTERVAL, pfMaxChecks);
        this.movementComponent.enablePathfinding(globalPathFinding);         // point to main PathFinding of the TileMap
        this.movementComponent.setPathfindingVis(pfVis);
    }