Commit 3931a75c authored by 魔大农's avatar 魔大农 🍀

Code cleanup

parent 3e355949
This diff is collapsed.
/* Quatter
// Copyright (C) 2016 LucKey Productions (luckeyproductions.nl)
// 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
......@@ -40,10 +40,11 @@ class Indicator;
class Board : public LogicComponent
{
URHO3D_OBJECT(Board, LogicComponent);
public:
Board(Context* context);
static void RegisterObject(Context* context);
virtual void OnNodeSet(Node* node);
void OnNodeSet(Node* node) override;
float GetThickness() const { return model_->GetBoundingBox().Size().y_; }
......@@ -70,8 +71,8 @@ public:
bool IsEmpty() const;
bool IsFull() const;
void HideIndicators();
private:
bool indicateSingle_;
StaticModel* model_;
HashMap<IntVector2, SharedPtr<Square>> squares_;
......
/* Quatter
// Copyright (C) 2016 LucKey Productions (luckeyproductions.nl)
// 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
......
/* Quatter
// Copyright (C) 2016 LucKey Productions (luckeyproductions.nl)
// 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
......@@ -34,7 +34,7 @@ public:
void FadeTo(Light* light, float brightness, float duration = 0.23f);
void FadeTo(SoundSource* soundSource, float gain, float duration = 2.3f);
void FadeOut(Material* material, float duration = 0.23f) {FadeTo(material, material->GetShaderParameter("MatDiffColor").GetColor() * 0.0f, duration); }
void FadeOut(Material* material, float duration = 0.23f) { FadeTo(material, material->GetShaderParameter("MatDiffColor").GetColor() * 0.0f, duration); }
void FadeOut(Light* light) { FadeTo(light, 0.0f); }
void FadeOut(SoundSource* soundSource, float duration = 5.0f);
......
/* Quatter
// Copyright (C) 2016 LucKey Productions (luckeyproductions.nl)
// 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
......@@ -29,7 +29,7 @@ Indicator::Indicator(Context* context) : LogicComponent(context)
}
void Indicator::OnNodeSet(Node *node)
{ (void)node;
{ if (!node) return;
glow_ = MC->GetMaterial("Glow")->Clone();
//Create nodes and models
......
/* Quatter
// Copyright (C) 2016 LucKey Productions (luckeyproductions.nl)
// 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
......@@ -22,16 +22,16 @@
#include <Urho3D/Urho3D.h>
#include "mastercontrol.h"
#include "luckey.h"
class Indicator : public LogicComponent
{
friend class Board;
URHO3D_OBJECT(Indicator, LogicComponent);
public:
Indicator(Context* context);
static void RegisterObject(Context* context);
virtual void OnNodeSet(Node* node);
void OnNodeSet(Node* node) override;
private:
Node* arrowNode1_;
......
This diff is collapsed.
/* Quatter
// Copyright (C) 2016 LucKey Productions (luckeyproductions.nl)
// 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
......@@ -35,6 +35,7 @@ class Yad;
class InputMaster : public Master
{
URHO3D_OBJECT(InputMaster, Master);
public:
InputMaster(Context* context);
bool IsIdle() const noexcept { return idle_; }
......
/*
// Copyright (C) 2016 LucKey Productions (luckeyproductions.nl)
// 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
......
/*
// Copyright (C) 2016 LucKey Productions (luckeyproductions.nl)
// 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
......@@ -98,11 +98,11 @@ class Camera;
using namespace Urho3D;
namespace LucKey {
enum SixaxisButton { SB_SELECT, SB_LEFTSTICK, SB_RIGHTSTICK, SB_START,
SB_DPAD_UP, SB_DPAD_RIGHT, SB_DPAD_DOWN, SB_DPAD_LEFT,
SB_L2, SB_R2, SB_L1, SB_R1,
SB_TRIANGLE, SB_CIRCLE, SB_CROSS, SB_SQUARE,
SB_PS };
enum SixaxisButton { SB_SELECT, SB_LEFTSTICK, SB_RIGHTSTICK, SB_START,
SB_DPAD_UP, SB_DPAD_RIGHT, SB_DPAD_DOWN, SB_DPAD_LEFT,
SB_L2, SB_R2, SB_L1, SB_R1,
SB_TRIANGLE, SB_CIRCLE, SB_CROSS, SB_SQUARE,
SB_PS };
unsigned IntVector2ToHash(IntVector2 vec);
......
/* Quatter
// Copyright (C) 2016 LucKey Productions (luckeyproductions.nl)
// 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
......
/* Quatter
// Copyright (C) 2016 LucKey Productions (luckeyproductions.nl)
// 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
......@@ -33,8 +33,9 @@ using namespace Urho3D;
class Master : public Object
{
friend class MasterControl;
URHO3D_OBJECT(Master, Object);
friend class MasterControl;
public:
Master(Context* context);
};
......
/* Quatter
// Copyright (C) 2016 LucKey Productions (luckeyproductions.nl)
// 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
......@@ -144,10 +144,11 @@ void MasterControl::CreateLights()
leafyLight_->SetShapeTexture(static_cast<Texture*>(CACHE->GetResource<Texture2D>("Textures/LeafyMask.png")));
//Add a directional light to the world. Enable cascaded shadows on it
Node* downardsLightNode{world_.scene_->CreateChild("DirectionalLight")};
Node* downardsLightNode{ world_.scene_->CreateChild("DirectionalLight") };
downardsLightNode->SetPosition(Vector3(2.0f, 23.0f, 3.0f));
downardsLightNode->LookAt(Vector3(0.0f, 0.0f, 0.0f));
Light* downwardsLight{downardsLightNode->CreateComponent<Light>()};
downardsLightNode->LookAt(Vector3::ZERO);
Light* downwardsLight{ downardsLightNode->CreateComponent<Light>() };
downwardsLight->SetLightType(LIGHT_DIRECTIONAL);
downwardsLight->SetBrightness(0.34f);
downwardsLight->SetColor(Color(0.8f, 0.9f, 0.95f));
......@@ -156,10 +157,12 @@ void MasterControl::CreateLights()
downwardsLight->SetShadowCascade(CascadeParameters(7.0f, 13.0f, 23.0f, 42.0f, 0.6));
//Create point lights
for (Vector3 pos : {Vector3(-10.0f, 8.0f, -23.0f), Vector3(-20.0f, -8.0f, 23.0f), Vector3(20.0f, -7.0f, 23.0f)}){
Node* pointLightNode_{world_.scene_->CreateChild("PointLight")};
for (Vector3 pos : { Vector3(-10.0f, 8.0f, -23.0f), Vector3(-20.0f, -8.0f, 23.0f), Vector3(20.0f, -7.0f, 23.0f) }) {
Node* pointLightNode_{ world_.scene_->CreateChild("PointLight") };
pointLightNode_->SetPosition(pos);
Light* pointLight{pointLightNode_->CreateComponent<Light>()};
Light* pointLight{ pointLightNode_->CreateComponent<Light>() };
pointLight->SetLightType(LIGHT_POINT);
pointLight->SetBrightness(0.42f);
pointLight->SetRange(42.0f);
......@@ -171,16 +174,16 @@ void MasterControl::CreateLights()
}
void MasterControl::CreateSkybox()
{
Node* skyNode{world_.scene_->CreateChild("Sky")};
Skybox* skybox{skyNode->CreateComponent<Skybox>()};
Node* skyNode{ world_.scene_->CreateChild("Sky") };
Skybox* skybox{ skyNode->CreateComponent<Skybox>() };
skybox->SetModel(GetModel("Sphere"));
skybox->SetMaterial(GetMaterial("LeafyKnoll"));
}
void MasterControl::CreateJukebox()
{
Sound* song1{GetMusic("Angelight - The Knowledge River")};
Sound* song2{GetMusic("Cao Sao Vang - Days Of Yore")};
Node* musicNode{world_.scene_->CreateChild("Music")};
Sound* song1{ GetMusic("Angelight - The Knowledge River") };
Sound* song2{ GetMusic("Angelight - The Knowledge River") };
Node* musicNode{ world_.scene_->CreateChild("Music") };
musicSource1_ = musicNode->CreateComponent<SoundSource>();
musicSource1_->SetSoundType(SOUND_MUSIC);
......@@ -194,19 +197,21 @@ void MasterControl::CreateJukebox()
}
void MasterControl::CreateTable()
{
Node* tableNode{world_.scene_->CreateChild("Table")};
StringVector tag{}; tag.Push(String("Table"));
tableNode->SetTags(tag);
Node* tableNode{ world_.scene_->CreateChild("Table") };
tableNode->AddTag("Table");
tableNode->SetRotation(Quaternion(23.5f, Vector3::UP));
StaticModel* tableModel = tableNode->CreateComponent<StaticModel>();
StaticModel* tableModel{ tableNode->CreateComponent<StaticModel>() };
tableModel->SetModel(GetModel("Table"));
tableModel->SetMaterial(GetMaterial("Table"));
tableModel->GetMaterial()->SetShaderParameter("MatDiffColor", Vector4(0.32f, 0.40f, 0.42f, 1.0f));
tableModel->SetCastShadows(true);
Node* hitNode{world_.scene_->CreateChild("HitPlane")};
Node* hitNode{ world_.scene_->CreateChild("HitPlane") };
hitNode->SetPosition(Vector3::DOWN * 1.23f);
hitNode->SetScale(128.0f);
StaticModel* hitPlane{hitNode->CreateComponent<StaticModel>()};
StaticModel* hitPlane{ hitNode->CreateComponent<StaticModel>() };
hitPlane->SetModel(MC->GetModel("Plane"));
hitPlane->SetMaterial(MC->GetMaterial("Invisible"));
}
......@@ -215,10 +220,11 @@ void MasterControl::CreateBoardAndPieces()
Node* boardNode{ world_.scene_->CreateChild("Board") };
world_.board_ = boardNode->CreateComponent<Board>();
world_.pieces_.Reserve(NUM_PIECES);
for (int p{0}; p < NUM_PIECES; ++p){
Node* pieceNode{ world_.scene_->CreateChild("Piece") };
Piece* newPiece = pieceNode->CreateComponent<Piece>();
Piece* newPiece{ pieceNode->CreateComponent<Piece>() };
newPiece->Init(Piece::PieceAttributes(p));
world_.pieces_.Push(SharedPtr<Piece>(newPiece));
......@@ -229,14 +235,18 @@ void MasterControl::CreateBoardAndPieces()
}
}
Sound* MasterControl::GetMusic(String name) const {
Sound* MasterControl::GetMusic(String name) const
{
Sound* song{ CACHE->GetResource<Sound>("Music/"+name+".ogg") };
song->SetLooped(true);
return song;
}
Sound* MasterControl::GetSample(String name) const {
Sound* MasterControl::GetSample(String name) const
{
Sound* sample{ CACHE->GetResource<Sound>("Samples/"+name+".ogg") };
sample->SetLooped(false);
return sample;
}
......@@ -263,8 +273,9 @@ void MasterControl::CameraSelectPiece(bool force)
if (!force && IsLame())
return;
Piece* nearest{selectedPiece_};
for (Piece* piece: world_.pieces_){
Piece* nearest{ selectedPiece_ };
for (Piece* piece : world_.pieces_) {
if (!nearest
&& (piece->GetState() == PieceState::FREE || piece->GetState() == PieceState::SELECTED))
{
......@@ -276,23 +287,27 @@ void MasterControl::CameraSelectPiece(bool force)
nearest = piece;
}
}
if (nearest != selectedPiece_){
if (nearest != selectedPiece_) {
SelectPiece(nearest);
}
}
bool MasterControl::SelectLastPiece()
{
if (lastSelectedPiece_){
if (lastSelectedPiece_) {
SelectPiece(lastSelectedPiece_);
return true;
} else
return false;
}
void MasterControl::StepSelectPiece(bool next)
{
SetSelectionMode(SM_STEP);
if (selectedPiece_){
if (selectedPiece_) {
int selectInt{selectedPiece_->ToInt()};
while (world_.pieces_.At(selectInt)->GetState() != PieceState::FREE){
......@@ -362,7 +377,7 @@ void MasterControl::Reset()
{
lastReset_ = TIME->GetElapsedTime();
for (Piece* p: world_.pieces_){
for (Piece* p : world_.pieces_){
p->Reset();
}
......@@ -468,7 +483,7 @@ void MasterControl::MusicGainDown(float step)
void MasterControl::TakeScreenshot()
{
Image screenshot{context_};
Image screenshot{ context_ };
GRAPHICS->TakeScreenShot(screenshot);
//Here we save in the Screenshots folder with date and time appended
String fileName{GetSubsystem<FileSystem>()->GetProgramDir() + "Screenshots/Screenshot_" +
......@@ -479,13 +494,15 @@ void MasterControl::TakeScreenshot()
float MasterControl::Sine(const float freq, const float min, const float max, const float shift)
{
float phase{freq * world_.scene_->GetElapsedTime() + shift};
float add{0.5f * (min + max)};
float phase{ freq * world_.scene_->GetElapsedTime() + shift };
float add{ 0.5f * (min + max) };
return LucKey::Sine(phase) * 0.5f * (max - min) + add;
}
float MasterControl::Cosine(const float freq, const float min, const float max, const float shift)
{
float phase{freq * world_.scene_->GetElapsedTime() + shift};
float add{0.5f * (min + max)};
float phase{ freq * world_.scene_->GetElapsedTime() + shift };
float add{ 0.5f * (min + max) };
return LucKey::Cosine(phase) * 0.5f * (max - min) + add;
}
/* Quatter
// Copyright (C) 2016 LucKey Productions (luckeyproductions.nl)
// 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
......@@ -35,9 +35,9 @@ class EffectMaster;
class Board;
class Piece;
enum class GameState{PLAYER1PICKS, PLAYER2PUTS, PLAYER2PICKS, PLAYER1PUTS, QUATTER};
enum MusicState{MUSIC_SONG1, MUSIC_SONG2, MUSIC_OFF};
enum SelectionMode{SM_CAMERA, SM_STEP, SM_YAD};
enum class GameState{ PLAYER1PICKS, PLAYER2PUTS, PLAYER2PICKS, PLAYER1PUTS, QUATTER };
enum MusicState{ MUSIC_SONG1, MUSIC_SONG2, MUSIC_OFF };
enum SelectionMode{ SM_CAMERA, SM_STEP, SM_YAD };
typedef struct GameWorld
{
......@@ -45,11 +45,6 @@ typedef struct GameWorld
SharedPtr<Scene> scene_;
SharedPtr<Board> board_;
Vector< SharedPtr<Piece> > pieces_;
struct {
SharedPtr<Node> sceneCursor_;
SharedPtr<Cursor> uiCursor_;
PODVector<RayQueryResult> hitResults_;
} cursor_;
} GameWorld;
#define MC MasterControl::GetInstance()
......@@ -66,6 +61,7 @@ class MasterControl : public Application
{
URHO3D_OBJECT(MasterControl, Application);
friend class InputMaster;
public:
MasterControl(Context* context);
static MasterControl* GetInstance();
......@@ -73,9 +69,9 @@ public:
GameWorld world_;
virtual void Setup();
virtual void Start();
virtual void Stop();
void Setup() override;
void Start() override;
void Stop() override;
void Exit();
void CreateLights();
......@@ -93,15 +89,15 @@ public:
void NextMusicState();
void TakeScreenshot();
float AttributesToAngle(int attributes) const { return (360.0f/NUM_PIECES * attributes) + 180.0f/NUM_PIECES + 23.5f; }
float AttributesToAngle(int attributes) const { return (360.0f/NUM_PIECES * attributes) + 180.0f / NUM_PIECES + 23.5f; }
Vector3 AttributesToPosition(int attributes) const {
return Quaternion(AttributesToAngle(attributes), Vector3::UP) * Vector3::BACK * 7.0f
+ Vector3::DOWN * TABLE_DEPTH;
}
Material* GetMaterial(String name) const { return CACHE->GetResource<Material>("Materials/"+name+".xml"); }
Model* GetModel(String name) const { return CACHE->GetResource<Model>("Models/"+name+".mdl"); }
Texture* GetTexture(String name) const { return CACHE->GetResource<Texture>("Textures/"+name+".png"); }
Material* GetMaterial(String name) const { return CACHE->GetResource<Material>("Materials/" + name + ".xml"); }
Model* GetModel(String name) const { return CACHE->GetResource<Model>("Models/" + name + ".mdl"); }
Texture* GetTexture(String name) const { return CACHE->GetResource<Texture>("Textures/" + name + ".png"); }
Sound* GetMusic(String name) const;
Sound* GetSample(String name) const;
......@@ -113,6 +109,7 @@ public:
float Sine(const float freq, const float min = -1.0f, const float max = 1.0f, const float shift = 0.0f);
float Cosine(const float freq, const float min = -1.0f, const float max = 1.0f, const float shift = 0.0f);
private:
static MasterControl* instance_;
String resourceFolder_;
......
/* Quatter
// Copyright (C) 2016 LucKey Productions (luckeyproductions.nl)
// 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
......@@ -32,11 +32,10 @@ Piece::Piece(Context* context): LogicComponent(context),
{
}
void Piece::OnNodeSet(Node* node)
{ (void)node;
{ if (!node) return;
node_->SetRotation(Quaternion(Random(360.0f), Vector3::UP));
StringVector tag{}; tag.Push(String("Piece"));
node_->SetTags(tag);
node_->AddTag("Piece");
pieceModel_ = node_->CreateComponent<StaticModel>();
pieceModel_->SetCastShadows(true);
......@@ -44,7 +43,7 @@ void Piece::OnNodeSet(Node* node)
outlineModel_ = node_->CreateComponent<StaticModel>();
outlineModel_->SetCastShadows(false);
Node* lightNode{node_->CreateChild("Light")};
Node* lightNode{ node_->CreateChild("Light") };
lightNode->SetPosition(Vector3::UP * 0.5f);
light_ = lightNode->CreateComponent<Light>();
light_->SetColor(Color(0.0f, 0.8f, 0.5f));
......@@ -56,12 +55,16 @@ void Piece::OnNodeSet(Node* node)
void Piece::Init(PieceAttributes attributes)
{
attributes_ = attributes;
pieceModel_->SetModel(MC->GetModel("Piece_" + GetCodon(3)));
if (attributes[3]){
if (attributes[3]) {
pieceModel_->SetMaterial(MC->GetMaterial("Wood_light"));
} else {
pieceModel_->SetMaterial(MC->GetMaterial("Wood_dark"));
}
else pieceModel_->SetMaterial(MC->GetMaterial("Wood_dark"));
outlineModel_->SetModel(MC->GetModel("Piece_"+GetCodon(2)+"_outline"));
outlineModel_->SetMaterial(MC->GetMaterial("Glow")->Clone());
......@@ -96,13 +99,13 @@ String Piece::GetCodon(int length) const
String codon{};
codon += !attributes_[0] ? "S" : "T"; //Tall : Short
codon += attributes_[0] ? "T" : "S"; //Tall : Short
if (length > 1)
codon += !attributes_[1] ? "S" : "R"; //Round : Square
codon += attributes_[1] ? "R" : "S"; //Round : Square
if (length > 2)
codon += !attributes_[2] ? "S" : "H"; //Hole : Solid
codon += attributes_[2] ? "H" : "S"; //Hole : Solid
if (length == NUM_ATTRIBUTES)
codon += !attributes_[3] ? "D" : "L"; //Light : Dark
codon += attributes_[3] ? "L" : "D"; //Light : Dark
return codon;
}
......@@ -113,17 +116,18 @@ void Piece::Select()
MC->GetGameState() == GameState::PLAYER2PICKS))
{
outlineModel_->SetEnabled(true);
if (state_ == PieceState::FREE){
if (state_ == PieceState::FREE) {
state_ = PieceState::SELECTED;
FX->FadeTo(outlineModel_->GetMaterial(),
COLOR_GLOW);
FX->FadeTo(outlineModel_->GetMaterial(), COLOR_GLOW);
FX->FadeTo(light_, 0.666f);
}
}
}
void Piece::Deselect()
{
if (state_ == PieceState::SELECTED){
if (state_ == PieceState::SELECTED) {
state_ = PieceState::FREE;
FX->FadeOut(outlineModel_->GetMaterial());
......@@ -132,10 +136,11 @@ void Piece::Deselect()
}
void Piece::Pick()
{
if (state_ != PieceState::PUT){
if (state_ != PieceState::PUT) {
state_ = PieceState::PICKED;
MC->SetPickedPiece(this);
if (MC->GetGameState() == GameState::PLAYER1PICKS)
node_->SetParent(CAMERA->GetPocket(false));
if (MC->GetGameState() == GameState::PLAYER2PICKS)
......@@ -151,7 +156,7 @@ void Piece::Pick()
}
void Piece::Put(Vector3 position)
{
if (state_ == PieceState::PICKED){
if (state_ == PieceState::PICKED) {
state_ = PieceState::PUT;
MC->SetPickedPiece(nullptr);
......
/* Quatter
// Copyright (C) 2016 LucKey Productions (luckeyproductions.nl)
// 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
......@@ -38,11 +38,12 @@ class Square;
class Piece : public LogicComponent
{
URHO3D_OBJECT(Piece, Object);
public:
typedef std::bitset<NUM_ATTRIBUTES> PieceAttributes;
Piece(Context* context);
static void RegisterObject(Context* context);
virtual void OnNodeSet(Node* node);
void OnNodeSet(Node* node) override;
void Init(PieceAttributes attributes);
Node* GetNode() const { return node_; }
......@@ -60,6 +61,7 @@ public:
void Reset();
int ToInt() const { return static_cast<int>(attributes_.to_ulong()); }
private:
SharedPtr<StaticModel> pieceModel_;
SharedPtr<StaticModel> outlineModel_;
......@@ -67,7 +69,6 @@ private:
PieceAttributes attributes_;
PieceState state_;
};
#endif // PIECE_H
/* Quatter
// Copyright (C) 2016 LucKey Productions (luckeyproductions.nl)
// 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
......@@ -31,7 +31,7 @@ QuatterCam::QuatterCam(Context* context) : LogicComponent(context),
{
}
void QuatterCam::OnNodeSet(Node *node)
{ (void)node;
{ if (!node) return;
node_->SetPosition(Vector3(3.0f, 10.0f, -8.0f));
node_->LookAt(Vector3::ZERO);
......
/* Quatter
// Copyright (C) 2016 LucKey Productions (luckeyproductions.nl)
// 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
......@@ -20,7 +20,7 @@
#define QUATTERCAM_H
#include <Urho3D/Urho3D.h>
#include "mastercontrol.h"
#include "luckey.h"
namespace Urho3D {
class Drawable;
......@@ -46,11 +46,12 @@ class QuatterCam : public LogicComponent
URHO3D_OBJECT(QuatterCam, LogicComponent);
friend class MasterControl;
friend class InputMaster;
public:
QuatterCam(Context* context);
static void RegisterObject(Context* context);
virtual void OnNodeSet(Node* node);
virtual void Update(float timeStep);
void OnNodeSet(Node* node) override;
void Update(float timeStep) override;
SharedPtr<Camera> camera_;
SharedPtr<Viewport> viewport_;
......@@ -76,7 +77,6 @@ private:
float aimDistance_;
Vector3 targetPosition_;
void SetupViewport();
void Rotate(Vector2 rotation);
void CreatePockets();
......
/* Quatter
// Copyright (C) 2016 LucKey Productions (luckeyproductions.nl)
// 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
......@@ -26,28 +26,29 @@ void Square::RegisterObject(Context *context)
Square::Square(Context* context) : LogicComponent(context)
{
}
void Square::OnNodeSet(Node *node)
{ (void)node;
{ if (!node) return;
node_->AddTag("Square");
StringVector tag{}; tag.Push(String("Square"));
node_->SetTags(tag);
StaticModel* touchPlane{node_->CreateComponent<StaticModel>()};
StaticModel* touchPlane{ node_->CreateComponent<StaticModel>() };
touchPlane->SetModel(MC->GetModel("Plane"));
touchPlane->SetMaterial(MC->GetMaterial("Invisible"));
free_ = true;
piece_ = nullptr;
//Create slot
Node* slotNode{node_->CreateChild("Slot")};
Node* slotNode{ node_->CreateChild("Slot") };
slotNode->SetPosition(Vector3::UP * 0.05f);
slot_ = slotNode->CreateComponent<AnimatedModel>();
slot_->SetModel(MC->GetModel("Slot"));
slot_->SetMaterial(MC->GetMaterial("Glow")->Clone());
slot_->GetMaterial()->SetShaderParameter("MatDiffColor", Color(0.0f, 0.0f, 0.0f, 0.0f));
//Create light
Node* lightNode{slotNode->CreateChild("Light")};
Node* lightNode{ slotNode->CreateChild("Light") };
lightNode->SetPosition(Vector3::UP * 0.23f);
light_ = lightNode->CreateComponent<Light>();
light_->SetColor(0.5f * COLOR_GLOW);
......
/* heXon
// Copyright (C) 2016 LucKey Productions (luckeyproductions.nl)
// 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
......@@ -20,7 +20,6 @@
#define SQUARE_H
#include <Urho3D/Urho3D.h>
#include "luckey.h"
class Piece;
......@@ -32,7 +31,7 @@ class Square : public LogicComponent
public:
Square(Context* context);
static void RegisterObject(Context* context);
virtual void OnNodeSet(Node* node);
void OnNodeSet(Node* node) override;
private:
IntVector2 coords_;
......
/* Quatter
// Copyright (C) 2016 LucKey Productions (luckeyproductions.nl)
// 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
......@@ -34,16 +34,17 @@ Yad::Yad(Context* context) : LogicComponent(context),
}
void Yad::OnNodeSet(Node *node)
{ (void)node;
{ if (!node) return;
node_->AddTag("Yad");
StringVector tag{}; tag.Push(String("Yad"));
node_->SetTags(tag);