-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVehicle.h
More file actions
121 lines (96 loc) · 2.55 KB
/
Copy pathVehicle.h
File metadata and controls
121 lines (96 loc) · 2.55 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#pragma once
#include "DrawableGameObject.h"
#include "WaypointManager.h"
#include "Vector2D.h"
#include "Collidable.h"
#include "ForceMotion.h"
#include "Waypoint.h"
#include <vector>
#include <iostream>
#define VEHICLE_MASS 0.00005f
#define SEEK_MESSAGE "SEEK"
#define SEEK_RADIUS 10
typedef struct MessagePosition
{
Vector2D position;
string name;
};
enum States
{
WANDER,
SEEK,
FLEE,
ARRIVE,
PURSUIT,
WAIT
};
enum CarMode
{
TAXI,
SABOTAGE
};
enum class carColour
{
redCar,
blueCar,
};
class Vehicle : public DrawableGameObject, public Collidable
{
public:
Vehicle();
public:
virtual HRESULT initMesh(ID3D11Device* pd3dDevice, carColour colour);
virtual void update(const float deltaTime);
void setPosition(Vector2D position); // the current position
void setWaypointManager(WaypointManager* wpm);
void hasCollided() {}
ForceMotion* getForceMotion() { return &m_forceMotion; }
void applyForceToPosition(const Vector2D& positionTo, string name = "");
Waypoint* targetPosition;
void SetState(States newState) { state = newState; }
States GetState() { return state; }
void SetOtherCar(Vehicle* followCar) { m_otherCar = followCar; }
void SetTargetPosition(Vector2D target);
void SetTargetPosition(Waypoint* target);
void SetCarMode(CarMode newMode) { m_carMode = newMode; }
void SetPassengerPos(Vector2D newpos) { m_passengerPosition = newpos; }
void SetFuelPos(Vector2D newpos) { m_fuelPosition = newpos; }
void SetSpeedPos(Vector2D newpos) { m_speedPosition = newpos; }
void AddFuel();
void AddSpeed();
protected: // protected methods
Vector2D* getPositionAddress() { return &m_currentPosition; }
void updateMessages(const float deltaTime);
void messageReceived(MessagePosition message);
void addMessage(MessagePosition message);
void updateState();
void TaxiUpdate();
void SabotageUpdate();
void CreateWhisker();
void UpdateWhisker(int whiskerIndex, Vector2D direction);
void Seek();
void Flee();
void Arrive();
void Wander(WaypointManager* waypoints);
void Pursuit();
Waypoint* GetRandomWaypoint();
void FindPath(Waypoint* target);
vecWaypoints m_path;
float FindDistance(Vector2D point1, Vector2D point2);
protected: // protected properties
Vector2D m_currentPosition;
Vector2D m_lastPosition;
WaypointManager* m_waypointManager;
ForceMotion m_forceMotion;
vector<Vector2D> m_whiskers;
States state;
States m_previousState;
Vehicle* m_otherCar;
float m_speed;
CarMode m_carMode;
float m_fuel;
Vector2D m_passengerPosition;
Vector2D m_fuelPosition;
Vector2D m_speedPosition;
list<MessagePosition> m_vecMessages;
};