Blame view

ios/Runner/Wowgame/Classes/game_animal/MapAdventureObjectRotatingEnd.h 3.48 KB
5daad4bc   xiaoyu   游戏源码添加编译(现存问题:游戏内...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
  //
  //  MapAdventureObjectRotatingEnd.h
  //  WattsenglishFoodApp
  //
  //  Created by Katarzyna Kalinowska-Górska on 21/03/2020.
  //
  
  #ifndef MapAdventureObjectRotatingEnd_h
  #define MapAdventureObjectRotatingEnd_h
  
  #include "IMapAdventureObject.h"
  #include "AniMapUtils.h"
  #include "AniJSONParseUtilsMap.h"
  
  class MapAdventureObjectRotatingEnd : public IMapAdventureObject {
      
  public:
      // init
      MapAdventureObjectRotatingEnd(const rapidjson::Value& p_mapObjectData, IMapImageObject* p_mapImageObject, IMapImageObject* p_hintMapImageObject);
      
      // virtuals
      virtual std::vector<AniMapUtils::TileData> getEntryTiles()  const override;
      virtual std::vector<AniMapUtils::TileData> getOccupiedTiles() const override;
      
      // other getters
      inline bool isReady(){ return m_isReady; }
      virtual std::vector<AniMapUtils::TileData> getBlockedTiles() const override { return m_isReady ? std::vector<AniMapUtils::TileData>() : m_tempBlockedTiles; };
      
      // actions
      // this function rotates the map image object in such a way that grabbed point of the sprite lands on the touch point
      // when the rotation value reaches m_readyRotation+-eps, the object sets m_isReady to true and cannot be rotated any more
      virtual void rotate(/*cocos2d::Point p_grabbedPoint,*/ cocos2d::Point p_touchPointOnMap);
      virtual float evalNewRotation(cocos2d::Point p_touchPointOnMap); // calculate the rotation to which the object would rotate if rotate() was called with the same argument
  //    virtual float evalDeltaRotation(cocos2d::Point p_touchPointOnMap); // calculate the delta rotation by which the object would rotate if rotate() was called with the same argument
      virtual bool evalReady(cocos2d::Point p_touchPointOnMap); // calculate whether the object would become ready if rotate() was called with the same argument
      bool evalReady(float p_newRotationDegrees);
      virtual void resetRotation();
      virtual void startBlinking();
      virtual void stopBlinking();
      virtual inline IMapImageObject* getMapImageObject(){ return m_mapImageObjects.begin()->second; }
      virtual inline IMapImageObject* getHintMapImageObject(){ return m_hintMapImageObject; }
      
      virtual void reset() override;
      
  protected:
      // props
      bool m_wasAlwaysReady { false};
      bool m_isReady { false };
      bool m_mergesWithMapWhenReady {false};
      cocos2d::Point m_rotationPivotPoint;
      float m_originalRotation;
      float m_readyRotationDegrees;
      bool m_onlyAllowRightDirection {true};
      std::vector<AniMapUtils::TileData> m_entryTilesLying; // the tiles where the player stands at the beginning - near the lying ladder
      std::vector<AniMapUtils::TileData> m_entryTilesReady; // the tiles where the player stands at the beginning when the ladder is ready. both sides.
      std::vector<AniMapUtils::TileData> m_occupiedTilesLying; // all the tiles that we can press to approach and start interacting with the ladder when it's still lying
      std::vector<AniMapUtils::TileData> m_occupiedTilesReady; // all the tiles that we can press to approach and start interacting with the ladder when it's already up
      std::vector<AniMapUtils::TileData> m_tempBlockedTiles; // tiles that are blocked in !m_isReady state
      std::string m_originalPictureFilePath {""};
      std::string m_blinkPictureFilePath {""};
      virtual void performOnRotationComplete() = 0;
      IMapImageObject* m_hintMapImageObject {nullptr};
      
      virtual float ensureValidRotation(float rotation, float prevRotation);
  };
  
  
  #endif /* MapAdventureObjectRotatingEnd_h */