Trent Butler's Documentation - TrentButler/Unity-ProductionTeams GitHub Wiki
This documentation will briefly cover the following behaviors and give a few code examples:
~
GameManager
~
HealthPackBehaviour
~
PayloadBehaviour
~
PayloadPusherBehaviour
~
PlayerBehaviour
~
TowerBehaviour
GameManager
void PauseGame()
Gathers all moving gameobjects and locks their movement
void ResumeGame()
Gathers all moving gameobjects and unlocks their movement
void MainMenu()
Changes the scene to the ‘main menu’ scene
void QuitGame()
Closes the application
void NextRound()
Increments various member variables, Gathers all ‘enemies’ and deletes them, reset the player and payload to original spawning point, instantiates an healthpack
void Populate()
Initializes various enemies with respect to an timer
List<GameObject> Gather()
Finds all ‘enemy’ gameobjects and returns them in a list
bool GameLoop()
Checks for user input, invokes ‘NextRound()’ when an timer reaches three minutes
void UpdateEnemies()
Iterates over an list, removes an object if that object is null
string _roundTime()
Returns an string representation of the current game time
void UpdateUI()
Updates the user interface with the current games information
void Start()
Initializes the ‘game manager’ object’s member variables
void Update()
Checks if the game needs to go to the next round, end, or if a scene change is needed
Code Example:
private void PauseGame()
{
Time.timeScale = 0;
_isPaused = true;
_buttonpanel.SetActive(true);
var _player = GameObject.FindGameObjectWithTag("Player");
var _payload = GameObject.FindGameObjectWithTag("Payload");
var _enemybullets = GameObject.FindGameObjectsWithTag("JunkBullet");
var _playerbullets = GameObject.FindGameObjectsWithTag("PlayerBullet");
var enemies = Gather();
var enemyBullets = _enemybullets.ToList<GameObject>();
var playerBullets = _playerbullets.ToList<GameObject>();
enemies.ForEach(enemy => { enemy.GetComponent<Rigidbody>().isKinematic = true; });
enemyBullets.ForEach(bullet => { bullet.GetComponent<Rigidbody>().isKinematic = true; });
playerBullets.ForEach(bullet => { bullet.GetComponent<Rigidbody>().isKinematic = true; });
_player.GetComponent<Rigidbody>().isKinematic = true;
_payload.GetComponent<Rigidbody>().isKinematic = true;
}
HealthPackBehaviour
void OnTriggerEnter(Collider other)
Checks the tag of ‘other’, if the tag is “Player” increment the player’s health by a specified value, then invoke the ‘Destroy()’ method on the attached gameobject
Initializes various member variables, invokes the attached NavMeshAgent’s method ‘SetDestination()’ with a specified target
void FixedUpdate()
Updates the attached NavMeshAgent’s target every frame, assigns NavMeshAgent’s member variable ‘acceleration’ with the member variable ‘PusherEffort’
void OnTriggerEnter(Collider other)
Checks the tag of ‘other’, if the tag is “PayloadPusher” increment the member variable ‘PusherEffort’ by a specified value, if the tag is “Tower” changes the scene to the game over scene, if the tag is “Player” the attached gameobject’s position is assigned its original position
void OnTriggerExit(Collider other)
Checks the tag of ‘other’, if the tag is “PayloadPusher” decrement the member variable ‘PusherEffort’ by a specified value