Character2D.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // Copyright (c) 2008-2020 the Urho3D project.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #pragma once
  23. #include <Urho3D/Scene/LogicComponent.h>
  24. // All Urho3D classes reside in namespace Urho3D
  25. using namespace Urho3D;
  26. const float MOVE_SPEED = 23.0f;
  27. const int LIFES = 3;
  28. /// Character2D component controling Imp behavior.
  29. class Character2D : public LogicComponent
  30. {
  31. URHO3D_OBJECT(Character2D, LogicComponent);
  32. public:
  33. /// Construct.
  34. explicit Character2D(Context* context);
  35. /// Register object factory and attributes.
  36. static void RegisterObject(Context* context);
  37. /// Handle update. Called by LogicComponent base class.
  38. void Update(float timeStep) override;
  39. /// Handle player state/behavior when wounded.
  40. void HandleWoundedState(float timeStep);
  41. /// Handle death of the player.
  42. void HandleDeath();
  43. /// Flag when player is wounded.
  44. bool wounded_;
  45. /// Flag when player is dead.
  46. bool killed_;
  47. /// Timer for particle emitter duration.
  48. float timer_;
  49. /// Number of coins in the current level.
  50. int maxCoins_;
  51. /// Counter for remaining coins to pick.
  52. int remainingCoins_;
  53. /// Counter for remaining lifes.
  54. int remainingLifes_;
  55. /// Indicate when the player is climbing a ladder or a rope.
  56. bool isClimbing_;
  57. /// Used only for ropes, as they are split into 2 shapes.
  58. bool climb2_;
  59. /// Indicate when the player is above a climbable object, so we can still jump anyway.
  60. bool aboveClimbable_;
  61. /// Indicate when the player is climbing a slope, so we can apply force to its body.
  62. bool onSlope_;
  63. };