- Handles box & player behavior
private void Start()
Player and box positions are stored in the start of the level via an array of Box
's
private void OnMove(InputValue value)
The value
parameter will be stored as the input vector for the direction of player movement
private bool CheckWallCollisions(Vector2 position, Vector2 moveVector)
Takes position
and the resulting destination of a Box
via the moveVector
to decide if the Box
will collide with a wall object
public Box CheckBoxCollision(Vector2 position, Vector2 moveVector)
Same as above but uses moveVector
against another block
private bool PushRowOfBoxes(Vector2 position, Vector2 moveVector)
When moving, this is used to deal with the player moving and pushing in general. It checks if there is a box in the direction you are moving, then checks again using that box's center, And so on until you hit a wall or run out of boxes. Returns true if the player can move. If there is not a wall, it will move every box in the row.
private bool PullRowOfBoxes(Vector2 position, Vector2 moveVector)
Pushes in negative move vector.
See PushRowOfBoxes()
for a similar process.
private void CalculateMovementPlayer()
Deals with sending input to the player target (preventing it from jumping around). Checks wall and box collision before the movement vector is applied.
private void UpdateMoveHistory()
Saves a history of the positions of every Box
and Player
instance per frame as a List
private void CalculateFallingMovement()
Checks if the Falling Box
is supported and calculates the necessary move vector
private Vector2 CalcMoveVector(Vector2 input)
Calculates the direction of the Player
in terms of a movement vector
private void Update()
General update loop which calls each function aside from Start()
in some manner
- Handles audio output
- Handles scene loading & transitions
- Handles save data
- Handles level logic
- Handles option management