1 | #include "dxstdafx.h"
|
---|
2 | #include ".\usercontactreport.h"
|
---|
3 | #include "Scene.h"
|
---|
4 | #include "GameScene.h"
|
---|
5 | #include "GameManager.h"
|
---|
6 | #include "Trigger.h"
|
---|
7 | #include "Node.h"
|
---|
8 | #include "Player.h"
|
---|
9 |
|
---|
10 | UserContactReport::UserContactReport(void)
|
---|
11 | {
|
---|
12 | }
|
---|
13 |
|
---|
14 | UserContactReport::~UserContactReport(void)
|
---|
15 | {
|
---|
16 | }
|
---|
17 |
|
---|
18 | void UserContactReport::setScene(Scene* _scene)
|
---|
19 | {
|
---|
20 | this->scene = _scene;
|
---|
21 | }
|
---|
22 |
|
---|
23 | void UserContactReport::onContactNotify(NxContactPair& pair, NxU32 events)
|
---|
24 | {
|
---|
25 | GameScene* gscene;
|
---|
26 | if(events & NX_NOTIFY_ON_START_TOUCH) { // | NX_NOTIFY_ON_TOUCH)) { Vorsicht...pointer bug!
|
---|
27 | Vector normal;
|
---|
28 | normal = Vector(pair.sumNormalForce);
|
---|
29 | normal.normalize();
|
---|
30 | //Bullte vs Terrain
|
---|
31 | if(pair.actors[0]->getGroup()== COLGROUP_BULLET && pair.actors[1]->getGroup()== COLGROUP_TERRAIN) {
|
---|
32 | gscene = ((GameScene*) ((Node*) pair.actors[0]->userData)->myScene);
|
---|
33 | gscene->setTrigger(gscene->TRIGGER_IMPACTTERRAIN, ((Node*) pair.actors[0]->userData), ((Node*) pair.actors[1]->userData), normal, 0);
|
---|
34 | } else if(pair.actors[1]->getGroup()== COLGROUP_BULLET && pair.actors[0]->getGroup()== COLGROUP_TERRAIN) {
|
---|
35 | gscene = ((GameScene*) ((Node*) pair.actors[1]->userData)->myScene);
|
---|
36 | gscene->setTrigger(gscene->TRIGGER_IMPACTTERRAIN, ((Node*) pair.actors[1]->userData), ((Node*) pair.actors[0]->userData), normal, 0);
|
---|
37 | } //Bullet vs Goodie
|
---|
38 | else if(pair.actors[0]->getGroup()== COLGROUP_BULLET && pair.actors[1]->getGroup()== COLGROUP_GOODIE) {
|
---|
39 | gscene = ((GameScene*) ((Node*) pair.actors[0]->userData)->myScene);
|
---|
40 | gscene->setTrigger(gscene->TRIGGER_IMPACTGOODIE, ((Node*) pair.actors[0]->userData), ((Node*) pair.actors[1]->userData), normal, 0);
|
---|
41 | } else if(pair.actors[1]->getGroup()== COLGROUP_BULLET && pair.actors[0]->getGroup()== COLGROUP_GOODIE) {
|
---|
42 | gscene = ((GameScene*) ((Node*) pair.actors[1]->userData)->myScene);
|
---|
43 | gscene->setTrigger(gscene->TRIGGER_IMPACTGOODIE, ((Node*) pair.actors[1]->userData), ((Node*) pair.actors[0]->userData), normal, 0);
|
---|
44 | } //Bullet vs Other
|
---|
45 | else if(pair.actors[0]->getGroup()== COLGROUP_BULLET && pair.actors[1]->getGroup()== COLGROUP_OTHER) {
|
---|
46 | gscene = ((GameScene*) ((Node*) pair.actors[0]->userData)->myScene);
|
---|
47 | gscene->setTrigger(gscene->TRIGGER_IMPACTOTHER, ((Node*) pair.actors[0]->userData), ((Node*) pair.actors[1]->userData), normal, 0);
|
---|
48 | } else if(pair.actors[1]->getGroup()== COLGROUP_BULLET && pair.actors[0]->getGroup()== COLGROUP_OTHER) {
|
---|
49 | gscene = ((GameScene*) ((Node*) pair.actors[1]->userData)->myScene);
|
---|
50 | gscene->setTrigger(gscene->TRIGGER_IMPACTOTHER, ((Node*) pair.actors[1]->userData), ((Node*) pair.actors[0]->userData), normal, 0);
|
---|
51 | } //Bullet vs Player
|
---|
52 | else if(pair.actors[0]->getGroup()== COLGROUP_BULLET && pair.actors[1]->getGroup()== COLGROUP_PLAYER) {
|
---|
53 | gscene = ((GameScene*) ((Node*) pair.actors[0]->userData)->myScene);
|
---|
54 | gscene->setTrigger(gscene->TRIGGER_IMPACTPLAYER, ((Node*) pair.actors[0]->userData), ((Node*) pair.actors[1]->userData), normal, 0);
|
---|
55 | } else if(pair.actors[1]->getGroup()== COLGROUP_BULLET && pair.actors[0]->getGroup()== COLGROUP_PLAYER) {
|
---|
56 | gscene = ((GameScene*) ((Node*) pair.actors[1]->userData)->myScene);
|
---|
57 | gscene->setTrigger(gscene->TRIGGER_IMPACTPLAYER, ((Node*) pair.actors[1]->userData), ((Node*) pair.actors[0]->userData), normal, 0);
|
---|
58 | } //Fire vs Player
|
---|
59 | else if(pair.actors[0]->getGroup()== COLGROUP_FIRE && pair.actors[1]->getGroup()== COLGROUP_PLAYER) {
|
---|
60 | gscene = ((GameScene*) ((Node*) pair.actors[0]->userData)->myScene);
|
---|
61 | gscene->setTrigger(gscene->TRIGGER_IMPACTFIRE, ((Node*) pair.actors[0]->userData), ((Node*) pair.actors[1]->userData), 0);
|
---|
62 | } else if(pair.actors[1]->getGroup()== COLGROUP_FIRE && pair.actors[0]->getGroup()== COLGROUP_PLAYER) {
|
---|
63 | gscene = ((GameScene*) ((Node*) pair.actors[1]->userData)->myScene);
|
---|
64 | gscene->setTrigger(gscene->TRIGGER_IMPACTFIRE, ((Node*) pair.actors[1]->userData), ((Node*) pair.actors[0]->userData), 0);
|
---|
65 | } //Bullet vs Obstacle
|
---|
66 | else if(pair.actors[0]->getGroup()== COLGROUP_BULLET && pair.actors[1]->getGroup()== COLGROUP_OBSTACLE) {
|
---|
67 | gscene = ((GameScene*) ((Node*) pair.actors[0]->userData)->myScene);
|
---|
68 | gscene->setTrigger(gscene->TRIGGER_IMPACTOTHER, ((Node*) pair.actors[0]->userData), ((Node*) pair.actors[1]->userData), normal, 0);
|
---|
69 | } else if(pair.actors[1]->getGroup()== COLGROUP_BULLET && pair.actors[0]->getGroup()== COLGROUP_OBSTACLE) {
|
---|
70 | gscene = ((GameScene*) ((Node*) pair.actors[1]->userData)->myScene);
|
---|
71 | gscene->setTrigger(gscene->TRIGGER_IMPACTOTHER, ((Node*) pair.actors[1]->userData), ((Node*) pair.actors[0]->userData), normal, 0);
|
---|
72 | } //Ice vs Player
|
---|
73 | else if(pair.actors[0]->getGroup()== COLGROUP_ICE && pair.actors[1]->getGroup()== COLGROUP_PLAYER) {
|
---|
74 | gscene = ((GameScene*) ((Node*) pair.actors[0]->userData)->myScene);
|
---|
75 | gscene->setTrigger(gscene->TRIGGER_IMPACTICE, ((Node*) pair.actors[0]->userData), ((Node*) pair.actors[1]->userData), 0);
|
---|
76 | } else if(pair.actors[1]->getGroup()== COLGROUP_ICE && pair.actors[0]->getGroup()== COLGROUP_PLAYER) {
|
---|
77 | gscene = ((GameScene*) ((Node*) pair.actors[1]->userData)->myScene);
|
---|
78 | gscene->setTrigger(gscene->TRIGGER_IMPACTICE, ((Node*) pair.actors[1]->userData), ((Node*) pair.actors[0]->userData), 0);
|
---|
79 | } //Bullet vs Create OnePlayer
|
---|
80 | else if(pair.actors[0]->getGroup()== COLGROUP_ONEPLAYER && pair.actors[1]->getGroup()== COLGROUP_BULLET) {
|
---|
81 | gscene = ((GameScene*) ((Node*) pair.actors[0]->userData)->myScene);
|
---|
82 | gscene->setTrigger(gscene->TRIGGER_CREATEPLAYER, ((Node*) pair.actors[0]->userData), ((Node*) pair.actors[1]->userData), 0);
|
---|
83 | } else if(pair.actors[1]->getGroup()== COLGROUP_ONEPLAYER && pair.actors[0]->getGroup()== COLGROUP_BULLET) {
|
---|
84 | gscene = ((GameScene*) ((Node*) pair.actors[1]->userData)->myScene);
|
---|
85 | gscene->setTrigger(gscene->TRIGGER_CREATEPLAYER, ((Node*) pair.actors[1]->userData), ((Node*) pair.actors[0]->userData), 0);
|
---|
86 | } //Bullet vs Create MorePlayer
|
---|
87 | else if(pair.actors[0]->getGroup()== COLGROUP_MOREPLAYER && pair.actors[1]->getGroup()== COLGROUP_BULLET) {
|
---|
88 | gscene = ((GameScene*) ((Node*) pair.actors[0]->userData)->myScene);
|
---|
89 | gscene->setTrigger(gscene->TRIGGER_CREATEMOREPLAYER, ((Node*) pair.actors[0]->userData), ((Node*) pair.actors[1]->userData), 0);
|
---|
90 | } else if(pair.actors[1]->getGroup()== COLGROUP_MOREPLAYER && pair.actors[0]->getGroup()== COLGROUP_BULLET) {
|
---|
91 | gscene = ((GameScene*) ((Node*) pair.actors[1]->userData)->myScene);
|
---|
92 | gscene->setTrigger(gscene->TRIGGER_CREATEMOREPLAYER, ((Node*) pair.actors[1]->userData), ((Node*) pair.actors[0]->userData), 0);
|
---|
93 | }
|
---|
94 | }
|
---|
95 | }
|
---|
96 |
|
---|