Advertisement
Guest User

Untitled

a guest
Apr 7th, 2020
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.06 KB | None | 0 0
  1. #pragma once
  2. #include "Entity.h"
  3. #include "Animation.h"
  4. #include "PlayerJsonReader.h"
  5. #include "PlayerState.h"
  6. #include "PlayerStateMachine.h"
  7.  
  8. class Map;
  9. class Sprite;
  10. class TileCollider;
  11. class BurstObject;
  12. class BurstArrow;
  13. class Tile;
  14. class Locator;
  15.  
  16. class Player final : public Entity
  17. {
  18.     friend class PlayerJsonReader;
  19.     friend class PlayerStateMachine;
  20.  
  21. public:
  22.     void Accept(EntityVisitor& aVisitor) override;
  23.     void InitCollider(Map* aMap);
  24.  
  25.     void CheckCollision(const std::vector<std::shared_ptr<Entity>>&); // Remove
  26.  
  27.     void Jump();
  28.     void MoveGrounded();
  29.     void MoveAirBorne();
  30.     void Burst(const VECTOR2F& aDirection);
  31.     void AimArrow(const float aRotation, bool aSetActive);
  32.  
  33.     void SetVelocity(const VECTOR2F& aVelocity);
  34.  
  35.     CommonUtilities::RectInt GetRect() const;
  36.     const TileCollider& GetTileCollider() const;
  37.     State GetState() const;
  38.     bool  CanBurst() const;
  39.     bool  IsGrounded() const;
  40.     int   GetCoyoteFrames() const;
  41.     float GetSpeed() const;
  42.     float GetMaxSpeed() const;
  43.     float GetGravity() const;
  44.     float GetAirControl() const;
  45.     float GetBurstSpeed() const;
  46.     VECTOR2F& GetVelocity();
  47.     VECTOR2F& GetAcceleration();
  48.     const VECTOR2F& GetPosition()const;
  49.  
  50. private:
  51.     void OnInit() override;
  52.     void Update() override;
  53.     bool HandleSlopes(const Tile& aCollider, const Locator& aLocator);
  54.     void InitAnimations();
  55.  
  56.     PlayerJsonReader myJsonReader;
  57.     PlayerStateMachine myStateMachine;
  58.     std::shared_ptr<BurstArrow> myBurstArrow;
  59.  
  60.     std::unordered_map<State, std::shared_ptr<Animation>> myAnimations;
  61.     std::shared_ptr<Animation> myCurrentAnimation;
  62.    
  63.  
  64.     void SetState(State aState);
  65.    
  66.     VECTOR2F myVelocity;
  67.     VECTOR2F myAcceleration;
  68.    
  69.     int myCoyoteFrames = 0;
  70.     float myAirControl = 0.f;
  71.     float mySpeed = 0.f;
  72.     float myBurstSpeed = 0.f;
  73.     float myGravity = 0.f;
  74.     float myJumpSpeed = 0.f;
  75.     float myMaxSpeed = 0.f;
  76.     float myMaxFallSpeed = 0.f;
  77.     float myMaxSpeedAfterBurst = 0.f;
  78.     float myXVelocityFallOff = 0.f;
  79.     bool  myIsGrounded = false;
  80.     bool  myInRangeForBurst = false;
  81.     bool  myHasBursted = false;
  82.     State myState = State::Idle;
  83. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement