-
Notifications
You must be signed in to change notification settings - Fork 5
Object Structure
This list assumes you understand the basics of GameObjects and Components in Unity.
###GameController This is the overarching controller script for the entire game, or at least the actual gameplay part. It controls the essentials for the game, from the number of lives each player has to the number of rounds needed to win.
Requires: 2 PlayerFieldControllers, 1 Guardian GameObject (planned)
Defines: Winning Score, Player Lives, Player's Current Score, Time for each round.
Objects that depend on it: GUI Elements(Score Indicators, Timer), EnemyManager
##PlayerFieldController This is an individual field a player moves/plays in. Behind the scenes, this controls everything about the area the Player is located in. It spawns all bullets, enemies, etc. that appear in that field. That includes the special attacks made by the other player. Almost all position calculations done by it are relative to the area it represents on a normalized scale. For example, the position that corresponds to the bottom-left corner of the Camera viewing the field can be represented as (0.0, 0.0) and (1.0,1.0) is the top-right.
Ex. (0.34, 0.7) is on the upper left, but isn't at the edge. and (0.9, 1.1) is above the top of the screen by 10% of the screen, and is 10% from the right edge of the screen.
Requires: 1 Camera, 1 ProjectilePool
Defines: the absolute positioning of most elements in the game (player, bullets, etc.), Player Spawn location.
Objects that depend on it: the Player object, the other player's field, the GameController
##Avatar/Characters This is the actual Player object. By itself it doesn't do anything, it requires a PlayerFieldController to define the space it moves about in, and a subclass of PlayerAgent to control its movements and actions. (Currently only ControlledAgent is implemented).
A PlayerAgent is a generic way to implement the way the player is controlled. ControlledAgent relays the input from a controller or the keyboard. The planned AIAgent is unimplemented at the moment, but is created with the possibility of AI/single-player in mind.
These are spawned in using prefabs handed to the GameController from the currently non-existent character select screen. The current workaround for the lack thereof is a TestSpawnPlayer script that spawns two specified characters.
Each character is defined by an object with the Avatar script attached.
Requires: BoxCollider2D, SpriteRenderer, Rigidbody2D, AttackPattern Scripts
Defines: character movement speed, shot behavior, charging behavior
Objects that depend on it: MovementBoundaries
##AttackPattern AttackPattern is the abstract superclass to all bullet patterns. These are programmed manually, but can be created to exhibit more dynamic behavior.
FireLinearBullet() creates a bullet with a given ProjectilePrefab that travels in a straight line. Defined by a start position, start rotation, velocity, and potentially an acceleration value.
FireCurvedBullet() creates a bullet with a given ProjectilePrefab travels in a curved path. In addition to the parameters used in FireLinearBullet(), it also has a angular velocity that defines how heavily it curves.
##Projectile These are both the player's shots as well as the enemy's/other player's bullets. Most developers will not touch this script at all, it's all handled by the backend coding.
These are pre-spawned en-masse at the start of the match, and is edited to match a ProjectilePrefab object when fired. Think of them as empty skeletons that ProjectilePrefabs are used to fill.
Each Projectile has a LinearVelocity and a AngularVelocity accessible in the code. LinearVelocity determines how many in-game distance units the projectile will travel in 1 second. AngularVelocity determines how many degrees it will rotate in one second. If AngularVelocity is left at 0, and LinearVelocity is not 0, the bullet will travel in a straight line. If AngularVelocity is not zero, the bullet will follow a curved movement pattern. Changing these two values over time can cause the bullet to accelerate or decelerate, and control the overall trajectory of the bullet.
##ProjectilePrefab Each ProjectilePrefab is created to define a certain kind of bullet. Each ProjectilePrefab has a SpriteRenderer, a BoxCollider2D or CircleCollider2D, and a Transform.
Bullets use a special shader coded by James. It tints the gray parts of any Sprite with the SpriteRenderer's color, but keeps both black and white. The more gray it is the heavier the hue.
The SpriteRenderer determines the color and the sprite used for the bullet.
The Collider determines the hitbox size and hitbox location for the bullet. To keep it computationally sound, only 2D Box and Circle Colliders can be used.
The Transform determines the scale of the scale of the bullet. The higher the X/Y scale, the bigger the bullet is. However, for the sake of optimization, it is generally good to keep scale at (1,1,1).