Player

Description

This will be a singleton class and store all info about the player in the game. Things it keeps track of are the players position, velocity, whether or not it’s in demon form or not, the enemy its currently possessing, its demon power(health), and the possession gauge reading. This will also take care of moving the player including jumping, and drawing itself, performing enemies abilities if possessing one, and the targeting and possession of enemies.

Once Possession() is called, possessedEnemy is set, and calling the PerformAbility methods will call the methods of the possessed Enemy

Relationships:

  • GameObject : Inherits from GameObject
  • AnimationManager : Will have its own AnimationManager
  • Enemy : Will communicate with Enemy classes so it can tell enemies when they are being possessed and to control them
  • PlayerState : Will use the PlayerState enum in the EnumClass

Members

  • const float SOUL_POWER_MAX - max value for the soul power
  • const float SOUL_POWER_INCREMENT - the amount that soul power drains
  • const float GAUGE_REGENERATION - regeneration rate for the possession
  • const float POSSESSION_GAUGE_MAX - max value for the possession gauge
  • const float SPEED - what to set the velocity to for the player
  • bool canPossess - whether or not the player can currently possess an enemy
  • bool hasJumped - whether or not the player has jumped and not landed yet
  • bool isActive - whether the player is alive
  • bool inSoulForm - whether or not the player is in demon form
  • float possessionGaugeReading - reading of the possession gauge
  • float soulPower - the health of the players soul
  • AnimationManager animation - the players animation manager
  • Player player - the player object that will be made and returned via the GetInstance property to classes that need it
  • Enemy possessedEnemy - the enemy being possessed, will be null if in demon form. This will be used to control the enemy when possessing and to get any info it needs from it.
  • PlayerState state - what state the player is in, which is used for animation purposes
  • Texture2D texture - the texture used in soul form
  • Vector2 locScreen - x,y location on the screen
  • Vector3 position - x,y,z position of player
  • Vector3 velocity - x,y,z velocities of player

Methods

  • Update
    • checks for death, calls Death method if it has died
    • if hasn't died then calls movement method and updates the possessionGaugeReading/canPossess members
    • updates the animation based on the current state
  • Draw
    • if not possessing an enemy
      • draws itself at its current position using it's animation manager
  • UpdatePosition
    • This method will get called by an enemy that is currently possessed letting the player know its position needs to get updated.
    • This will set its position to the possessedEnemy's one
  • Movement
    • updates the position based on the players velocity.
    • if the player hasJumped is true, applies gravity and checks if the player has landed yet
  • MoveLeft
    • sets the players velocity to move left, or if possessing an enemy calls the enemies MoveLeft method
    • velocity is set based on the degree the thumbstick is pressed in that direction which is passed in
  • MoveRight
    • sets the players velocity to move right, or if possessing an enemy calls the enemies MoveRight method
    • velocity is set based on the degree the thumbstick is pressed in that direction which is passed in
  • MoveUp
    • sets the players velocity to move up, or if possessing an enemy calls the enemies MoveUp method
    • velocity is set based on the degree the thumbstick is pressed in that direction which is passed in
  • MoveDown
    • sets the players velocity to move down, or if possessing an enemy calls the enemies MoveDown method
    • velocity is set based on the degree the thumbstick is pressed in that direction which is passed in
  • Jump
    • will call the enemies jump method if possessing one (possessedEnemy.Jump() )
  • Possession
    • This method sets the possessedEnemy member to the one passed in, updates the possessionGaugeReading, and checks if canPossess needs to be false. This also makes sure that enemies are updated so that their isPossessed member is accurate, and updates inSoulForm.
  • Release
    • If the player is in body form this will release into soul form, setting the possessed enemy's isPossessed member to false
  • PerformAbility1
    • will tell the possessed enemy to perform its first ability(possessedEnemy.PerformAbility1() these perform ability methods are just to call the enemies ability methods which will actually perform the ability)
  • PerformAbility2
    • will tell the possessed enemy to perform its second ability
  • PerformSpecial
    • will tell the possessed enemy to perform its special ability
  • Reset
    • will reset position based on the position passed in, velocity, inDemonForm, possessedEnemy, demonPower, possessionGaugeReading, and animation.
  • Death
    • The level will be reset and the game will be switched to the gameover state so the MenuManager can display the game over screen
    • If the player chooses to retry, the state will be switched to gameplay and the players position will be set to the previous checkpoint.
  • Simulate

Other Notes

How Possession Will Work

Possession, in terms of targetting enemies, determining success/failure, and updating of the HUD when the possession meter needs to be shown, will be taken care of in the GameManager. Targetting of enemies will be done with the right thumbstick, and you will target an enemy that in the direction that you press the stick, if there is one. To figure out which enemy should be targeted the GameManager will pass in the player's current position, and a direction to the level manager's SelectEnemy method which will return which enemy should be selected. For example, if you pass in the position 10, 10, and the up direction, the enemies whose Y value was both less than and closest to 10 would be returned. If there is a tie in the Y direction(when the direction is up or down) then the closest X will be targeted. If the left or right direction is passed in X would be the first test with Y being the tie breaker. If there aren't any enemies in that direction it will return null.To possess an enemy you must use the right shoulder button for hard possession, and right trigger for soft possession. When doing a hard possession, by the game manager will determine a success or fail based on the willpower of the targeted enemy, and your current possession energy. When doing a soft possession, by only slightly pressing in the trigger, the game manager will update the HUD to show the will ring. When a Possession has succeeded, the GameManager will pass in the enemy that was possessed via the Possession method. When a player is possessing an enemy the player takes the place of the enemies AI and tells it when to use its abilities, move, and jump, via input.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License