void Start() { movementComponent = GetComponent <TimedCellMovement>(); //keeps data of the MovementComponents previous direction movementComponent.TimerComponent.OnTimerTick += () => previousDirection = movementComponent.CurrentMovementDirection; }
public void Start() { snakeTail = GetComponent <SnakeTailManager>(); occupant = GetComponent <CellOccupant>(); cellMovementHandler = GetComponent <TimedCellMovement>(); cellMovementHandler.OnNewCell += (Cell newCell) => { //moves the head to the new cell, and then calls the tail to move behind it var previousCell = occupant.CurrentCell; occupant.CurrentCell = newCell; snakeTail.TryUpdateTailPositions(previousCell); }; }