Skip to content

Latest commit

 

History

History
84 lines (61 loc) · 2.99 KB

File metadata and controls

84 lines (61 loc) · 2.99 KB

Tank CPU Game

Overview: An educational game

This game is designed mainly for "Week 9 - Enemy/AI" session with The University of Sheffield GameDev Society.

The general idea is that each group/person can write their own class that inherits from "CPUBrain". They will then be able to implement methods and use provided helper methods (from CPUBrain).

In game, players can select which CPUs to spawn into the match, and can optionally add a "Player" controlled player for testing too.

Game Design Doc: Google Doc Link

How to make a CPU

The game comes with a class called CustomiseCPUBrain which has some minor base code inside of it. To make a CPU, just edit this file. If you need help / get stuck then there is an ExampleCPUBrain class that I built which uses these methods to run.

Functionality for your CPU is stored in the base class CPUBrain that this inherits from. Here is a comprehensive list of methods you can call from your CPU

Methods

Movement

bool IsObstacleAhead(float range = 10)
IDetectableObstacle GetObstacleAhead(float range = 10)
float GetRotationToLookAt(IDetectableObject obj)

bool IsMoving()
bool IsRotating()
StopAllMovement()

SetDriveInput(float value)
SetRotationInput(float value)
StopDriving()
StopRotating()

MoveForSeconds(float speed, float seconds)
RotateForSeconds(float speed, float seconds)

float GetRotation()

Direction Utilities

Vector2 GetDirectionTo(Vector2 targetPosition)
Vector2 GetDirectionTo(IDetectableObject target)
Vector2 GetDirectionToNearestTank()
Vector2 GetDirectionToNearestProjectile()

Distance Utilities

float GetDistanceTo(Vector2 targetPosition)
float GetDistanceTo(IDetectableObject target)
float GetDistanceToNearestTank()
float GetDistanceToNearestProjectile()

Detection

List<IDetectableObject> GetObjectsInViewCone()
List<IDetectableTank> GetTanksInViewCone()
List<IDetectableProjectile> GetProjectilesInViewCone()

IDetectableTank GetClosestTank()
IDetectableProjectile GetClosestProjectile()
bool IsEnemyProjectileInView()
bool IsTankShootableAhead(float range = 10)

Utilities

bool HasLineOfSightTo(IDetectableObject target)
bool IsObjectWithinRange(IDetectableObject target, float range)
bool IsTankVisible()
bool IsProjectileVisible()
bool IsAnyObjectVisible()
float GetHealth()
Shoot()

Also...

You have access to methods from the Brain class, most notably being able to override the Update() method which runs every frame, using public override void Update() in your cpu class.

If you have issues make sure to check out the ExampleCPUBrain class.

Current Roadmap

  • Make UI stay upright and above the player
  • Polish the game
    • Add recoil to shooting
    • Add SFX