AniBasicSteveMapCharacterController.h
5.32 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//
//  IMapCharacterController.h
//  WattsenglishFoodApp
//
//  Created by Katarzyna Kalinowska-Górska on 22/03/2020.
//
#ifndef AniBasicSteveMapCharacterController_h
#define AniBasicSteveMapCharacterController_h
#include "IMapCharacterController.h"
#include "AniSteveCharacter.h"
#include "MapAdventureObjectSlide.h"
#include "MapAdventureObjectLadder.h"
#include "MapAdventureObjectLog.h"
#include "MapAdventureObjectPickupItem.h"
#include "AniScalingUtils.h"
#include "AniTutorialMapControl.h"
class AniBasicSteveMapCharacterControllerDelegate;
class AniBasicSteveMapCharacterController : public IMapCharacterController {
    
public:
    virtual void interactWithAdventureObjects(std::vector<IMapAdventureObject*> p_advObjects) override;
    virtual void interactWithAdventureObject(IMapAdventureObject* p_advObject) override;
    virtual void approachAdventureObject(IMapAdventureObject* p_advObject, AniMapUtils::TileData tile) override;
    inline void setDelegate(AniBasicSteveMapCharacterControllerDelegate* p_delegate){ m_delegate = p_delegate; }
    
    void disableSteveHappy();
    void disableSteveDisappointed();
    void steveLookAround();
    void steveReadyForAdventure();
    MapAdventureObjectRotatingEnd* currentlyInteractedWithObject();
    
    static constexpr float minSwipeDelta { 10 };
    
protected:
    std::vector<IMapAdventureObject*> m_visitedAdventureObjects;
    void clearVisitedAdventureObjects();
    void removeVisitedAdventureObject(IMapAdventureObject* m_object);
//    MapAdventureObjectLadder* pickVisitedLadder();
    MapAdventureObjectRotatingEnd* pickVisitedMapAdventureObjectRotatingEnd();
    void checkIfObjectRotatingEndReady(MapAdventureObjectRotatingEnd* visitedLadderORLog);
    
    bool m_fingerInteractingWithObject {false};
    bool m_isDraggingObject {false};
    bool m_isSteveTouchMoving {false};
    cocos2d::Point m_lastSingleTouchedPoint;
    bool m_blockJump {false};
    
    inline AniSteveCharacter* steveCharacter(){ return dynamic_cast<AniSteveCharacter*>(m_mapCharacter); }
    
    virtual void interactWithSlideAdventureObject(MapAdventureObjectSlide* p_slide);
    virtual void interactWithLadderAdventureObject(MapAdventureObjectLadder* p_slide);
    virtual void interactWithLogAdventureObject(MapAdventureObjectLog* p_slide);
    virtual void interactWithPickupItemAdventureObject(MapAdventureObjectPickupItem* p_slide);
    
    AniBasicSteveMapCharacterControllerDelegate* m_delegate { nullptr };
//    IMapAdventureObject
    
    // IMapControlInterface
    virtual void handleCommandSingleXYPress(const IMapControlSingleXYEventData& eventData) override;
    virtual void handleCommandSingleXYMove(const IMapControlSingleXYEventData& eventData) override;
    virtual void handleCommandSingleXYRelease(const IMapControlSingleXYEventData& eventData) override;
    
    virtual void handleCommandMultipleXYPress(const std::vector<IMapControlSingleXYEventData>& eventData) override;
    virtual void handleCommandMultipleXYMove(const std::vector<IMapControlSingleXYEventData>& eventData) override;
    virtual void handleCommandMultipleXYRelease(const std::vector<IMapControlSingleXYEventData>& eventData) override;
    
    virtual void handleCommandSingleXYLongPress(const IMapControlSingleXYEventData& eventData) override;
    virtual void handleCommandSingleXYTap(const IMapControlSingleXYEventData& eventData) override;
    virtual void handleCommandTicklingStarted() override;
    virtual void handleCommandTicklingContinued() override;
    virtual void handleCommandTicklingEnded() override;
    virtual void handleCommandFastSwipe(const IMapControlSwipeEventData& eventData) override;
    
    virtual bool shouldBlockCharacterControl();
    virtual bool checkIfTouchedAdventureObject(IMapAdventureObject* p_adventureObject, cocos2d::Point p_touchPointScreen);
    
    virtual AniMapUtils::TileData getJumpTile(cocos2d::Vec2 speed, int dirX, int dirY);
    virtual void moveCharacterToTouchedTile(const cocos2d::Point& touchLocation, const cocos2d::Point& mapPosition) override;
  
    virtual void onTileChange(const AniMapUtils::TileData& previousTile, const AniMapUtils::TileData& newTile) override;
    void adjustCharacterWalkingType(const AniMapUtils::TileData& tile);
    
//    void tut_sendTappedTileEvent(AniMapUtils::TileData p_tile);
    void tut_sendJumpStartedEvent(cocos2d::Vec2 p_characterPosition, AniMapUtils::TileData p_tile);
    void tut_sendJumpFinishedEvent(cocos2d::Vec2 p_characterPosition, AniMapUtils::TileData p_tile);
    void tut_sendTicklingFinishedEvent();
};
class AniBasicSteveMapCharacterControllerDelegate {
public:
    virtual bool isRightPickUpItem(MapAdventureObjectPickupItem* item) = 0;
    virtual bool isBonusPickUpItem(MapAdventureObjectPickupItem* item) = 0;
    virtual void onRightItemPickedUp(MapAdventureObjectPickupItem* item) = 0;
    virtual void onWrongItemPickUpTry(MapAdventureObjectPickupItem* item) = 0;
    virtual void onBonusItemPickUp(MapAdventureObjectPickupItem* item) = 0;
    virtual bool shouldApproachItem(IMapAdventureObject* item, AniMapUtils::TileData pressedTileCoords) = 0;
    virtual void onApproachedRotatingItem(MapAdventureObjectRotatingEnd* object) = 0;
    virtual void onFinishedRotatingItem(MapAdventureObjectRotatingEnd* object) = 0;
    virtual void onCancelledRotatingItem(MapAdventureObjectRotatingEnd* object) = 0;
};
#endif /* AniBasicSteveMapCharacterController_h */
