Skip to content

Character

Mikhail Albershtein edited this page Apr 4, 2020 · 27 revisions

ICharacter

ICharacter is the principal interface for the characters. It's a parent of one interface- IPhysicalCharacter which is the character that uses Rigidbody for the movement in the world.
From now on we are going to refer to the Physical Character.

The class that implements ICharacter is a "container" facade class - it has references to all the other classes and, if you implement a new component to the class and you need, for example IAttackManager, you should get it from the ICharacter class and store the references in your component.
Character GameObject


Character GameObject

Character Components

Character requires the following monobehaviour scripts/components:

  • ICharacter class
  • Rigidbody
  • Stats
  • Collider

Attributes

Character Attributes

ICharacter class requires the following classes:

  • IMovement - current movement state. In charge of moving the character
  • IAnimatorFacade - the layer to communicate with the animator
  • IMovementDirection- the class that combines input with the camera to control the direction the player is moving
  • IHealthComponent - in charge of dealing with taking damage
  • IArmour - calculates the taken damage based on the armour
  • IAttackManager - controls the attacking logic of the character

Other attributes:

  • CameraView cameraView - camera enum to change movementDirection
  • FastEnumIntEqualityComparer FastEnumIntEqualityComparer - Optimized enum comparator for the Dictionary .Learn more in IMovement page
  • Dictionary<MovementEnum, IMovement> movements - every possible movement states. Learn more in IMovement page

Getters

Make sure that all the classes that you need in your components(movement, health, animator, etc...) you get from the ICharacter. That's why the character has mainly only getters. It makes easier to control the dependencies and can remove possible bugs.

Recomended GameObject Structure

Character GameObject

I recommend that you use that structure for building your character:


Stats

Stats

Stats is the class that contains all the stats of the character(health, speed, jump force, etc...)