Skip to content

About

Three Unity games in C#: TownDefence, Wildball and a 2D platformer, with playable Windows builds

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

Unity Projects

Three small Unity games made in 2023 with Unity 2021.3 and C#: TownDefence, a resource-management game; Wildball, a 3D physics game; and a 2D Platformer.

Play them: Windows builds are on the Releases page, one zip per game. Unzip it and run the .exe.

About the code. The original Unity project folders were lost. The C# here was recovered from each game's Windows build (Assembly-CSharp.dll, Mono backend) with ILSpy 9.1. Class, field and method names are original; comments, local variable names and formatting were regenerated by the decompiler. Third-party code that shipped inside the builds (the Cainos pixel-art asset pack and TextMesh Pro examples) is left out. Scenes, prefabs and art were not recovered, so these folders are for reading the code, not for opening in the editor.

Game Genre Scripts
TownDefence 2D resource management TownDefence/Scripts
Wildball 3D physics game Wildball/Scripts
2D Platformer 2D action platformer 2D Platformer/Scripts

TownDefence

Keep a village alive through three goblin raids. Wheat is harvested on a timer; spend it on farmers, who raise each harvest, or soldiers, who defend. The goblin horde grows every few seconds, and every 30 seconds it raids. If you have fewer soldiers than goblins, you lose; survive three raids and you win. After each raid, prices go up and the game speeds up. The whole game is played through Unity UI.

  • GameScript: the game loop. The harvest, purchase-cooldown and raid timers drive UI fill bars. It also runs the step-by-step battle animation, the win/lose check, difficulty scaling between rounds, pause, and a results screen (wheat left, farmers and soldiers bought, rounds lasted, goblins defeated).
  • MusicHandler: background music per game state and a mute toggle with its own sound effects.
  • StateMachine: switches between screens by activating one root object at a time.

Wildball

Roll a ball through a series of levels using physics forces. Collect coins, open doors by pressing E next to them, and step on switches that raise platforms or set off animations. Enemies knock you back and end the run, and touching hazards ends it too. Reaching a level's exit loads the next scene.

  • WildBall.Inputs.PlayerInput / PlayerMovement: input is read in Update and applied as Rigidbody.AddForce in FixedUpdate; input axis names are constants in GlobalStringVars.
  • CameraMovement: a follow camera that keeps its starting offset from the ball.
  • CollectScript, DoorScript, ButtonPress, CubeMovement, RisingPlatform: trigger- and collision-driven level mechanics using Animator triggers and particle effects.
  • EnemyCorutine, LevelCorutine: game-over sequences in coroutines: a short delay, then the game-over screen and particles, then a pause. Enemies also knock the ball back with an impulse.
  • LevelTransition, StateMachine: next-level loading by build index, plus pause (Time.timeScale), resume and restart.

2D Platformer

A side-scrolling pixel-art platformer. An opening cutscene plays, then you run, jump and attack mushroom enemies that patrol back and forth. Contact with an enemy costs health, the HP counter is on screen, and death plays an animation and brings up a game-over screen with restart. Level art uses the Cainos "Pixel Art Platformer – Village Props" asset pack.

  • PlayerInput: reads movement, jump and attack input, applies an attack cooldown, and waits for the Timeline cutscene (PlayableDirector) to finish before giving control.
  • PlayerMovement: Rigidbody2D movement with a ground check (Physics2D.OverlapCircle), an AnimationCurve for run speed, jumping and sprite flipping.
  • PlayerAttack: enables an attack hitbox for half a second and damages anything tagged Damagable.
  • EntityHealth: one health component shared by the player and enemies (damage, death animation, disabling a dead enemy's collider).
  • MushroomController: an enemy state machine that walks, stops at EnemyStopper triggers, waits, then turns around. EnemyDamageDealer deals contact damage.
  • StateMachine: HP display, the delayed game-over screen and restart.

Tech

Unity 2021.3.22f1 · C# · Windows builds (Mono scripting backend) · Unity UI, Animator, Timeline, 2D and 3D physics.

About

Three Unity games in C#: TownDefence, Wildball and a 2D platformer, with playable Windows builds

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages