-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.cpp
executable file
·114 lines (99 loc) · 3.03 KB
/
player.cpp
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
/* Drone Hunter
// Copyright (C) 2017 LucKey Productions (luckeyproductions.nl)
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "player.h"
#include "mastercontrol.h"
#include "inputmaster.h"
Player::Player(int playerId, Context* context): Object(context),
playerId_{playerId},
// autoPilot_{playerId_ == 2 && !GetSubsystem<Input>()->GetJoystickByIndex(playerId_-1)},
autoPilot_{false},
// autoPilot_{true},
alive_{true},
score_{0},
flightScore_{0},
multiplier_{1}
{
// Node* guiNode{ MC->scene_->CreateChild("GUI3D") };
// gui3d_ = guiNode->CreateComponent<GUI3D>();
// gui3d_->Initialize(playerId_);
}
void Player::Die()
{
alive_ = false;
}
void Player::Respawn()
{
ResetScore();
multiplier_ = 1;
alive_ = true;
}
void Player::SetScore(int points)
{
score_ = points;
// gui3d_->SetScore(score_);
}
void Player::ResetScore()
{
SetScore(0);
}
void Player::EnterLobby()
{
// for (Pilot* pilot : MC->GetComponentsRecursive<Pilot>()) {
// if (playerId_ == pilot->GetPlayerId()){
// GetSubsystem<InputMaster>()->SetPlayerControl(playerId_, pilot);
// if (!alive_){
// pilot->Revive();
// } else pilot->EnterLobbyFromShip();
// }
// }
// gui3d_->EnterLobby();
}
void Player::EnterPlay()
{
// gui3d_->EnterPlay();
}
void Player::AddScore(int points)
{
if (!alive_) return;
// points *= static_cast<int>(pow(2.0, static_cast<double>(multiplier_-1)));
// SetScore(GetScore()+points);
// //Check for multiplier increase
// for (int i{0}; i < 10; ++i){
// unsigned tenPow{static_cast<unsigned>(pow(10, i))};
// if (flightScore_ < tenPow && (flightScore_ + points) > tenPow){
// ++multiplier_;
// GetSubsystem<InputMaster>()->GetControllableByPlayer(playerId_)->
// PlaySample(MC->GetSample("MultiX"), 0.42f);
// MC->arena_->FlashX(playerId_);
// break;
// }
// }
// flightScore_ += points;
// toCount_ += points;
}
Vector3 Player::GetPosition()
{
return GetSubsystem<InputMaster>()->GetControllableByPlayer(playerId_)->GetNode()->GetPosition();
}
Controllable* Player::GetControllable()
{
Controllable* controllable{ GetSubsystem<InputMaster>()->GetControllableByPlayer(playerId_) };
if (controllable)
return controllable;
else return nullptr;
}