top of page

Codename Sicarius

Code Architecture

Codename Sicarius is a 3rd personal Melee combat game inspired by assassin's creed made using Unity & C#. I made this game to learn, apply and implement various player and enemy behaviors and features using Gameplay Programming Patterns. To make this I've made my own Statemachine from scratch and have not used Unity's Native Statemachine at all.

Patterns I've used:

- State Pattern
- Subclass Sandbox
- Type Object Pattern
- Observer Pattern

So this game is heavily based on State patterns. Both Player and Enemy have lots of states that have been managed by their own state machine. I'll describe it below.
First Let's have a look at the whole system.

So first there were 2 base Abstract Classes I made:
1. Statemachine: This abstract class has all the functions needed to track and switch between states.

2. State: This abstract class has all the functions needed to work as a State. This is the main template for all  States possible. Then I inherited 2 more Abstract classes, Player Base State & Enemy Base State. & then all the states inherited from there.

3. Player & Enemy Statemachine: Player and Enemy both State machine Has-A reference of all of systems and objects needed.  This statemachine follows Type Object Pattern.

Now, these State Machine is responsible for changing states and State will automatically handle behavior in them.
Here's a diagram of my Player States.

Types of States:
1. Existing States:  All the states in Black color are already existing to players from the beginning and they can access them anytime. 

2. Unlockable States: All the states in Green color are Unlockable states. These states you'll be able to unlock when you kill certain types of enemies. As all enemies deplete something after they die. Those items can be Health potions or any ability item that unlocks these special states that give the player more ability.

Now lets's look at Gameplay.

Gameplay

Player States

  • Free Look State: In this State players can roam around freely like in any 3rd person game.

  • Targeting State: In this state after the enemy is locked player will strafe around the locked enemy. 

  • Attacking State: In the attacking State, the Player does a 3-attack combo and with each attack, he moves a little forward which is done by the custom Force Reciever Component. Each Attack has different Damage that is done by the Attack Type Object which is containing all the data of attacks like Damage, Animations etc. 

  • Block State: This state is an Unlockable state that the player gets from killing enemies. After getting this Player can right click to make a Dome type energy shield around him and while he's in there he doesn't take any damage

  • Climb State: This state is also an Unlockable state. You'll able to climb if you go to a Ledge that has a Ledge collider to detect. 

  • Dodge State: This is also an Unlockable state. After unlocking, you can dodge enemy attacks when they attack by going left or right.

Enemy States

  • Idle State: In this state enemies are idle and playing idle animation.

  • Chase State: In this state, if a player comes near its chase radius, It starts chasing the player.

  • Attack State: If the player comes to its attack distance it'll start the attack. Normally Enemies have a single attack.

  • Impact State: In this state enemy takes damage and plays hit react animation and takes a knockback force.

  • Dead State: For this state Enemy uses Ragdoll physics to do the death scenario, it doesn't play death animation.

Player & Enemy Systems

  • Targeting System: Targeting system has 2 components, A targeter which changes the Player's current state to the Targeting state, and A target which is just a tag that every enemy has. So if ENemy is in a certain range. The player will target lock the closest one. This is only for players.
     

  • Force Reciever: As I'm using unity's character controller component, gravity doesn't work as it does with a rigid body. So I had to make my own force receiver that includes Gravity or downward force. Forward force or attack and Backwards force for Knockback. This is for Both enemy and the Player.
     

  • Input Reader: I've used unity's new Input system so for that I've added my own input reader component so it can receive input from both the Keyboard/Mouse  & Joystick. This is for players.
     

  • Ragdoll: This is used for both player and enemy death scenarios. They don't play death animation.

bottom of page