-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDrone.hpp
More file actions
64 lines (59 loc) · 1.38 KB
/
Drone.hpp
File metadata and controls
64 lines (59 loc) · 1.38 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
/*****************************************************************************/
/*!
\file Drone.hpp
\author Yeongki Baek
\par email: yeongki.baek\@digipen.edu
\date 08/01/2017
\brief
This is the interface file for the module
Copyright 2017, Digipen Institute of Technology
*/
/*****************************************************************************/
#pragma once
#include "BehaviorTree.hpp"
namespace HOLD
{
struct zerg_drone
{
int id;
};
class Unitset_drone
{
private:
std::stack<zerg_drone*> drones;
public:
Unitset_drone(int nodrones) { initializeBuilding(nodrones); }
const std::stack<zerg_drone*>& getDrones() const { return drones; }
private:
void initializeBuilding(int nodrones)
{
for (auto i = 0; i < nodrones; ++i)
drones.push(new zerg_drone{ nodrones - i });
}
};
struct DataContext
{
std::stack<zerg_drone*> drones;
zerg_drone* currentResource;
zerg_drone* ResourceTarget = nullptr;
};
class Gathering : public BehaviorTree::Node
{
private:
std::string name;
int probabilityOfSuccess;
public:
Gathering(const std::string newName, int prob) : name(newName), probabilityOfSuccess(prob) {}
private:
virtual bool run() override
{
if (std::rand() % 100 < probabilityOfSuccess)
{
std::cout << name << " succeeded." << std::endl;
return true;
}
std::cout << name << " failed." << std::endl;
return false;
}
};
}