@HighligerBimBam: trotzdem danke für deine hilfe
@Nox:
also die _states.h is nur ne header datei in der andere includet sind ...
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
|
#pragma once
//general states
#include "state_Arrive.h"
#include "state_Attack.h"
#include "state_Flee.h"
#include "state_Search.h"
#include "state_Trace.h"
//ant own states
#include "state_Carry.h"
#include "state_Hide.h"
|
ich post auch mal sicherheitshalber alle anderen ... auch wenn ich da bisher (nach mehrfachem drüberschauen) nichts gefunden hab ... aber der schriftsteller findet ja bekantlich seine eigenen fehler als letztes ...
state_arrive.h
|
C-/C++-Quelltext
|
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
|
#pragma once
#include "state.h"
#include "TSingelton.h"
#include "Telegram.h"
#include "GameMovingEntity.h"
#include "SteeringBehaviors.h"
class state_Arrive : public state , public TSingelton<state_Arrive>
{
void Enter(GameMovingEntity* p);
void Execute(GameMovingEntity* p);
void Exit(GameMovingEntity* p);
bool OnMessage(GameMovingEntity* p, Telegram t);
};
void state_Arrive::Enter(GameMovingEntity* p)
{
p->getSteering()->ArriveOn();
}
void state_Arrive::Execute(GameMovingEntity* p)
{
p->moveEntity(p->getSteering()->Calculate());
}
void state_Arrive::Exit(GameMovingEntity* p)
{
p->getSteering()->ArriveOff();
}
bool state_Arrive::OnMessage(GameMovingEntity* p, Telegram t)
{
return true;
}
|
state_Attack.h
|
C-/C++-Quelltext
|
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
|
#pragma once
#include "state.h"
#include "TSingelton.h"
#include "Telegram.h"
#include "GameMovingEntity.h"
class state_Attack : public state , public TSingelton<state_Attack>
{
void Enter(GameMovingEntity* p);
void Execute(GameMovingEntity* p);
void Exit(GameMovingEntity* p);
bool OnMessage(GameMovingEntity* p, Telegram t);
};
void state_Attack::Enter(GameMovingEntity* p)
{
}
void state_Attack::Execute(GameMovingEntity* p)
{
}
void state_Attack::Exit(GameMovingEntity* p)
{
}
bool state_Attack::OnMessage(GameMovingEntity* p, Telegram t)
{
return true;
}
|
state_Flee.h
|
C-/C++-Quelltext
|
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
|
#pragma once
#include "state.h"
#include "TSingelton.h"
#include "Telegram.h"
#include "GameMovingEntity.h"
#include "SteeringBehaviors.h"
class state_Flee : public state , public TSingelton<state_Flee>
{
void Enter(GameMovingEntity* p);
void Execute(GameMovingEntity* p);
void Exit(GameMovingEntity* p);
bool OnMessage(GameMovingEntity* p, Telegram t);
};
void state_Flee::Enter(GameMovingEntity* p)
{
p->getSteering()->FleeOn();
}
void state_Flee::Execute(GameMovingEntity* p)
{
p->moveEntity(p->getSteering()->Calculate());
}
void state_Flee::Exit(GameMovingEntity* p)
{
p->getSteering()->FleeOff();
}
bool state_Flee::OnMessage(GameMovingEntity* p, Telegram t)
{
return true;
}
|
state_Search.h
|
C-/C++-Quelltext
|
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
|
#pragma once
#include "state.h"
#include "TSingelton.h"
#include "Telegram.h"
#include "GameMovingEntity.h"
#include "SteeringBehaviors.h"
class state_Search : public state , public TSingelton<state_Search>
{
void Enter(GameMovingEntity* p);
void Execute(GameMovingEntity* p);
void Exit(GameMovingEntity* p);
bool OnMessage(GameMovingEntity* p, Telegram t);
};
void state_Search::Enter(GameMovingEntity* p)
{
p->getSteering()->WanderOn();
}
void state_Search::Execute(GameMovingEntity* p)
{
p->moveEntity(p->getSteering()->Calculate());
}
void state_Search::Exit(GameMovingEntity* p)
{
p->getSteering()->WanderOff();
}
bool state_Search::OnMessage(GameMovingEntity* p, Telegram t)
{
return true;
}
|
state_Trace.h
|
C-/C++-Quelltext
|
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
|
#pragma once
#include "state.h"
#include "TSingelton.h"
#include "Telegram.h"
#include "GameMovingEntity.h"
#include "SteeringBehaviors.h"
class state_Trace : public state , public TSingelton<state_Trace>
{
void Enter(GameMovingEntity* p);
void Execute(GameMovingEntity* p);
void Exit(GameMovingEntity* p);
bool OnMessage(GameMovingEntity* p, Telegram t);
};
void state_Trace::Enter(GameMovingEntity* p)
{
p->getSteering()->InterceptOn(reinterpret_cast<GameMovingEntity*>(p->getTargetAgent()));
}
void state_Trace::Execute(GameMovingEntity* p)
{
p->moveEntity(p->getSteering()->Calculate());
}
void state_Trace::Exit(GameMovingEntity* p)
{
p->getSteering()->InterceptOff();
}
bool state_Trace::OnMessage(GameMovingEntity* p, Telegram t)
{
return true;
}
|
state_Carry.h
|
C-/C++-Quelltext
|
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
|
#pragma once
#include "state.h"
#include "TSingelton.h"
#include "Telegram.h"
#include "GameMovingEntity.h"
class state_Carry : public state , public TSingelton<state_Carry>
{
void Enter(GameMovingEntity* p);
void Execute(GameMovingEntity* p);
void Exit(GameMovingEntity* p);
bool OnMessage(GameMovingEntity* p, Telegram t);
};
void state_Carry::Enter(GameMovingEntity* p)
{
}
void state_Carry::Execute(GameMovingEntity* p)
{
}
void state_Carry::Exit(GameMovingEntity* p)
{
}
bool state_Carry::OnMessage(GameMovingEntity* p, Telegram t)
{
return true;
}
|
state_Hide.h
|
C-/C++-Quelltext
|
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
|
#pragma once
#include "state.h"
#include "TSingelton.h"
#include "Telegram.h"
#include "GameMovingEntity.h"
#include "SteeringBehaviors.h"
class state_Hide : public state , public TSingelton<state_Hide>
{
void Enter(GameMovingEntity* p);
void Execute(GameMovingEntity* p);
void Exit(GameMovingEntity* p);
bool OnMessage(GameMovingEntity* p, Telegram t);
};
void state_Hide::Enter(GameMovingEntity* p)
{
p->getSteering()->HideOn();
}
void state_Hide::Execute(GameMovingEntity* p)
{
p->moveEntity(p->getSteering()->Calculate());
}
void state_Hide::Exit(GameMovingEntity* p)
{
p->getSteering()->HideOff();
}
bool state_Hide::OnMessage(GameMovingEntity* p, Telegram t)
{
return false;
}
|
... so ... soviel zu den states ... jetzt kommt die ant ...
Ant.h
|
C-/C++-Quelltext
|
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
|
#pragma once
#include "gamemovingentity.h"
#include "GameBaseEntity.h"
#include "Whiff.h"
#include "scale.h"
#include "MessageDispatcher.h"
#include "stateMachine.h"
#include "world.h"
using namespace scale;
class Ant : public GameMovingEntity
{
private: Whiff* m_nextWayPoint;
private: int m_force;
private: int m_MemberOf;
public: Ant(MessageDispatcher *post,int memberOfStaate,double collisionSize, core::vector3df position,double rotation);
public: ~Ant(void);
public: void Update( float elapsed);
public: bool HandleMessage(Telegram t);
public: int getForce(void);
public: int getStaate(void);
public: bool existWayPoint(void);
public: Whiff* getWayPoint(void);
public: void setWayPoint(Whiff*);
public: void clearWayPoint(void);
public: bool getFoeInPanicDistance(void);
public: bool getFriendsInViewRange(void);
};
|
Ant.cpp
|
C-/C++-Quelltext
|
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
|
#include "_states.h"
#include "Ant.h"
Ant::Ant(MessageDispatcher *post, int memberOfStaate,double collisionSize, core::vector3df position,double rotation):GameMovingEntity(ET_ANT,post,collisionSize,position,rotation, scale::EntityMinViewRange,scale::AntViewRange,scale::EntityMinSpeed,scale::AntMaxSpeed,scale::EntityMinForce,scale::AntMaxForce,scale::AntMinMass,scale::AntMaxMass),m_MemberOf(memberOfStaate)
{
//this->m_sm = new stateMachine(this);
//this->m_sm->setCurrentStat(state_Search<Ant>::Instance());
//this->m_sm->ChangeState(state_Search::Instance());
this->m_nextWayPoint = NULL;
}
Ant::~Ant(void)
{
//delete this->m_sm;
}
void Ant::Update( float elapsed)
{
this->m_elapsedTime = elapsed;
this->m_sm->Update();
}
bool Ant::HandleMessage(Telegram t)
{
return true;
}
int Ant::getForce()
{
return this->m_force;
}
int Ant::getStaate()
{
return this->m_MemberOf;
}
bool Ant::existWayPoint()
{
if(this->m_nextWayPoint)
return true;
return false;
}
Whiff* Ant::getWayPoint()
{
return this->m_nextWayPoint;
}
void Ant::setWayPoint(Whiff *wp)
{
this->m_nextWayPoint = wp;
}
void Ant::clearWayPoint()
{
this->m_nextWayPoint = NULL;
}
bool Ant::getFoeInPanicDistance()
{
return true;
}
bool Ant::getFriendsInViewRange()
{
return true;
}
|
gruß zeus