Dragentor

Dragentor is a tower defense game which my group decided to create for our Level 5 Technical Games Production Assignment
Our task was to create a game as a team and overall testing our ability to work as a team to achieve a functioning game by the deadline

Unfortunately, I am not the leader of the project and do not have the permissions to make the repository public however I will leave the link here in the case it is ever turned public
Learn More

View On Github

Project Overview

As this project was a group project not all of the project is my work and I will outline the features I added on my own and the parts of the project I helped and created with other members of the team
The main feature which I added was everything to do with the enemies within the game. From their models, to the logic for them spawning.

My Contributions

  • > Enemy models
  • > Enemy AI
  • > Enemy Spawning
  • > Enemy Manager
  • > Tower AI

Overall there are a lot of smaller parts I have contributed to as I very much enjoy working with others to solve issues they or I may stumble upon along the way.

Code Snippets / Screenshots

Enemies

The basic idea of enemies within the game is that they spawn from 3 different spawn points which are set up from the map, they path find their way to the users base and attack the base from a given range.
As the game was created in unity I created prefabs for enemies and a enemy object so adding more enemies was much easier and makes the code easier to manage. Because of the way I programmed the enemies I was able to create 4 different enemy types fairly quickly and have them working in the game.
I created Orks and these Orks had 4 different troops, a Warrior, an Archer, and a Mage as shown to the right.

using UnityEngine;

[CreateAssetMenu(menuName = "Enemy/EnemyObject")]
public class EnemyObject_SO : ScriptableObject
{
	public GameObject enemyPrefab;
	public float damage;
	public float maximumHealth;
	public float currentHealth;
	public float movementSpeed;
	public float attackRange;
	public int bounty;
}

Enemy Object

As the project used unity I found some methods of allowing for better coding practice and it also fit with the coding style of the others in my group. As stated before this object allowed us to make enemies and import them into the game much quicker as ever enemy needs to have specific values which are stated within this object.

Enemy AI

The enemies need to have a way to path-find to the players base and to do this a navMesh is placed onto the map and our enemies are set as navMeshAgents, this allows us to set the destination and the enemies with use the NavMesh to get to their destination. The other AI element added is when the enemies should attack the users base. This is done by using a variable called attackRange which stores the rage the enemies can attack from, fro example a archer is a ranged unit while a warrior is a melee unit and we should factor this into our game.

private void Update()
{
	if (navMeshAgent.remainingDistance 
	<= enemyObject.attackRange && navMeshAgent.hasPath)
	{
		if (!isAttacking)
		{
			//Within attack range of destination
			//Debug.Log("Attacking");
			OnEnemyAttackingEvent.Raise(gameObject);
			navMeshAgent.isStopped = true;
			isAttacking = true;
		}
	}
}
						
private void SpawningLogic()
{
	if (countdown <= 0f)
	{
		if (!hasWaveStarted)
		{
			//Wave Start
			Debug.Log("Wave Start");
			onEnemyWaveStartEvent.Raise(waveNumber);
			hasWaveStarted = true;
		}

		if (!SpawnWave())
		{
			hasWaveStarted = false;
			//Wave Finished Spawning Enemies
			countdown = timeBetweenWaves;
		}
	}
	else
	{
		countdown -= Time.deltaTime;
	}
}

private bool SpawnWave()
{
	bool result = true;

	if(spawnDelayCounter <= 0f)
	{
		SpawnEnemy();
		tempListEnemiesToSpawn++;
		spawnDelayCounter = spawnDelay;
		if (tempListEnemiesToSpawn >= enemiesToSpawn)
		{
			//Finished Spawning Enemies
			Debug.Log("Wave End");
			onEnemyWaveEndEvent.Raise(new Void());
			result = false;
			tempListEnemiesToSpawn = 0;
		}
	}
	else
	{
		spawnDelayCounter -= Time.deltaTime;
	}
	
	return result;
}					

Enemy Spawning / Manager

As the game is a tower defense the enemies must spawn in waves, to do this I created a EnemyManager Script which handles all of this logic. The enemies spawn at the start of a wave then a countdown is reset til the next wave, to keep the game difficult the amount of enemies spawned increases with each wave and after a set number of waves a boss enemy will spawn.

Tower AI

Due to the towers needing to shoot the enemies I worked quite closely with the person programming the towers, there were originally a few issue with how we should allow the towers to target the enemies as our initial methods were rather slow and inefficient. However, in the end we utilised our events system to request the data from the manager.

public void OnPollEnemiesListener()
{
	Vector3[] tempArray = new Vector3[enemyList.Count];
	for (int i = 0; i < tempArray.Length; i++)
	{
		tempArray[i] = enemyList[i].gameObject.transform.position;
	}

	sendEnemyVector3ArrayEvent.Raise(tempArray);
}
						


I am happy to go into further detail for this or any projects on my portfolio if needs be.

View On Github