// Update is called once per frame void Update () { goals.ForEach(g=>g.updatePrerequisites(this)); List<Goal> pendingGoals = goals.SkipWhile(g=>g.nextGoal(this) == null).ToList(); if (pendingGoals.Any()) { Goal nextGoal = pendingGoals.First().nextGoal(this); Debug.Log(nextGoal); switch(nextGoal.GetType().ToString()) { case "GoalLocation": GoalLocation goalLocation = nextGoal as GoalLocation; if (goalIndicator != null) { goalIndicator.position = grid.positionForCoord(goalLocation.pos); } if (Time.time > pathLastUpdated + .5f) { PathFinder pathFinder = new PathFinder(manager,grid.navigable(),grid.coordForPosition(transform.position),goalLocation.pos); path = pathFinder.shortest(); pathLastUpdated = Time.time; } if (path != null) { Vector3 direction = (grid.positionForCoord(path.First()) - transform.position).normalized; Quaternion newRotation = Quaternion.LookRotation(direction,Vector3.up); transform.rotation = Quaternion.Lerp(transform.rotation,newRotation,Time.deltaTime * 4f); transform.position = transform.position + direction * 3 * Time.deltaTime; } break; case "GoalSitInChair": GoalSitInChair goalSitInChair = nextGoal as GoalSitInChair; _currentChair = goalSitInChair.chair; break; case "GoalOrderCoffee": if ( Time.time < placedOrderAt ) { placedOrderAt = Time.time; } if ( Time.time > placedOrderAt + 3f) { hasOrdered = true; } break; case "GoalDrinkCoffee": if ( Time.time < startedDrinkingCoffeeAt ) { startedDrinkingCoffeeAt = Time.time; } if ( Time.time > startedDrinkingCoffeeAt + 5f) { hasDrunkCoffee = true; } break; case "GoalSitInNearestChair": GoalSitInNearestChair goalSitInNearestChair = nextGoal as GoalSitInNearestChair; _currentChair = goalSitInNearestChair.chair; break; } } }