void GetOn() { if (targetElevator.transform.position.y != currentFloor) { targetElevator = null; LevelSettings.StartWaiting(gameObject, currentFloor); targetPosition = LevelSettings.GetWaitPoint(gameObject, currentFloor); MoveToTarget(targetPosition, slowSpeed); Debug.Log("missed the elevator!"); } else { var success = (targetElevator.GetComponent("ElevatorMove") as ElevatorMove).GetOn(gameObject); if (success) { onElevator = true; LightUpTarget(new Vector2(targetElevator.transform.position.x, targetFloor)); } else { Debug.Log("elevator is full!"); targetElevator = null; LevelSettings.StartWaiting(gameObject, currentFloor); targetPosition = LevelSettings.GetWaitPoint(gameObject, currentFloor); MoveToTarget(targetPosition, slowSpeed); } } }
void DoProductiveStuff() { timeSinceLastProduction += Time.deltaTime; if (timeSinceLastProduction >= timeToProduce) { timeSinceLastProduction = 0; ProductivityTextController.instance.UpdateProductivity(1); flashing = true; timeSinceFlashed = 0; if (anger > 0) { anger -= 1; ChangeToColorBasedOnAnger(); } spriteRenderer.color = flashColour; } timeSinceArrived += Time.deltaTime; if (timeSinceArrived > waitTime) { SetNewTarget(); if (targetFloor != currentFloor) { LevelSettings.StartWaiting(gameObject, currentFloor); targetPosition = LevelSettings.GetWaitPoint(gameObject, currentFloor); MoveToTarget(targetPosition, fastSpeed); } timeSinceArrived = 0; } }
void Start() { anger = 0; timeWaiting = 0; currentFloor = LevelSettings.instance.rockBottom; spriteRenderer = GetComponent <SpriteRenderer>(); originalColour = spriteRenderer.color; targetPosition = GetProductiveLocation(); SetNewTarget(); if (targetFloor != currentFloor) { LevelSettings.StartWaiting(gameObject, currentFloor); targetPosition = LevelSettings.GetWaitPoint(gameObject, currentFloor); } MoveToTarget(targetPosition, fastSpeed); timeSinceArrived = 0; }