![]() |
Eye of the Nile Docs
Everything you need to know to get started!
|
This script controls Geb's movement and will triggers Geb's attacks. This script mainly consists of:
Documentation updated 5/3/2025
Public Member Functions | |
void | GebOpeningCutsceneStarted () |
Called by GebPhaseController once when the opening cutscene starts. | |
void | GebPhase1Started () |
Called by GebPhaseController once when the opening cutscene is over and the bossfight starts. | |
void | GebPhase2Started () |
Called by GebPhaseController once when phase 2 starts. | |
void | GebPhase3Started () |
Called by GebPhaseController once when phase 3 starts. | |
void | GebClosingCutsceneStarted () |
Called by GebPhaseController once when the closing cutscene starts. | |
void | GebDefeated () |
Called by GebPhaseController once when the closing cutscene finishes. | |
Vector2 | GetMinInitialThrowVelocity (float deltaX, float deltaY, float gravity) |
Find the velocity vector with the minimum possible magnitude that can reach a given target location when launching a projectile. | |
Vector2 | PredictLocation (Vector2 currentPos, Vector2 currentVel, float gravity, float time) |
Predicts where something will be in a given amount of time based on its current position, velocity, and gravity. Limits are placed that excludes positions out of bounds. | |
GebAction | GetCurrentAction () |
float | GetCurrentActionPercentage () |
Protected Attributes | |
Rigidbody2D | rb |
Reference to Geb's Rigidbody 2D. | |
BoxCollider2D | bc |
Reference to Geb's Box Collider 2D. | |
Animator | animator |
Reference to Geb's animator. | |
PatrolZone | bounds |
Reference to the bossroom's Bounds (PatrolZone), which has the left and right ends of the bossroom that Geb must stay in. | |
GebPhaseController | phaseController |
Reference to Geb's phase controller. | |
GameObject | player |
Reference to the player object. | |
GameObject | throwableRock |
Reference to the rock prefab for the rocks that Geb throws and have a chance to turn into a rock golem. | |
GameObject | chargeAttackHitbox |
The hitbox that Geb uses during a charge attack to damage the player and destroy walls. | |
GameObject | protectiveWall |
Reference to the wall prefab for the walls that Geb summons in phase 2 and 3. | |
GameObject | earthquakeZone |
Reference to Geb's earthquake zone object that Geb uses in phase 3. | |
GameObject | rockTornado |
Reference to Geb's rock tornado object that Geb uses in phase 3. | |
double | minPlayerHeight = 5.879 |
Minimum y-position that Geb will attempt to throw rocks at. | |
float | bossActivationRadius = 13f |
Radius around the boss that the player must be within for the bossfight to start. | |
int | maxAttackChain = 3 |
The maximum number of attack actions that can happen in a row. | |
int | minAttackChain = -1 |
The minimum number of attacks that can happen in a row whenever there has already been at least 1 attack. Values less than or equal to 1 do nothing. | |
int | maxNonAttackChain = 3 |
The maximum number of non-attack actions that can happen in a row. | |
int | minNonAttackChain = 2 |
The minimum number of non-attack actions that can happen in a row whenever there has already been at least 1 non-attack. Values less than or equal to 1 do nothing. This can get cut short if an attack is forced. For example, Geb gets stuck on one of his walls and must start a charge attack. | |
float | flySpeedX = 15f |
(Phase 1) The speed at which Geb moves horizontally. | |
float | walkSpeedX = 5f |
(Phase 2 and 3) The speed at which Geb moves horizontally. | |
float | idleDuration = 1f |
(Phase 1, 2, and 3) Each time Geb stops moving (Idle), this is the duration it will last (in seconds). | |
float | throwDuration = 1f |
(Phase 1, 2, and 3) The duration of the rock throw animation before the rock entity is spawned (in seconds). | |
float | wallSummonDuration = 1f |
(Phase 2 and 3) The amount of time that Geb will spend raising a wall (in seconds). | |
float | chargeDuration = 3f |
(Phase 2 and 3) The maximum amount of time that Geb will charge for (in seconds). | |
float | windUpPercentage = 4f/9f |
(Phase 2 and 3) The percentage of the charge attack and earthquake durations that Geb will spend animated before the hitbox activates fully. | |
float | earthquakeDuration = 5f |
(Phase 3) The amount of time that Geb will quake the ground (in seconds). | |
float | tornadoDuration = 3f |
(Phase 3) The amount of time that Geb will surround himself in a protective rock tornado (in seconds). | |
float | minPlayerDistanceX = 10f |
(Phase 1, 2, and 3) The minimum horizontal distance that Geb will try to keep from the player when moving. | |
float | maxPlayerDistanceX = 20f |
(Phase 1, 2, and 3) The maximum horizontal distance that Geb will try to keep from the player when moving. | |
float | chargeSpeed = 18f |
(Phase 2 and 3) The speed at which Geb moves during the charge attack. | |
Private Member Functions | |
void | Awake () |
Set references to the player's GameObject and Geb's Rigidbody 2D, Box Collider 2D, phase controller, and wall detector. | |
void | Start () |
Calculate the minimum and maximum x position for Geb using the bounds of the bossroom and his collider's width. | |
void | Update () |
Every frame, activate the logic for the current phase Geb is in. | |
void | InactiveState () |
Runs every frame when Geb is inactive. | |
void | OpeningCutsceneState () |
Runs every frame when the opening cutscene is playing. | |
void | Phase1State () |
Runs every frame when Geb is in phase 1. Steps: | |
void | Phase2State () |
Runs every frame when Geb is in phase 2. Steps: | |
void | Phase3State () |
Runs every frame when Geb is in phase 3. Steps: | |
void | ClosingCutsceneState () |
Runs every frame when Geb is defeated and the closing cutscene is playing. | |
void | DefeatedState () |
Runs every frame when the closing cutscene is over. | |
void | Phase1StartIdle () |
Used to initiate the Idle action in phase 1. | |
void | Phase1StartMoving () |
Used to initiate the Moving action in phase 1. | |
void | Phase1StartRockThrowAttack () |
Used to initiate the RockThrowAttack attack in phase 1. | |
void | Phase2StartIdle () |
Used to initiate the Idle action in phase 2. | |
void | Phase2StartMoving () |
Used to initiate the Moving action in phase 2. | |
void | Phase2StartRockThrowAttack () |
Used to initiate the RockThrowAttack attack in phase 2. | |
void | Phase2StartWallSummon () |
Used to initiate the WallSummon attack in phase 2. | |
void | Phase2StartChargeAttack () |
Used to initiate the ChargeAttack attack in phase 2. | |
void | Phase3StartIdle () |
Used to initiate the Idle action in phase 3. | |
void | Phase3StartMoving () |
Used to initiate the Moving action in phase 3. | |
void | Phase3StartRockThrowAttack () |
Used to initiate the RockThrowAttack attack in phase 3. | |
void | Phase3StartWallSummon () |
Used to initiate the WallSummon attack in phase 3. | |
void | Phase3StartChargeAttack () |
Used to initiate the ChargeAttack attack in phase 3. | |
void | Phase3StartEarthquake () |
Used to initiate the Earthquake attack in phase 3. | |
void | Phase3StartRockTornado () |
Used to initiate the RockTornado attack in phase 3. | |
void | FacePlayer () |
void | FlipToFacePlayer () |
void | ChangeSide () |
Flip the side variable. | |
void | MoveGebInBounds () |
When this function is called, Geb is moved in bounds if he was out of bounds. | |
void | StartMoving () |
Used to set Geb's current action to Moving and to calculate a new target position for Geb to move towards. Variable "side" is used to determine whether Geb will pick a target position to the left or to the right of the player. This function gets called by the phase-specific action-starting functions. Use those functions instead. | |
void | ThrowRock () |
Summons and launches a rock at Geb's location. The rock is thrown towards the player. This function gets called by the phase-specific action-starting functions. Use those functions instead. | |
void | StartWallSummon () |
Sets Geb's current action to WallSummon and instantiates a wall. This function gets called by the phase-specific action-starting functions. Use those functions instead. | |
void | StartChargeAttack () |
Used in phase 2 and 3 to set Geb's current action to ChargeAttack and pick a direction to move in. This function gets called by the phase-specific action-starting functions. Use those functions instead. | |
void | StartRockTornado () |
Used in phase 3 to start the RockTornado attack. This function gets called by the phase-specific action-starting functions. Use those functions instead. | |
Private Attributes | |
WallDetectorInfo | wallDetector |
Reference to Geb's wall detector. | |
GebAction | currentAction |
The current action that Geb is taking. | |
System.Random | rng = new System.Random() |
Create random number generator. | |
int | attackCount |
The number of times in a row Geb has attacked. Negative values count how many times in a row Geb doesn't attack. | |
float | horizontalDirection = 0f |
The direction Geb moves in. | |
float | currentActionTimer = 0.0f |
How long Geb has been doing his current action (in seconds). | |
float | currentActionDuration |
How long the current action should last (in seconds). | |
float | minPosX |
The minimum x position that Geb can have. Calculated using Geb's width and the bounds of the room. | |
float | maxPosX |
The maximum x position that Geb can have. Calculated using Geb's width and the bounds of the room. | |
float | targetPositionX |
The x position that Geb is moving towards. | |
string | side |
Either "LEFT" or "RIGHT", Geb will try to stay on this side of the player in phase 1 when moving. This is done by always picking targetPositionX to be on this side of the player. This also determines which direction Geb faces. Geb always moves backwards in phase 1. | |
Vector3 | positionOnDefeat |
Geb's initial position when defeated (when the closing cutscene starts). | |
|
private |
Set references to the player's GameObject and Geb's Rigidbody 2D, Box Collider 2D, phase controller, and wall detector.
|
private |
Flip the side variable.
|
private |
Runs every frame when Geb is defeated and the closing cutscene is playing.
|
private |
Runs every frame when the closing cutscene is over.
|
private |
|
private |
void GebBossController.GebClosingCutsceneStarted | ( | ) |
Called by GebPhaseController once when the closing cutscene starts.
void GebBossController.GebDefeated | ( | ) |
Called by GebPhaseController once when the closing cutscene finishes.
void GebBossController.GebOpeningCutsceneStarted | ( | ) |
Called by GebPhaseController once when the opening cutscene starts.
void GebBossController.GebPhase1Started | ( | ) |
Called by GebPhaseController once when the opening cutscene is over and the bossfight starts.
void GebBossController.GebPhase2Started | ( | ) |
Called by GebPhaseController once when phase 2 starts.
void GebBossController.GebPhase3Started | ( | ) |
Called by GebPhaseController once when phase 3 starts.
GebAction GebBossController.GetCurrentAction | ( | ) |
float GebBossController.GetCurrentActionPercentage | ( | ) |
Vector2 GebBossController.GetMinInitialThrowVelocity | ( | float | deltaX, |
float | deltaY, | ||
float | gravity ) |
Find the velocity vector with the minimum possible magnitude that can reach a given target location when launching a projectile.
deltaX | The x distance to the target location. |
deltaY | The y distance to the target location. |
gravity | The magnitude of the gravity of the projectile (direction assumed downwards). |
|
private |
Runs every frame when Geb is inactive.
|
private |
When this function is called, Geb is moved in bounds if he was out of bounds.
|
private |
Runs every frame when the opening cutscene is playing.
|
private |
Used to initiate the Idle action in phase 1.
|
private |
Used to initiate the Moving action in phase 1.
Special behavior for when initiating the Moving action from Geb's Idle state.
Special behavior for when initiating the Moving action from Geb's Moving state (itself).
|
private |
Used to initiate the RockThrowAttack attack in phase 1.
|
private |
Runs every frame when Geb is in phase 1. Steps:
|
private |
Used to initiate the ChargeAttack attack in phase 2.
|
private |
Used to initiate the Idle action in phase 2.
|
private |
Used to initiate the Moving action in phase 2.
Special behavior for when initiating the Moving action from Geb's Moving state (itself).
|
private |
Used to initiate the RockThrowAttack attack in phase 2.
|
private |
Used to initiate the WallSummon attack in phase 2.
|
private |
Runs every frame when Geb is in phase 2. Steps:
|
private |
Used to initiate the ChargeAttack attack in phase 3.
|
private |
Used to initiate the Earthquake attack in phase 3.
|
private |
Used to initiate the Idle action in phase 3.
Special behavior for when initiating the Idle action from Geb's RockTornado state.
|
private |
Used to initiate the Moving action in phase 3.
Special behavior for when initiating the Moving action from Geb's Moving state (itself).
|
private |
Used to initiate the RockThrowAttack attack in phase 3.
|
private |
Used to initiate the RockTornado attack in phase 3.
|
private |
Used to initiate the WallSummon attack in phase 3.
|
private |
Runs every frame when Geb is in phase 3. Steps:
Vector2 GebBossController.PredictLocation | ( | Vector2 | currentPos, |
Vector2 | currentVel, | ||
float | gravity, | ||
float | time ) |
Predicts where something will be in a given amount of time based on its current position, velocity, and gravity. Limits are placed that excludes positions out of bounds.
currentPos | Current position of the entity. |
currentVel | Current velocity of the entity. |
gravity | Magnitude of gravity on the entity (assumed downwards). |
time | Number of seconds in the future this prediction will be made for. |
|
private |
Calculate the minimum and maximum x position for Geb using the bounds of the bossroom and his collider's width.
|
private |
Used in phase 2 and 3 to set Geb's current action to ChargeAttack and pick a direction to move in. This function gets called by the phase-specific action-starting functions. Use those functions instead.
|
private |
Used to set Geb's current action to Moving and to calculate a new target position for Geb to move towards. Variable "side" is used to determine whether Geb will pick a target position to the left or to the right of the player. This function gets called by the phase-specific action-starting functions. Use those functions instead.
|
private |
Used in phase 3 to start the RockTornado attack. This function gets called by the phase-specific action-starting functions. Use those functions instead.
|
private |
Sets Geb's current action to WallSummon and instantiates a wall. This function gets called by the phase-specific action-starting functions. Use those functions instead.
|
private |
Summons and launches a rock at Geb's location. The rock is thrown towards the player. This function gets called by the phase-specific action-starting functions. Use those functions instead.
|
private |
Every frame, activate the logic for the current phase Geb is in.
|
protected |
Reference to Geb's animator.
|
private |
The number of times in a row Geb has attacked. Negative values count how many times in a row Geb doesn't attack.
|
protected |
Reference to Geb's Box Collider 2D.
|
protected |
Radius around the boss that the player must be within for the bossfight to start.
|
protected |
Reference to the bossroom's Bounds (PatrolZone), which has the left and right ends of the bossroom that Geb must stay in.
|
protected |
The hitbox that Geb uses during a charge attack to damage the player and destroy walls.
|
protected |
(Phase 2 and 3) The maximum amount of time that Geb will charge for (in seconds).
|
protected |
(Phase 2 and 3) The speed at which Geb moves during the charge attack.
|
private |
The current action that Geb is taking.
|
private |
How long the current action should last (in seconds).
|
private |
How long Geb has been doing his current action (in seconds).
|
protected |
(Phase 3) The amount of time that Geb will quake the ground (in seconds).
|
protected |
Reference to Geb's earthquake zone object that Geb uses in phase 3.
|
protected |
(Phase 1) The speed at which Geb moves horizontally.
|
private |
The direction Geb moves in.
|
protected |
(Phase 1, 2, and 3) Each time Geb stops moving (Idle), this is the duration it will last (in seconds).
|
protected |
The maximum number of attack actions that can happen in a row.
|
protected |
The maximum number of non-attack actions that can happen in a row.
|
protected |
(Phase 1, 2, and 3) The maximum horizontal distance that Geb will try to keep from the player when moving.
|
private |
The maximum x position that Geb can have. Calculated using Geb's width and the bounds of the room.
|
protected |
The minimum number of attacks that can happen in a row whenever there has already been at least 1 attack. Values less than or equal to 1 do nothing.
|
protected |
The minimum number of non-attack actions that can happen in a row whenever there has already been at least 1 non-attack. Values less than or equal to 1 do nothing. This can get cut short if an attack is forced. For example, Geb gets stuck on one of his walls and must start a charge attack.
|
protected |
(Phase 1, 2, and 3) The minimum horizontal distance that Geb will try to keep from the player when moving.
|
protected |
Minimum y-position that Geb will attempt to throw rocks at.
|
private |
The minimum x position that Geb can have. Calculated using Geb's width and the bounds of the room.
|
protected |
Reference to Geb's phase controller.
|
protected |
Reference to the player object.
|
private |
Geb's initial position when defeated (when the closing cutscene starts).
|
protected |
Reference to the wall prefab for the walls that Geb summons in phase 2 and 3.
|
protected |
Reference to Geb's Rigidbody 2D.
|
private |
Create random number generator.
|
protected |
Reference to Geb's rock tornado object that Geb uses in phase 3.
|
private |
Either "LEFT" or "RIGHT", Geb will try to stay on this side of the player in phase 1 when moving. This is done by always picking targetPositionX to be on this side of the player. This also determines which direction Geb faces. Geb always moves backwards in phase 1.
|
private |
The x position that Geb is moving towards.
|
protected |
Reference to the rock prefab for the rocks that Geb throws and have a chance to turn into a rock golem.
|
protected |
(Phase 1, 2, and 3) The duration of the rock throw animation before the rock entity is spawned (in seconds).
|
protected |
(Phase 3) The amount of time that Geb will surround himself in a protective rock tornado (in seconds).
|
protected |
(Phase 2 and 3) The speed at which Geb moves horizontally.
|
private |
Reference to Geb's wall detector.
|
protected |
(Phase 2 and 3) The amount of time that Geb will spend raising a wall (in seconds).
|
protected |
(Phase 2 and 3) The percentage of the charge attack and earthquake durations that Geb will spend animated before the hitbox activates fully.