2D Sci-Fi space shooter video game developed using Unity Game Engine and C# programming language. Developed using "The Most Comprehensive Guide To Unity Game Development Vol 1" course by Awesome Tuts.
This script handles the movement of the player using the keyboard.
- speed: The speed of the player's movement. Default value is 600f.
- myBody: The rigidbody component of the player.
- Awake(): Gets the rigidbody component of the player.
- FixedUpdate(): Calls the HandleMovement() method in every fixed update.
- HandleMovement(): Handles the movement of the player based on the input keys.
This script handles the engine fires of the player's ship.
- engineFires: The particle system components of the engine fires.
- enginePower: The power of the engine fires. Default value is 10.
- Update(): Calls the HandleFireEngine() method in every update.
- HandleFireEngine(): Handles the emission of engine fire particles based on the input keys.
- EmiEngineFireParticle(int engineIndex, int enginePower): Emits engine fire particles for the given engine index and power.
This script handles the collision of the player's projectiles, meteors, and collectibles.
- OnTriggerEnter2D(Collider2D collision): Destroys the collided object if it's a meteor or a collectible. Sets the collided object to inactive if it's a projectile.
bool moveOnX
: Whether the enemy should move on the X-axis or not.bool moveOnY
: Whether the enemy should move on the Y-axis or not.float minX
: The minimum position of the enemy on the X-axis.float maxX
: The maximum position of the enemy on the X-axis.float minY
: The minimum position of the enemy on the Y-axis.float maxY
: The maximum position of the enemy on the Y-axis.float moveSpeed
: The speed at which the enemy moves.float horizontalMovementTreshold
: The maximum distance the enemy can move from its initial position on the X-axis.float verticalMovementTreshold
: The maximum distance the enemy can move from its initial position on the Y-axis.
Vector3 tempMovement_Horizontal
: A temporary vector used to store the enemy's position while moving horizontally.Vector3 tempMovement_Vertical
: A temporary vector used to store the enemy's position while moving vertically.bool moveLeft
: Whether the enemy is moving left or not.bool moveUp
: Whether the enemy is moving up or not.
void HandleEnemyMovementHorizontal()
: Handles the enemy's horizontal movement.void HandleEnemyMovementVertical()
: Handles the enemy's vertical movement.
Transform[] movementPoints
: An array of points the enemy can move towards.float moveSpeed
: The speed at which the enemy moves.bool moveRandomly
: Whether the enemy should move towards a random point or not.
int currentMoveIndex
: The index of the current point the enemy is moving towards.Vector3 targetPosition
: The position of the current point the enemy is moving towards.
void SetTargetPosition()
: Sets the target position to the next point in themovementPoints
array.void SelectRandomPosition()
: Selects a random point from themovementPoints
array as the target position.void SelectPointToPointPosition()
: Selects the next point in themovementPoints
array as the target position.
float minX
: The minimum position of the enemy on the X-axis.float maxX
: The maximum position of the enemy on the X-axis.float minY
: The minimum position of the enemy on the Y-axis.float maxY
: The maximum position of the enemy on the Y-axis.float moveSpeed
: The speed at which the enemy moves.
Vector3 targetPosition
: The position the enemy is moving towards.
void SetTargetPosition()
: Sets the target position to a random position within theminX
,maxX
,minY
, andmaxY
bounds.
The tag for the object that holds all of the player's projectiles.
The tag for the object that holds all of the enemy's projectiles.
The tag for all types of projectiles in the game.
The tag for all enemies in the game.
The tag for the player object in the game.
The tag for all meteors in the game.
The tag for all objects in the game that do not have a tag assigned to them.
The tag for the player's health slider object.
The tag for all collectable objects in the game.
This class handles the movement and rotation of a meteor object.
The minimum speed the meteor can move at.
The maximum speed the meteor can move at.
The current speed of the meteor on the X axis.
The current speed of the meteor on the Y axis.
A boolean that determines whether the meteor can move on the X axis.
A boolean that determines whether the meteor can move on the Y axis.
The minimum rotation speed of the meteor.
The maximum rotation speed of the meteor.
The current rotation speed of the meteor.
A Vector3 that holds the current position of the meteor.
The current rotation of the meteor on the Z axis.
A Unity method that is called when the script instance is being loaded.
A Unity method that is called before the first frame update.
A Unity method that is called once per frame. It updates the movement and rotation of the meteor.
A method that rotates the meteor based on its rotation speed.
A method that handles the movement of the meteor on the Y axis.
A method that handles the movement of the meteor on the X axis.
This class handles the spawning of meteor objects.
An array of meteor objects to spawn.
The minimum X position where the meteor can spawn.
The maximum X position where the meteor can spawn.
The minimum number of meteors to spawn.
The maximum number of meteors to spawn.
The minimum interval between each wave of meteors.
The maximum interval between each wave of meteors.
The number of meteors to spawn in the current wave.
A Vector3 that holds the random position where the meteor will spawn.
A Unity method that is called when the script instance is being loaded.
A Unity method that is called before the first frame update. It starts spawning meteors.
A Unity method that is called once per frame.
A method that spawns a wave of meteors. It is called recursively with a random interval between each wave.