removed commented code

This commit is contained in:
devZoGok
2022-01-13 20:21:42 +02:00
parent 74537a5ee9
commit 12d66acc9a
25 changed files with 2 additions and 680 deletions
-214
View File
@@ -32,92 +32,6 @@ namespace battleship{
const int size = 50; const int size = 50;
ActiveGameState::UnitButton::UnitButton(ActiveGameState *activeState, Vector2 pos, Vector2 size, std::string name, int faction, int unitId) : vb01Gui::Button(pos, size, name, PATH + "Fonts/batang.ttf", -1, true){
this->activeState=activeState;
this->faction=faction;
this->unitId=unitId;
}
void ActiveGameState::UnitButton::onClick(){
Player *player=activeState->getPlayer();
Vector3 spawnPoint=player->getSpawnPoint();
Unit *u;
switch(unitData::unitType[unitId]){
case unitData::UNIT_TYPE::VESSEL:
u=new Vessel(player,spawnPoint,unitId);
break;
case unitData::UNIT_TYPE::DESTROYER:
u=new Destroyer(player,spawnPoint,unitId);
break;
case unitData::UNIT_TYPE::CRUISER:
u=new Cruiser(player,spawnPoint,unitId);
break;
case unitData::UNIT_TYPE::AIRCRAFT_CARRIER:
u=new AircraftCarrier(player,spawnPoint,unitId);
break;
case unitData::UNIT_TYPE::SUBMARINE:
u=new Submarine(player,spawnPoint,unitId);
break;
}
player->addUnit(u);
}
void ActiveGameState::UnitButton::onMouseOver(){
/*
if(!mouseOverDone){
GameManager *gm = GameManager::getSingleton();
GuiAppState *guiState=((GuiAppState*)GameManager::getSingleton()->getStateManager()->getAppState(AppStateTypes::GUI_STATE));
guiState->addTooltip(new gui::Tooltip(pos-Vector2(100,0),name));
}
*/
}
void ActiveGameState::UnitButton::onMouseAway(){
/*
if(!mouseAwayDone){
GuiAppState *guiState=((GuiAppState*)GameManager::getSingleton()->getStateManager()->getAppState(AppStateTypes::GUI_STATE));
guiState->removeAllTooltips();
}
*/
}
ActiveGameState::UnitActionButton::UnitActionButton(unitData::UNIT_TYPE type, Vector2 pos, Vector2 size, string name, string path) : vb01Gui::Button(pos, size, name, "", -1, true){
this->type=type;
GameManager *gm = GameManager::getSingleton();
activeState=((ActiveGameState*)gm->getStateManager()->getAppStateByType(AppStateType::ACTIVE_STATE));
/*
IVideoDriver *driver = gm->getDevice()->getVideoDriver();
setImageButton(new Image(driver->getTexture(path),pos,vector2di(50,50)));
*/
}
void ActiveGameState::UnitActionButton::onClick(){
std::vector<Unit*> &selectedUnits=activeState->getSelectedUnits();
for(Unit *u : selectedUnits)
if(u->getType()==type)
units.push_back(u);
}
void ActiveGameState::UnitActionButton::onMouseOver(){
/*
if(!mouseOverDone){
GuiAppState *guiState=((GuiAppState*)GameManager::getSingleton()->getStateManager()->getAppState(AppStateTypes::GUI_STATE));
guiState->addTooltip(new gui::Tooltip(pos-Vector2(100,0),name));
}
*/
}
void ActiveGameState::UnitActionButton::onMouseAway(){
/*
if(!mouseAwayDone){
GuiAppState *guiState=((GuiAppState*)GameManager::getSingleton()->getStateManager()->getAppState(AppStateTypes::GUI_STATE));
guiState->removeAllTooltips();
}
*/
}
ActiveGameState::ActiveGameState(GuiAppState *guiState, Map *map, vector<Player*> players, int playerId) { ActiveGameState::ActiveGameState(GuiAppState *guiState, Map *map, vector<Player*> players, int playerId) {
type = AppStateType::ACTIVE_STATE; type = AppStateType::ACTIVE_STATE;
this->guiState = guiState; this->guiState = guiState;
@@ -156,22 +70,6 @@ namespace battleship{
int faction = mainPlayer->getFaction(), width = gm->getWidth(), height = gm->getHeight(), size = 50; int faction = mainPlayer->getFaction(), width = gm->getWidth(), height = gm->getHeight(), size = 50;
string names[5] = {"Battleship", "Destroyer", "Cruiser", "Carrier", "Submarine"}; string names[5] = {"Battleship", "Destroyer", "Cruiser", "Carrier", "Submarine"};
/*
for(int i = 0; i < 5; i++){
int id = 2 * i + (i == 4 && faction == 1 ? 0 : faction);
Vector2 pos = Vector2(width - size - 1, 1 + i * size), sizeVec = Vector2(size, size);
UnitButton *button = new UnitButton(this, pos, sizeVec, names[i], faction, id);
if(i == 3)
names[i] = "aircraftCarrier";
else
transform(names[i].begin(), names[i].end(), names[i], names[i]);
//button->setImageButton(new Image(driver->getTexture(PATH+"Textures/Icons/"+names[i]+"0"+stringw(faction)+".png"),pos,sizeVec));
guiState->addButton(button);
}
*/
Bind binds[]{Bind::LOOK_UP, Bind::LOOK_DOWN, Bind::LOOK_LEFT, Bind::LOOK_RIGHT}; Bind binds[]{Bind::LOOK_UP, Bind::LOOK_DOWN, Bind::LOOK_LEFT, Bind::LOOK_RIGHT};
int triggers[]{Mapping::MOUSE_AXIS_UP, Mapping::MOUSE_AXIS_DOWN, Mapping::MOUSE_AXIS_LEFT, Mapping::MOUSE_AXIS_RIGHT}; int triggers[]{Mapping::MOUSE_AXIS_UP, Mapping::MOUSE_AXIS_DOWN, Mapping::MOUSE_AXIS_LEFT, Mapping::MOUSE_AXIS_RIGHT};
int numData = sizeof(triggers) / sizeof(int); int numData = sizeof(triggers) / sizeof(int);
@@ -198,8 +96,6 @@ namespace battleship{
dragboxNode->setVisible(isSelectionBox); dragboxNode->setVisible(isSelectionBox);
renderUnits(); renderUnits();
renderGUIBorders();
renderActionButtons();
if(!lookingAround) if(!lookingAround)
updateCameraPosition(); updateCameraPosition();
@@ -238,7 +134,6 @@ namespace battleship{
} }
} }
//rendUn->getLight()->setVisible(true);
u->getNode()->setVisible(true); u->getNode()->setVisible(true);
} }
else{ else{
@@ -252,104 +147,6 @@ namespace battleship{
u->getNode()->setVisible(dist <= units[i]->getLineOfSight() || isInLineOfSight(compUnPos, units[i]->getLineOfSight(), u) ? true : false); u->getNode()->setVisible(dist <= units[i]->getLineOfSight() || isInLineOfSight(compUnPos, units[i]->getLineOfSight(), u) ? true : false);
} }
} }
if (u->isDebuggable())
u->debug();
}
}
void ActiveGameState::renderGUIBorders(){
/*
GameManager *gm = GameManager::getSingleton();
IVideoDriver *driver = gm->getDevice()->getVideoDriver();
int width = gm->getWidth(), height = gm->getHeight(), size = 50;
for(int i=0;i<height/size;i++){
driver->draw2DRectangleOutline(recti(vector2di(width-(2*size+3),size*i),dimension2di(size+2,size+2)));
driver->draw2DRectangleOutline(recti(vector2di(width-(size+2),size*i),dimension2di(size+2,size+2)));
}
*/
}
void ActiveGameState::renderActionButtons(){
class MakeJetButton : public UnitActionButton{
public:
MakeJetButton(int faction, unitData::UNIT_TYPE type, Vector2 pos, Vector2 size):UnitActionButton(type, pos, size, "Jet", PATH + "Textures/Icons/jet0" + to_string(faction) + ".png"){
}
~MakeJetButton(){}
void onClick(){
UnitActionButton::onClick();
for(int i=0;i<units.size();i++)
((AircraftCarrier*)units[i])->makeJet();
}
private:
};
class LaunchButton : public UnitActionButton{
public:
LaunchButton(int faction, unitData::UNIT_TYPE type, Vector2 pos, Vector2 size) : UnitActionButton(type, pos, size, "Launch", PATH + "Textures/Icons/guidedMissile0" + to_string(faction) + ".png"){}
~LaunchButton(){}
void onClick(){
UnitActionButton::onClick();
activeState->setSelectingLaunchPoint(true);
}
private:
};
class MissileButton : public UnitActionButton{
public:
MissileButton(bool aam, Vector2 pos, Vector2 size, string name, string path) : UnitActionButton(unitData::UNIT_TYPE::MISSILE_JET,pos,size,name,path){
this->aam=aam;
}
~MissileButton(){}
void onClick(){
UnitActionButton::onClick();
for(int i=0;i<units.size();i++)
((MissileJet*)units[i])->installMissiles(aam);
}
private:
bool aam;
};
GameManager *gm = GameManager::getSingleton();
int width = gm->getWidth(), height = gm->getHeight(), slotSize = size + 2, faction = mainPlayer->getFaction();
bool carriers=false, cruisers=false, missileJets=false;
for(int i=0;i<selectedUnits.size()&&!(carriers&&cruisers&&missileJets);i++){
if(selectedUnits[i]->getType()==unitData::UNIT_TYPE::AIRCRAFT_CARRIER)
carriers=true;
else if(selectedUnits[i]->getType()==unitData::UNIT_TYPE::CRUISER)
cruisers=true;
else if(selectedUnits[i]->getType()==unitData::UNIT_TYPE::MISSILE_JET)
missileJets=true;
}
if(carriers&&!actionButtons[0]){
actionButtons[0] = new MakeJetButton(faction, unitData::UNIT_TYPE::AIRCRAFT_CARRIER, Vector2(width - 2 * slotSize, 0), Vector2(size, size));
guiState->addButton(actionButtons[0]);
}
else if(!carriers&&actionButtons[0]){
guiState->removeButton(actionButtons[0]);
actionButtons[0]=nullptr;
}
if(cruisers&&!actionButtons[1]){
actionButtons[1] = new LaunchButton(faction, unitData::UNIT_TYPE::CRUISER, Vector2(width - 2 * slotSize, slotSize), Vector2(size, size));
guiState->addButton(actionButtons[1]);
}
else if(!cruisers&&actionButtons[1]){
guiState->removeButton(actionButtons[1]);
actionButtons[1]=nullptr;
}
if(missileJets&&!actionButtons[2]){
actionButtons[2]=new MissileButton(true, Vector2(width - 2 * slotSize, slotSize * 3), Vector2(size, size), "AAM", PATH + "Textures/Icons/aam.png");
actionButtons[3]=new MissileButton(false, Vector2(width - 2 * slotSize, slotSize * 4), Vector2(size, size), "AWM", PATH + "Textures/Icons/awm.png");
guiState->addButton(actionButtons[2]);
guiState->addButton(actionButtons[3]);
}
else if(!missileJets&&actionButtons[2]){
guiState->removeButton(actionButtons[2]);
guiState->removeButton(actionButtons[3]);
actionButtons[2]=nullptr;
actionButtons[3]=nullptr;
} }
} }
@@ -477,14 +274,6 @@ namespace battleship{
Ray::retrieveCollisions(camPos, rayDir, map->getWaterNode(), results); Ray::retrieveCollisions(camPos, rayDir, map->getWaterNode(), results);
std::map<Node*, Unit*> unitData; std::map<Node*, Unit*> unitData;
/*
for (Player *p : players)
for (Unit *u : p->getUnits()){
Ray::retrieveCollisions(camPos, rayDir, u->getNode(), results);
unitData.emplace(u->getNode(), u);
}
*/
Ray::sortResults(results); Ray::sortResults(results);
if(!results.empty()){ if(!results.empty()){
@@ -579,9 +368,6 @@ namespace battleship{
break; break;
case Bind::INSTALL_AAM: case Bind::INSTALL_AAM:
case Bind::INSTALL_AWM: case Bind::INSTALL_AWM:
for(Unit *u : selectedUnits)
if(u->getType() == unitData::UNIT_TYPE::MISSILE_JET)
((MissileJet*)u)->installMissiles(bind == Bind::INSTALL_AAM);
break; break;
case Bind::GROUP_0: case Bind::GROUP_0:
case Bind::GROUP_1: case Bind::GROUP_1:
-28
View File
@@ -25,34 +25,7 @@ namespace battleship{
inline std::vector<Unit*>& getSelectedUnits(){return selectedUnits;} inline std::vector<Unit*>& getSelectedUnits(){return selectedUnits;}
inline std::vector<Unit*>& getUnitGroup(int i){return unitGroups[i];} inline std::vector<Unit*>& getUnitGroup(int i){return unitGroups[i];}
private: private:
class UnitButton : public vb01Gui::Button{
public:
UnitButton(ActiveGameState*, vb01::Vector2, vb01::Vector2, std::string, int, int);
~UnitButton(){}
virtual void onClick();
virtual void onMouseOver();
virtual void onMouseAway();
private:
ActiveGameState *activeState;
int faction, unitId;
};
class UnitActionButton : public vb01Gui::Button{
public:
UnitActionButton(unitData::UNIT_TYPE, vb01::Vector2, vb01::Vector2, std::string, std::string);
~UnitActionButton(){}
virtual void onClick();
virtual void onMouseOver();
virtual void onMouseAway();
protected:
unitData::UNIT_TYPE type;
std::vector<Unit*> units;
ActiveGameState *activeState;
};
void deselectUnits(); void deselectUnits();
void renderGUIBorders();
void renderActionButtons();
void renderUnits(); void renderUnits();
void updateCameraPosition(); void updateCameraPosition();
void updateSelectionBox(); void updateSelectionBox();
@@ -72,7 +45,6 @@ namespace battleship{
std::vector<vb01::Node*> unitLightNodes; std::vector<vb01::Node*> unitLightNodes;
std::vector<Unit*> unitGroups[9], selectedUnits; std::vector<Unit*> unitGroups[9], selectedUnits;
std::vector<Order::Target> targets; std::vector<Order::Target> targets;
UnitActionButton *actionButtons[4]{nullptr, nullptr, nullptr, nullptr};
bool isSelectionBox = false, shiftPressed = false, controlPressed = false, selectingPatrolPoints = false, selectingGuidedMissileTarget = false,lookingAround=false; bool isSelectionBox = false, shiftPressed = false, controlPressed = false, selectingPatrolPoints = false, selectingGuidedMissileTarget = false,lookingAround=false;
bool isInLineOfSight(vb01::Vector3, float, Unit*); bool isInLineOfSight(vb01::Vector3, float, Unit*);
int playerId, zooms = 0; int playerId, zooms = 0;
-39
View File
@@ -31,8 +31,6 @@ namespace battleship{
validateAddUnitArguments(fullCommand); validateAddUnitArguments(fullCommand);
executeAddUnit(atoi(fullCommand[1].c_str()), atoi(fullCommand[2].c_str())); executeAddUnit(atoi(fullCommand[1].c_str()), atoi(fullCommand[2].c_str()));
} }
else
printConsoleMessage("No such command");
} }
void ConsoleCommand::parse(string commandStr, vector<string> &fullCommand){ void ConsoleCommand::parse(string commandStr, vector<string> &fullCommand){
@@ -101,42 +99,5 @@ namespace battleship{
} }
players[playerId]->addUnit(u); players[playerId]->addUnit(u);
}
/*
void ConsoleCommand::debugUnits() {
if (arguments.size() == 0)
for (Player *pl : players){
vector<Unit*> &units=pl->getUnits();
for (Unit *u : units){
u->toggleDebugging(true);
vector<Projectile*> projectiles=u->getProjectiles();
for(Projectile *pr : projectiles)
pr->debug();
}
}
else
printConsoleMessage("Too many arguments");
}
*/
void ConsoleCommand::printConsoleMessage(string message) {
/*
int messageId = 0;
bool foundEmptySlot = false;
for (int i = 0; i < listbox->getContents().size() && !foundEmptySlot; i++)
if (listbox->getContents()[i] == L"") {
messageId = i;
foundEmptySlot = true;
}
if (foundEmptySlot)
listbox->changeLine(messageId, message);
else
listbox->addLine(message);
*/
} }
} }
-3
View File
@@ -19,9 +19,6 @@ namespace battleship{
static void executeAddUnit(int, int); static void executeAddUnit(int, int);
static void validateDebugUnitsArguments(); static void validateDebugUnitsArguments();
static void debugUnits();
static void printConsoleMessage(std::string);
}; };
} }
-20
View File
@@ -29,25 +29,5 @@ namespace battleship{
void DemoJet::update(){ void DemoJet::update(){
Jet::update(); Jet::update();
if(!onBoard&&!orders.empty()&&orders[0].type==Order::TYPE::ATTACK){
GameManager *gm = GameManager::getSingleton();
/*
ISceneManager *smgr = gm->getDevice()->getSceneManager();
ISceneNode *collNode = castRay(smgr,pos,pos+dirVec*length);
if(collNode && collNode != node){
InGameAppState *inGameState = ((InGameAppState*)gm->getStateManager()->getAppState(AppStateTypes::IN_GAME_STATE));
for(Player *p : inGameState->getPlayers())
for(Unit *u : p->getUnits())
if(u->getNode() == collNode)
u->takeDamage(damage);
blowUp();
}
else if(pos.y<0)
blowUp();
*/
}
} }
} }
-7
View File
@@ -39,13 +39,6 @@ namespace battleship{
Vector3 p1 = u->getCorner(1); Vector3 p1 = u->getCorner(1);
Vector3 p3 = u->getCorner(3); Vector3 p3 = u->getCorner(3);
Vector3 p4 = u->getCorner(4); Vector3 p4 = u->getCorner(4);
/*
if(isWithinCuboid(p0,p1,p3,p4,pos)){
detonated=true;
collNode=u->getNode();
}
*/
} }
if(detonated) if(detonated)
-11
View File
@@ -228,7 +228,6 @@ namespace battleship{
} }
void GuiAppState::onRawMousePress(int trigger){ void GuiAppState::onRawMousePress(int trigger){
//updateControlsListbox(trigger);
} }
Textbox* GuiAppState::getOpenTextbox() { Textbox* GuiAppState::getOpenTextbox() {
@@ -278,10 +277,6 @@ namespace battleship{
void GuiAppState::removeButton(Button *b) { void GuiAppState::removeButton(Button *b) {
for (int i = 0; i < buttons.size(); i++) { for (int i = 0; i < buttons.size(); i++) {
if (b == buttons[i]) { if (b == buttons[i]) {
/*
if (b->isImageButton())
GameManager::getSingleton()->detachImage(b->getImage());
*/
delete b; delete b;
buttons.erase(buttons.begin() + i); buttons.erase(buttons.begin() + i);
} }
@@ -291,13 +286,7 @@ namespace battleship{
void GuiAppState::removeButton(string name) { void GuiAppState::removeButton(string name) {
for (int i = 0; i < buttons.size(); i++) { for (int i = 0; i < buttons.size(); i++) {
if (name == buttons[i]->getName() && buttons[i]->isSeparate()) { if (name == buttons[i]->getName() && buttons[i]->isSeparate()) {
/*
if (buttons[i]->isImageButton())
GameManager::getSingleton()->detachImage(buttons[i]->getImage());
*/
delete buttons[i]; delete buttons[i];
buttons.erase(buttons.begin() + i); buttons.erase(buttons.begin() + i);
} }
} }
+1 -43
View File
@@ -129,9 +129,7 @@ namespace battleship{
} }
InGameAppState::UnitCreationButton::UnitCreationButton(string icon, Vector2 pos, Vector2 size, string name, bool separate) : Button(pos, size, name, PATH + "Fonts/batang.ttf", -1, separate) { InGameAppState::UnitCreationButton::UnitCreationButton(string icon, Vector2 pos, Vector2 size, string name, bool separate) : Button(pos, size, name, PATH + "Fonts/batang.ttf", -1, separate) {}
//setImageButton(new Image(icon, pos, size));
}
void InGameAppState::UnitCreationButton::onClick() { void InGameAppState::UnitCreationButton::onClick() {
} }
@@ -229,14 +227,6 @@ namespace battleship{
if (map) if (map)
map->update(); map->update();
if (isMainMenuActive) {
GameManager *gm = GameManager::getSingleton();
/*
IVideoDriver *driver = gm->getDevice()->getVideoDriver();
driver->draw2DRectangle(SColor(100, 0, 0, 0), rect<s32>(0, 0, gm->getWidth(), gm->getHeight()));
*/
}
for (Player *p : players) for (Player *p : players)
if (p) { if (p) {
p->update(); p->update();
@@ -312,26 +302,6 @@ namespace battleship{
projectiles.erase(projectiles.begin()+i); projectiles.erase(projectiles.begin()+i);
} }
} }
for(int i=0;i<fx.size();i++){
if(getTime()-fx[i].initTime>fx[i].time){
/*
IParticleSystemSceneNode *node=fx[i].node;
if(node){
node->removeAllAffectors();
node->setVisible(false);
}
if(fx[i].sfx){
delete fx[i].sfx->getBuffer();
delete fx[i].sfx;
}
fx.erase(fx.begin()+i);
*/
}
}
} }
void InGameAppState::attachGui() { void InGameAppState::attachGui() {
@@ -340,14 +310,6 @@ namespace battleship{
if (mainPlayer->getFaction() == 1) if (mainPlayer->getFaction() == 1)
idOffset += 7; idOffset += 7;
/*
IVideoDriver *driver = GameManager::getSingleton()->getDevice()->getVideoDriver();
bcb = new BattleshipCreationButton(gameManager, driver->getTexture(iconPath[idOffset]), vector2d<s32>(gameManager->getWidth() - 100, gameManager->getHeight() - 540), vector2d<s32>(100, 100), "battleships", true);
dcb = new DestroyerCreationButton(gameManager, driver->getTexture(iconPath[idOffset + 1]), vector2d<s32>(gameManager->getWidth() - 100, gameManager->getHeight() - 430), vector2d<s32>(100, 100), "destroyers", true);
crcb = new CruiserCreationButton(gameManager, driver->getTexture(iconPath[idOffset + 2]), vector2d<s32>(gameManager->getWidth() - 100, gameManager->getHeight() - 320), vector2d<s32>(100, 100), "cruisers", true);
ccb = new CarrierCreationButton(gameManager, driver->getTexture(iconPath[idOffset + 3]), vector2d<s32>(gameManager->getWidth() - 100, gameManager->getHeight() - 210), vector2d<s32>(100, 100), "carriers", true);
scb = new SubmarineCreationButton(gameManager, driver->getTexture(iconPath[idOffset + 4]), vector2d<s32>(gameManager->getWidth() - 100, gameManager->getHeight() - 100), vector2d<s32>(100, 100), "submarines", true);
*/
guiState->addButton(bcb); guiState->addButton(bcb);
guiState->addButton(dcb); guiState->addButton(dcb);
guiState->addButton(crcb); guiState->addButton(crcb);
@@ -370,7 +332,6 @@ namespace battleship{
isMainMenuActive = true; isMainMenuActive = true;
gm->getStateManager()->dettachAppState(activeState); gm->getStateManager()->dettachAppState(activeState);
//detachGui();
Vector2 pos = Vector2(100, 100); Vector2 pos = Vector2(100, 100);
resumeButton = new ResumeButton(guiState, this, Vector2(pos.x, pos.y), Vector2(150, 50), "Resume", true); resumeButton = new ResumeButton(guiState, this, Vector2(pos.x, pos.y), Vector2(150, 50), "Resume", true);
consoleButton = new ConsoleButton(guiState, this, Vector2(pos.x, pos.y + 60), Vector2(150, 50), "Console", true); consoleButton = new ConsoleButton(guiState, this, Vector2(pos.x, pos.y + 60), Vector2(150, 50), "Console", true);
@@ -382,13 +343,11 @@ namespace battleship{
guiState->addButton(optionsButton); guiState->addButton(optionsButton);
guiState->addButton(mainMenuButton); guiState->addButton(mainMenuButton);
guiState->addButton(exitButton); guiState->addButton(exitButton);
//gameManager->getDevice()->getSceneManager()->getActiveCamera()->setVisible(false);
} }
else { else {
isMainMenuActive = false; isMainMenuActive = false;
gm->getStateManager()->attachAppState(activeState); gm->getStateManager()->attachAppState(activeState);
//attachGui();
guiState->removeAllCheckboxes(); guiState->removeAllCheckboxes();
guiState->removeAllListboxes(); guiState->removeAllListboxes();
guiState->removeAllSliders(); guiState->removeAllSliders();
@@ -399,7 +358,6 @@ namespace battleship{
guiState->removeButton("Options"); guiState->removeButton("Options");
guiState->removeButton("Exit"); guiState->removeButton("Exit");
guiState->removeButton("Resume"); guiState->removeButton("Resume");
//gameManager->getDevice()->getSceneManager()->getActiveCamera()->setVisible(true);
} }
} }
-1
View File
@@ -15,7 +15,6 @@
namespace battleship{ namespace battleship{
struct Fx { struct Fx {
s64 initTime, time; s64 initTime, time;
//irr::scene::IParticleSystemSceneNode *node=nullptr;
sf::Sound *sfx = nullptr; sf::Sound *sfx = nullptr;
}; };
-4
View File
@@ -141,9 +141,5 @@ namespace battleship{
dirVec = rotQuat * dirVec, upVec = rotQuat * upVec; dirVec = rotQuat * dirVec, upVec = rotQuat * upVec;
horAngle = angle; horAngle = angle;
float yAngle = model->getOrientation().y; float yAngle = model->getOrientation().y;
/*
node->setOrientation(vector3df(angle, 0, 0));
node->setOrientation(vector3df(angle, yAngle, 0));
*/
} }
} }
-1
View File
@@ -14,7 +14,6 @@ namespace battleship{
class Jet : public Unit { class Jet : public Unit {
public: public:
Jet(Player*, vb01::Vector3, int, bool); Jet(Player*, vb01::Vector3, int, bool);
//virtual void attack(Order);
virtual void update(); virtual void update();
inline void setJetId(int i){this->jetId = i;} inline void setJetId(int i){this->jetId = i;}
inline void setAircraftCarrier(AircraftCarrier *a){aircraftCarrier = a;} inline void setAircraftCarrier(AircraftCarrier *a){aircraftCarrier = a;}
-28
View File
@@ -53,32 +53,4 @@ namespace battleship{
missiles--; missiles--;
lastFireTime=getTime(); lastFireTime=getTime();
} }
void MissileJet::installMissiles(bool aam){
/*
if(!missilesInstalled){
missiles=2;
GameManager *gm = GameManager::getSingleton();
ISceneManager *smgr = gm->getDevice()->getSceneManager();
IVideoDriver *driver = gm->getDevice()->getVideoDriver();
for(int i=0;i<missiles;i++){
IAnimatedMesh *missileMesh=smgr->getMesh(projectileData::meshPath[id][i]);
missileNodes[i]=smgr->addAnimatedMeshSceneNode(missileMesh);
ITexture *diffuseTexture = driver->getTexture(projectileData::diffuseMapTextPath[id][i]);
if (!diffuseTexture)
diffuseTexture = driver->getTexture(DEFAULT_TEXTURE);
missileNodes[i]->setMaterialTexture(0, diffuseTexture);
missileNodes[i]->setMaterialFlag(EMF_LIGHTING, false);
missileNodes[i]->setPosition(projectileData::pos[id][aam][i]);
missileNodes[i]->setParent(node);
}
type=(MissileType)aam;
missilesInstalled=true;
}
*/
}
} }
-25
View File
@@ -29,10 +29,6 @@ namespace battleship{
} }
void OptionsButton::BackButton::onClick() { void OptionsButton::BackButton::onClick() {
GameManager *gm = GameManager::getSingleton(); GameManager *gm = GameManager::getSingleton();
/*
gm->detachAllBitmapTexts();
gm->detachAllImages();
*/
state->removeAllListboxes(); state->removeAllListboxes();
state->removeAllCheckboxes(); state->removeAllCheckboxes();
state->removeAllSliders(); state->removeAllSliders();
@@ -52,7 +48,6 @@ namespace battleship{
OkButton *okButton = new OkButton(); OkButton *okButton = new OkButton();
DefaultsButton *defaultsButton = new DefaultsButton(); DefaultsButton *defaultsButton = new DefaultsButton();
BackButton *returnButton = new BackButton(); BackButton *returnButton = new BackButton();
//defaultsButton->moveText(-25, 0);
state->addButton(okButton); state->addButton(okButton);
state->addButton(defaultsButton); state->addButton(defaultsButton);
state->addButton(returnButton); state->addButton(returnButton);
@@ -97,11 +92,6 @@ namespace battleship{
Textbox *mouseSensitivityTextbox = new Textbox(Vector2(pos.x + 320, pos.y - 10), Vector2(100, 20), font); Textbox *mouseSensitivityTextbox = new Textbox(Vector2(pos.x + 320, pos.y - 10), Vector2(100, 20), font);
Checkbox *reverseMouseCheckbox = new Checkbox(Vector2(pos.x, pos.y + 50), font); Checkbox *reverseMouseCheckbox = new Checkbox(Vector2(pos.x, pos.y + 50), font);
/*
gm->attachBitmapText(new BitmapText("MouseSensitivity", vector2d<s32>(gm->getWidth() / 3 - 90, gm->getHeight() / 4 - 5), font));
gm->attachBitmapText(new BitmapText("ReverseMouse", vector2d<s32>(gm->getWidth() / 3 + 20, gm->getHeight() / 4 + 50), font));
*/
state->addTextbox(mouseSensitivityTextbox); state->addTextbox(mouseSensitivityTextbox);
state->addSlider(mouseSensitivitySlider); state->addSlider(mouseSensitivitySlider);
state->addCheckbox(reverseMouseCheckbox); state->addCheckbox(reverseMouseCheckbox);
@@ -134,14 +124,6 @@ namespace battleship{
Checkbox *parallaxMapCheckbox = new Checkbox(Vector2(pos.x, pos.y + 90), font); Checkbox *parallaxMapCheckbox = new Checkbox(Vector2(pos.x, pos.y + 90), font);
Checkbox *specularMapCheckbox = new Checkbox(Vector2(pos.x, pos.y + 110), font); Checkbox *specularMapCheckbox = new Checkbox(Vector2(pos.x, pos.y + 110), font);
/*
gm->attachBitmapText(new BitmapText("Fullscreen", vector2d<s32>(pos.X + 20, pos.Y + 30), font));
gm->attachBitmapText(new BitmapText("VSync", vector2d<s32>(pos.X + 20, pos.Y + 50), font));
gm->attachBitmapText(new BitmapText("Normal map", vector2d<s32>(pos.X + 20, pos.Y + 70), font));
gm->attachBitmapText(new BitmapText("Parallax map", vector2d<s32>(pos.X + 20, pos.Y + 90), font));
gm->attachBitmapText(new BitmapText("Specular map", vector2d<s32>(pos.X + 20, pos.Y + 110), font));
*/
state->addListbox(resolutionsListbox); state->addListbox(resolutionsListbox);
state->addCheckbox(fullscreenCheckbox); state->addCheckbox(fullscreenCheckbox);
state->addCheckbox(vsyncCheckbox); state->addCheckbox(vsyncCheckbox);
@@ -184,12 +166,6 @@ namespace battleship{
Textbox *udpTextbox = new Textbox(Vector2(pos.x, pos.y + 30), Vector2(100, 20), font); Textbox *udpTextbox = new Textbox(Vector2(pos.x, pos.y + 30), Vector2(100, 20), font);
Textbox *playerNameTextbox = new Textbox(Vector2(pos.x, pos.y + 60), Vector2(100, 20), font); Textbox *playerNameTextbox = new Textbox(Vector2(pos.x, pos.y + 60), Vector2(100, 20), font);
/*
gm->attachBitmapText(new BitmapText("TCP port", vector2d<s32>(pos.X - 50, pos.Y), font));
gm->attachBitmapText(new BitmapText("UDP port", vector2d<s32>(pos.X - 50, pos.Y + 30), font));
gm->attachBitmapText(new BitmapText("Player name", vector2d<s32>(pos.X - 65, pos.Y + 60), font));
*/
state->addTextbox(tcpTextbox); state->addTextbox(tcpTextbox);
state->addTextbox(udpTextbox); state->addTextbox(udpTextbox);
state->addTextbox(playerNameTextbox); state->addTextbox(playerNameTextbox);
@@ -209,7 +185,6 @@ namespace battleship{
VideoTab *videoTab = new VideoTab(); VideoTab *videoTab = new VideoTab();
AudioTab *audioTab = new AudioTab(); AudioTab *audioTab = new AudioTab();
MultiplayerTab *mupltiplayerTab = new MultiplayerTab(); MultiplayerTab *mupltiplayerTab = new MultiplayerTab();
//mupltiplayerTab->moveText(-20, 0);
state->addButton(controlsTab); state->addButton(controlsTab);
state->addButton(mouseTab); state->addButton(mouseTab);
state->addButton(videoTab); state->addButton(videoTab);
-49
View File
@@ -66,55 +66,6 @@ namespace battleship {
void onClick(); void onClick();
}; };
virtual void onClick(); virtual void onClick();
/*
class ReturnButton :public Button {
public:
ReturnButton(GuiAppState *state, GameManager *gM, vector2d<s32> pos, vector2d<s32> size, stringw name, bool separate) :Button(gM, pos, size, name, separate) {
this->state = state;
}
void onClick() {
state->removeAllListboxes();
state->removeAllCheckboxes();
state->removeAllTextboxes();
state->removeAllSliders();
IVideoDriver *driver = gameManager->getDevice()->getVideoDriver();
SpButton *spButton = new SpButton(state, gameManager, vector2d<s32>(driver->getScreenSize().Width / 16, driver->getScreenSize().Height / 12), vector2d<s32>(150, 40), "Singleplayer", true);
OptionsButton *optionsButton = new OptionsButton(state, gameManager, vector2d<s32>(driver->getScreenSize().Width / 16, driver->getScreenSize().Height / 12 * 2), vector2d<s32>(150, 40), "Options", true);
ExitButton *exitButton = new ExitButton(gameManager, vector2d<s32>(driver->getScreenSize().Width / 16, driver->getScreenSize().Height / 12 * 3), vector2d<s32>(150, 40), "Exit", true);
state->addButton(spButton);
state->addButton(optionsButton);
state->addButton(exitButton);
state->removeButton("Controls");
state->removeButton("Mouse");
state->removeButton("Video");
state->removeButton("Audio");
state->removeButton("Multiplayer");
state->removeAllListboxes();
state->removeAllCheckboxes();
state->removeAllSliders();
state->removeAllTextboxes();
state->removeButton("Back");
}
private:
GuiAppState *state;
};
*/
/*ControlsTab *controlsTab = new ControlsTab(state, this->gameManager, vector2d<s32>(gameManager->getWidth() / 4, gameManager->getHeight() / 10), vector2d<s32>(100, 50), "Controls", true);
MouseTab *mouseTab = new MouseTab(state, this->gameManager, vector2d<s32>(gameManager->getWidth() / 4, gameManager->getHeight() / 10 + 60), vector2d<s32>(100, 50), "Mouse", true);
VideoTab *videoTab = new VideoTab(state, this->gameManager, vector2d<s32>(gameManager->getWidth() / 4, gameManager->getHeight() / 10 + 120), vector2d<s32>(100, 50), "Video", true);
AudioTab *audioTab = new AudioTab(state, this->gameManager, vector2d<s32>(gameManager->getWidth() / 4, gameManager->getHeight() / 10 + 180), vector2d<s32>(100, 50), "Audio", true);
MultiplayerTab *mupltiplayerTab = new MultiplayerTab(state, this->gameManager, vector2d<s32>(gameManager->getWidth() / 4, gameManager->getHeight() / 10 + 240), vector2d<s32>(100, 50), "Multiplayer", true);
//ReturnButton *returnButton = new ReturnButton(state, this->gameManager, vector2d<s32>(50, gameManager->getHeight() - 150), vector2d<s32>(140, 50), "Back", true);
//state->addButton(returnButton);
mupltiplayerTab->moveText(-20, 0);
state->addButton(controlsTab);
state->addButton(mouseTab);
state->addButton(videoTab);
state->addButton(audioTab);
state->addButton(mupltiplayerTab);
state->removeButton("Exit");
state->removeButton("Singleplayer");
state->removeButton("Options");*/
GuiAppState *state; GuiAppState *state;
}; };
} }
-29
View File
@@ -32,13 +32,8 @@ namespace battleship{
this->rayLength=projectileData::length[id][weaponTypeId][weaponId]; this->rayLength=projectileData::length[id][weaponTypeId][weaponId];
GameManager *gm = GameManager::getSingleton(); GameManager *gm = GameManager::getSingleton();
//this->node=node;
if(!node){ if(!node){
/*
mesh = smgr->getMesh(projectileData::meshPath[id][weaponTypeId]);
this->node = smgr->addAnimatedMeshSceneNode(mesh);
*/
this->node = new Model((projectileData::meshPath[id][weaponTypeId])); this->node = new Model((projectileData::meshPath[id][weaponTypeId]));
Material *mat = new Material(Root::getSingleton()->getLibPath() + "texture"); Material *mat = new Material(Root::getSingleton()->getLibPath() + "texture");
mat->addBoolUniform("lightingEnabled", false); mat->addBoolUniform("lightingEnabled", false);
@@ -46,11 +41,6 @@ namespace battleship{
Texture *diffuseTexture = new Texture(f, 1, false); Texture *diffuseTexture = new Texture(f, 1, false);
mat->addTexUniform("textures[0]", diffuseTexture, true); mat->addTexUniform("textures[0]", diffuseTexture, true);
this->node->setMaterial(mat); this->node->setMaterial(mat);
/*
if (!diffuseTexture)
diffuseTexture = driver->getTexture(DEFAULT_TEXTURE);
*/
} }
this->node->setPosition(pos); this->node->setPosition(pos);
@@ -61,7 +51,6 @@ namespace battleship{
speed = projectileData::speed[id][weaponTypeId][weaponId]; speed = projectileData::speed[id][weaponTypeId][weaponId];
float angle = dirVec.getAngleBetween(Vector3(0, 0, -1)); float angle = dirVec.getAngleBetween(Vector3(0, 0, -1));
angle = Quaternion(angle, upVec) * Vector3(0, 0, -1) == dirVec ? angle : -angle; angle = Quaternion(angle, upVec) * Vector3(0, 0, -1) == dirVec ? angle : -angle;
//this->node->setRotation(vector3df(0, angle / PI * 180, 0));
string p1 = PATH + "Sounds/" + unitData::name[id] + "s/" + projectileData::name[id][weaponTypeId] + ".ogg"; string p1 = PATH + "Sounds/" + unitData::name[id] + "s/" + projectileData::name[id][weaponTypeId] + ".ogg";
string p2 = PATH + "Sounds/Explosions/explosion03" + to_string(rand() % 4) + ".ogg"; string p2 = PATH + "Sounds/Explosions/explosion03" + to_string(rand() % 4) + ".ogg";
@@ -78,10 +67,6 @@ namespace battleship{
} }
Projectile::~Projectile(){ Projectile::~Projectile(){
/*
ISceneManager *smgr = GameManager::getSingleton()->getDevice()->getSceneManager();
node->getParent()->removeChild(node);
*/
} }
void Projectile::update() { void Projectile::update() {
@@ -92,13 +77,6 @@ namespace battleship{
} }
void Projectile::checkForCollision() { void Projectile::checkForCollision() {
//ISceneNode *collNode = castRay(GameManager::getSingleton()->getSceneManager(),pos,pos+dirVec*rayLength);
/*
Ray::castRay(pos, pos + dirVec, );
if (pos.y < -7 || (collNode&&collNode != unit->getNode()))
explode(collNode);
*/
} }
void Projectile::explode(Node *collNode) { void Projectile::explode(Node *collNode) {
@@ -123,12 +101,6 @@ namespace battleship{
} }
void Projectile::debug(){ void Projectile::debug(){
/*
IVideoDriver *driver = GameManager::getSingleton()->getDevice()->getVideoDriver();
driver->draw3DLine(pos,pos+dirVec,SColor(255,0,0,255));
driver->draw3DLine(pos,pos+leftVec,SColor(255,255,0,0));
driver->draw3DLine(pos,pos+upVec,SColor(255,0,255,0));
*/
} }
void Projectile::orientProjectile(Vector3 orientVec){ void Projectile::orientProjectile(Vector3 orientVec){
@@ -143,6 +115,5 @@ namespace battleship{
Quaternion rotQuat=Quaternion(projAngle/180*PI,leftVec); Quaternion rotQuat=Quaternion(projAngle/180*PI,leftVec);
dirVec=rotQuat*dirVec; dirVec=rotQuat*dirVec;
upVec=rotQuat*upVec; upVec=rotQuat*upVec;
//node->setRotation(vector3df(projAngle,rotAngle,0));
} }
} }
-5
View File
@@ -34,10 +34,5 @@ namespace battleship{
float tanAngle = -atan((speed * sin(angle) + g * time) / (speed * cos(angle))); float tanAngle = -atan((speed * sin(angle) + g * time) / (speed * cos(angle)));
Quaternion rotQuat = Quaternion(tanAngle, leftVec); Quaternion rotQuat = Quaternion(tanAngle, leftVec);
dirVec = rotQuat*straightVec, upVec = rotQuat * Vector3(0, 1, 0); dirVec = rotQuat*straightVec, upVec = rotQuat * Vector3(0, 1, 0);
/*
Vector3 rotVec = node->getOrientation();
rotVec=vector3df(tanAngle/PI*180,rotVec.Y,rotVec.Z);
node->setRotation(rotVec);
*/
} }
} }
-12
View File
@@ -6,23 +6,11 @@ using namespace vb01;
namespace battleship{ namespace battleship{
Tooltip::Tooltip(Vector2 pos, string entry){ Tooltip::Tooltip(Vector2 pos, string entry){
this->pos = pos; this->pos = pos;
/*
GameManager *gm = GameManager::getSingleton();
text=new BitmapText(entry,pos,gm->getDevice()->getGUIEnvironment()->getFont(PATH + "Fonts/fontcourier.bmp"));
gm->attachBitmapText(text);
*/
} }
Tooltip::~Tooltip(){ Tooltip::~Tooltip(){
//GameManager::getSingleton()->detachBitmapText(text);
} }
void Tooltip::update(){ void Tooltip::update(){
/*
IVideoDriver *driver=GameManager::getSingleton()->getDevice()->getVideoDriver();
dimension2d<u32> dim=text->getFont()->getDimension(text->getText().c_str());
driver->draw2DRectangle(SColor(255,0,0,0),recti(pos.X,pos.Y,pos.X+dim.Width,pos.Y+dim.Height),nullptr);
driver->draw2DRectangleOutline(recti(pos-vector2di(1,1),dimension2df(dim.Width+1,dim.Height+1)),SColor(255,255,0,0));
*/
} }
} }
-1
View File
@@ -11,7 +11,6 @@ namespace battleship{
void update(); void update();
private: private:
vb01::Vector2 pos; vb01::Vector2 pos;
//BitmapText *text;
}; };
} }
-1
View File
@@ -10,7 +10,6 @@ namespace battleship{
Torpedo(Unit*, vb01::Vector3, vb01::Vector3, vb01::Vector3, vb01::Vector3, int, int, int); Torpedo(Unit*, vb01::Vector3, vb01::Vector3, vb01::Vector3, vb01::Vector3, int, int, int);
~Torpedo(){} ~Torpedo(){}
void update(); void update();
//void explode()
}; };
} }
-56
View File
@@ -49,12 +49,6 @@ namespace battleship{
root->getRootNode()->attachChild(model); root->getRootNode()->attachChild(model);
placeUnit(pos); placeUnit(pos);
/*
light = smgr->addLightSceneNode(node, vector3df(0, 2, 0), SColor(255, 255, 255, 255), lineOfSight);
light->setVisible(false);
model->setVisible(false);
*/
selectionSfxBuffer = new sf::SoundBuffer(); selectionSfxBuffer = new sf::SoundBuffer();
string p = PATH + "Sounds/" + unitData::name[id] + "s/selection.ogg"; string p = PATH + "Sounds/" + unitData::name[id] + "s/selection.ogg";
@@ -83,12 +77,6 @@ namespace battleship{
} }
Unit::~Unit() { Unit::~Unit() {
/*
GameManager *gm = GameManager::getSingleton();
driver->removeTexture(node->getMaterial(0).getTexture(0));
node->removeChild(light);
node->getParent()->removeChild(node);
*/
} }
void Unit::update() { void Unit::update() {
@@ -110,7 +98,6 @@ namespace battleship{
if (selected) { if (selected) {
displayUnitStats(); displayUnitStats();
drawCuboid();
} }
if (health <= 0) if (health <= 0)
@@ -128,40 +115,6 @@ namespace battleship{
hpBackgroundNode->setPosition(Vector3(shiftedX, screenPos.y, .1)); hpBackgroundNode->setPosition(Vector3(shiftedX, screenPos.y, .1));
} }
void Unit::drawCuboid() {
/*
IVideoDriver *driver = GameManager::getSingleton()->getDevice()->getVideoDriver();
driver->setTransform(ETS_WORLD, IdentityMatrix);
for (int i = 0; i < 8; i++) {
vector3df vec = unitCornerPoints[id][i];
vector3df yVec;
vec = leftVec * vec.X + upVec * vec.Y - dirVec * vec.Z;
if (0 <= i && i < 4)
yVec = vector3df(0, unitCuboidDimensions[id][i].Y, 0);
else if (i >= 4)
yVec = vector3df(0, -unitCuboidDimensions[id][i].Y, 0);
quaternion rotQuat = rotQuat.fromAngleAxis(PI / 2 * i, vector3df(0, 1, 0));
vector3df vec1 = rotQuat * (-leftVec * unitCuboidDimensions[id][i].X), vec2 = rotQuat * (-dirVec * unitCuboidDimensions[id][i].Z);
driver->draw3DLine(pos + vec, pos + vec + vec1);
driver->draw3DLine(pos + vec, pos + vec + vec2);
driver->draw3DLine(pos + vec, pos + vec + yVec);
}
*/
}
void Unit::debug() {
/*
IVideoDriver *driver = GameManager::getSingleton()->getDevice()->getVideoDriver();
driver->setTransform(ETS_WORLD, IdentityMatrix);
driver->setMaterial(createLineMaterial());
float length = unitAxisLength[id];
driver->draw3DLine(pos, pos + dirVec * length, SColor(255, 0, 0, 255));
driver->draw3DLine(pos, pos + leftVec * length, SColor(255, 255, 0, 0));
driver->draw3DLine(pos, pos + upVec * length, SColor(255, 0, 255, 0));
*/
}
void Unit::executeOrders() { void Unit::executeOrders() {
if (orders.size() > 0) { if (orders.size() > 0) {
Order order = orders[0]; Order order = orders[0];
@@ -300,7 +253,6 @@ namespace battleship{
Quaternion rotQuat = Quaternion(projAngle / 180 * PI, leftVec); Quaternion rotQuat = Quaternion(projAngle / 180 * PI, leftVec);
dirVec = rotQuat * dirVec; dirVec = rotQuat * dirVec;
upVec = rotQuat * upVec; upVec = rotQuat * upVec;
//node->setRotation(vector3df(projAngle,rotAngle,0));
} }
Vector3 Unit::getCorner(int i) { Vector3 Unit::getCorner(int i) {
@@ -338,13 +290,5 @@ namespace battleship{
orderLineDispTime = getTime(); orderLineDispTime = getTime();
} }
/*
SMaterial Unit::createLineMaterial() {
SMaterial mat;
mat.Lighting = false;
return mat;
}
*/
void Unit::addProjectile(Projectile *p) {((InGameAppState*)GameManager::getSingleton()->getStateManager()->getAppStateByType((int)AppStateType::IN_GAME_STATE))->addProjectile(p);} void Unit::addProjectile(Projectile *p) {((InGameAppState*)GameManager::getSingleton()->getStateManager()->getAppStateByType((int)AppStateType::IN_GAME_STATE))->addProjectile(p);}
} }
-4
View File
@@ -53,7 +53,6 @@ namespace battleship{
~Unit(); ~Unit();
virtual void update(); virtual void update();
virtual void blowUp(); virtual void blowUp();
virtual void debug();
virtual void halt(); virtual void halt();
void toggleSelection(bool); void toggleSelection(bool);
void setOrder(Order); void setOrder(Order);
@@ -71,7 +70,6 @@ namespace battleship{
inline vb01::Vector2 getScreenPos(){return screenPos;} inline vb01::Vector2 getScreenPos(){return screenPos;}
inline vb01::Vector3 getPos() {return pos;} inline vb01::Vector3 getPos() {return pos;}
inline vb01::Vector3* getPosPtr() {return &pos;} inline vb01::Vector3* getPosPtr() {return &pos;}
//inline ILightSceneNode* getLight() {return light;}
inline float getLineOfSight() {return lineOfSight;} inline float getLineOfSight() {return lineOfSight;}
inline float getWidth() {return width;} inline float getWidth() {return width;}
inline float getHeight() {return height;} inline float getHeight() {return height;}
@@ -92,7 +90,6 @@ namespace battleship{
inline int getNextPatrolPointId(int numPoints) {return patrolPointId == numPoints - 1 ? 0 : patrolPointId + 1;} inline int getNextPatrolPointId(int numPoints) {return patrolPointId == numPoints - 1 ? 0 : patrolPointId + 1;}
inline bool canDisplayOrderLine(){return vb01::getTime() - orderLineDispTime < orderVecDispLength;} inline bool canDisplayOrderLine(){return vb01::getTime() - orderLineDispTime < orderVecDispLength;}
//ILightSceneNode *light;
const int orderVecDispLength = 2000; const int orderVecDispLength = 2000;
sf::SoundBuffer *selectionSfxBuffer; sf::SoundBuffer *selectionSfxBuffer;
sf::Sound *selectionSfx = nullptr; sf::Sound *selectionSfx = nullptr;
@@ -102,7 +99,6 @@ namespace battleship{
protected: protected:
Player *player; Player *player;
MoveDir moveDir = MoveDir::FORWARD; MoveDir moveDir = MoveDir::FORWARD;
//vb01::Material createLineMaterial();
unitData::UNIT_TYPE type; unitData::UNIT_TYPE type;
vb01::Vector2 screenPos; vb01::Vector2 screenPos;
std::vector<Order> orders; std::vector<Order> orders;
+1 -31
View File
@@ -90,7 +90,6 @@ namespace battleship{
state->removeAllListboxes(); state->removeAllListboxes();
state->removeAllSliders(); state->removeAllSliders();
state->removeAllTextboxes(); state->removeAllTextboxes();
//GameManager::getSingleton()->detachAllBitmapTexts();
makeTitlescreenButtons(state); makeTitlescreenButtons(state);
state->removeButton("Play"); state->removeButton("Play");
state->removeButton("Back"); state->removeButton("Back");
@@ -106,12 +105,7 @@ namespace battleship{
difficulties.push_back("Hard"); difficulties.push_back("Hard");
factions.push_back("0"); factions.push_back("0");
factions.push_back("1"); factions.push_back("1");
/*
gm->attachBitmapText(new BitmapText("Difficulty", vector2d<s32>(pos.X, pos.Y - 20), font));
gm->attachBitmapText(new BitmapText("Faction", vector2d<s32>(pos.X + 110, pos.Y - 20), font));
gm->attachBitmapText(new BitmapText("Player", vector2d<s32>(pos.X - 40, pos.Y), font));
gm->attachBitmapText(new BitmapText("CPU", vector2d<s32>(pos.X - 20, pos.Y + 30), font));
*/
string font = PATH + "Fonts/batang.ttf"; string font = PATH + "Fonts/batang.ttf";
Listbox *cpuDifficulty = new Listbox(Vector2(pos.x, pos.y + 30), Vector2(100, 20), difficulties, 3, font); Listbox *cpuDifficulty = new Listbox(Vector2(pos.x, pos.y + 30), Vector2(100, 20), difficulties, 3, font);
Listbox *cpuFaction = new Listbox(Vector2(pos.x + 110, pos.y + 30), Vector2(100, 20), factions, 2, font); Listbox *cpuFaction = new Listbox(Vector2(pos.x + 110, pos.y + 30), Vector2(100, 20), factions, 2, font);
@@ -238,28 +232,4 @@ namespace battleship{
spacePos = vec4(spacePos.x / spacePos.w, spacePos.y / spacePos.w, spacePos.z / spacePos.w, spacePos.w); spacePos = vec4(spacePos.x / spacePos.w, spacePos.y / spacePos.w, spacePos.z / spacePos.w, spacePos.w);
return Vector3(spacePos.x, spacePos.y, spacePos.z); return Vector3(spacePos.x, spacePos.y, spacePos.z);
} }
/*
bool isWithinRect(vector3df c1,vector3df c2, vector3df p, vector3df dir){
float mainAngle=getAngleBetween(c1-c2,dir);
float mainHyp=(c1-c2).getLength();
float mainWidth=cos(mainAngle)*mainHyp,mainLength=sin(mainAngle)*mainHyp;
vector3df center=(c2-c1)/2+c1;
float angle=getAngleBetween(center-p,dir);
float hyp=(center-p).getLength();
float width=cos(angle)*hyp,length=sin(angle)*hyp;
return width<=mainWidth/2&&length<=mainLength/2?true:false;
}
bool isWithinCuboid(vector3df c0, vector3df c1,vector3df c2,vector3df c3, vector3df p0){
vector3df aVec=c1-c0,bVec=c2-c0,cVec=c3-c0,pVec=p0-c0;
float a=aVec.getLength(),b=bVec.getLength(),c=cVec.getLength(),p=pVec.getLength();
float aAngle=getAngleBetween(pVec,aVec);
float bAngle=getAngleBetween(pVec,bVec);
float cAngle=getAngleBetween(pVec,cVec);
bool withinA=aAngle<=PI/2&&p*cos(aAngle)<=a;
bool withinB=bAngle<=PI/2&&p*cos(bAngle)<=b;
bool withinC=cAngle<=PI/2&&p*cos(cAngle)<=c;
return withinA&&withinB&&withinC;
}
*/
} }
-4
View File
@@ -27,10 +27,6 @@ namespace battleship{
void makeTitlescreenButtons(GuiAppState*); void makeTitlescreenButtons(GuiAppState*);
vb01::Vector2 spaceToScreen(vb01::Vector3); vb01::Vector2 spaceToScreen(vb01::Vector3);
vb01::Vector3 screenToSpace(vb01::Vector2); vb01::Vector3 screenToSpace(vb01::Vector2);
/*
bool isWithinRect(irr::core::vector3df,irr::core::vector3df,irr::core::vector3df,irr::core::vector3df);
bool isWithinCuboid(irr::core::vector3df,irr::core::vector3df,irr::core::vector3df,irr::core::vector3df,irr::core::vector3df);
*/
} }
#endif #endif
-61
View File
@@ -48,28 +48,6 @@ namespace battleship{
mantlets.push_back(mantlet); mantlets.push_back(mantlet);
} }
/*
fxNode=smgr->addParticleSystemSceneNode(false);
emitter=fxNode->createPointEmitter(dirVec,
10,10,
SColor(0,255,255,255),
SColor(0,255,255,255),
500,500,0,
dimension2df(5,5),
dimension2df(10,10));
fxNode->setEmitter(emitter);
emitter->drop();
affector=fxNode->createFadeOutParticleAffector();
fxNode->addAffector(affector);
affector->drop();
fxNode->setParent(turretMantletNodes[0]);
fxNode->setMaterialFlag(EMF_LIGHTING, false);
fxNode->setMaterialFlag(EMF_ZWRITE_ENABLE, false);
fxNode->setMaterialTexture(0, driver->getTexture(PATH+"Textures/Explosions/fire.bmp"));
fxNode->setMaterialType(EMT_TRANSPARENT_ADD_COLOR);
fxNode->setVisible(false);
*/
maxAngle = unitData::turretMaxAngle[unitId][turretId] / 180 * PI; maxAngle = unitData::turretMaxAngle[unitId][turretId] / 180 * PI;
rotationSpeed = unitData::turretRotationSpeed[unitId][turretId] / 180 * PI; rotationSpeed = unitData::turretRotationSpeed[unitId][turretId] / 180 * PI;
@@ -85,32 +63,9 @@ namespace battleship{
} }
void Vessel::Turret::update() { void Vessel::Turret::update() {
/*
Node *rootNode = Root::getSingleton()->getRootNode();
Vector3 turretPosition = turret->localToGlobalPosition(Vector3::VEC_ZERO);
float hullAngle = PI / 180;
float turretAngle = PI / 180 * angle;
quaternion rotQuat = rotQuat.fromAngleAxis(hullAngle + turretAngle, vector3df(0, 1, 0));
quaternion offsetQuat = offsetQuat.fromAngleAxis(PI / 180 * unitData::turretAngleOffset[unitId][turretId], vector3df(0, 1, 0));
emitter->setDirection(dirVec);
if(getTime()-lastShotTime>30&&fxNode->isVisible())
fxNode->setVisible(false);
*/
dirVec = node->getGlobalAxis(2), leftVec = node->getGlobalAxis(0); dirVec = node->getGlobalAxis(2), leftVec = node->getGlobalAxis(0);
} }
void Vessel::Turret::debug() {
/*
float length = turretAxisLength[unitId][turretId]*0 + 1;
IVideoDriver *driver = GameManager::getSingleton()->getDevice()->getVideoDriver();
driver->setTransform(ETS_WORLD, IdentityMatrix);
driver->setMaterial(mat);
driver->draw3DLine(turretPosition, turretPosition + dirVec*length, SColor(255, 0, 0, 255));
driver->draw3DLine(turretPosition, turretPosition + leftVec*length, SColor(255, 255, 0, 0));
driver->draw3DLine(turretPosition, turretPosition + upVec*length, SColor(255, 0, 255, 0));
*/
}
Vector3 Vessel::Turret::getInitDir(int dirType){ Vector3 Vessel::Turret::getInitDir(int dirType){
Vector3 initDirs[3]; Vector3 initDirs[3];
@@ -141,17 +96,6 @@ namespace battleship{
} }
void Vessel::Turret::fire() { void Vessel::Turret::fire() {
/*
fxNode->setVisible(true);
quaternion rotQuat = rotQuat.fromAngleAxis(barrelAngle / 180 * PI, leftVec);
int barId = 0;
vector3df startPos = vessel->getPos() + vessel->getLeftVec() * turretNode->getPosition().X + vessel->getUpVec() * turretNode->getPosition().Y - vessel->getDirVec() * turretNode->getPosition().Z;
startPos += rotQuat * (leftVec * turretMantletNodes[barId]->getPosition().X + upVec * turretMantletNodes[barId]->getPosition().Y + dirVec * turretMantletNodes[barId]->getPosition().Z);
startPos += rotQuat * (leftVec * turretBarrelNodes[barId]->getPosition().X + upVec * turretBarrelNodes[barId]->getPosition().Y + dirVec * turretBarrelNodes[barId]->getPosition().Z);
startPos += rotQuat * (leftVec * projectileData::pos[unitId][0][turretId].X + upVec * projectileData::pos[unitId][0][turretId].Y + dirVec * projectileData::pos[unitId][0][turretId].Z);
vessel->addProjectile(new Shell(vessel, startPos, rotQuat*dirVec, rotQuat*leftVec, rotQuat*upVec, unitId, 0, turretId));
*/
if(sfx) if(sfx)
sfx->play(); sfx->play();
@@ -196,9 +140,4 @@ namespace battleship{
} }
} }
} }
void Vessel::debug() {
for (Turret *t : turrets)
t->debug();
}
} }
-3
View File
@@ -21,8 +21,6 @@ namespace battleship {
protected: protected:
void attack(Order); void attack(Order);
private: private:
void debug();
class Turret { class Turret {
public: public:
struct Mantlet{ struct Mantlet{
@@ -33,7 +31,6 @@ namespace battleship {
void update(); void update();
void fire(); void fire();
void rotate(double); void rotate(double);
void debug();
vb01::Vector3 getInitDir(int); vb01::Vector3 getInitDir(int);
inline vb01::Vector3 getDirVec(){return dirVec;} inline vb01::Vector3 getDirVec(){return dirVec;}
inline vb01::Vector3 getLeftVec(){return leftVec;} inline vb01::Vector3 getLeftVec(){return leftVec;}