Example #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);
    }
Example #2
0
	// ------------------------------------------------------------------------
	// ------------------------------------------------------------------------
	public void loadMap(int mapNumber){

		// nuke the remains of anything old and create new
		this.resetWorld();
		this.mapNumber = mapNumber;

		// reset vars
		Time.timeScale = 1.0f; // in case paused

		// create the new tilemap
		this.tilemap = new Tilemap(this.mapNumber);

		// reattach pf
		this.pathfindingVisualization = this.gameObject.AddComponent<PathfindingVisualization>();
		this.pathfindingVisualization.attachPathfinding(this.tilemap.pathFinding);

		// update camera pan for this map to top left
		this.panCamera();

		// reset game ui state
		this.gameUI.reset(); // called after world is reset/recreated
	}
 // ------------------------------------------------------------------------
 // ------------------------------------------------------------------------
 public void setPathfindingVis(PathfindingVisualization pfVis)
 {
     this.pfVis = pfVis;
 }