J :
* Add missing files.
This commit is contained in:
@@ -0,0 +1,48 @@
|
|||||||
|
#ifndef _CARDSELECTOR_H_
|
||||||
|
#define _CARDSELECTOR_H_
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include "GuiLayers.h"
|
||||||
|
#include "DuelLayers.h"
|
||||||
|
#include "Pos.h"
|
||||||
|
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
|
class PlayGuiObject;
|
||||||
|
class DuelLayers;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct LimitorFunctor
|
||||||
|
{
|
||||||
|
virtual bool select(T*) = 0;
|
||||||
|
virtual bool greyout(T*) = 0;
|
||||||
|
typedef T Target;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T=PlayGuiObject>
|
||||||
|
class ObjectSelector : public GuiLayer
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
vector<T*> cards;
|
||||||
|
T* active;
|
||||||
|
bool showBig;
|
||||||
|
DuelLayers* duel;
|
||||||
|
LimitorFunctor<T>* limitor;
|
||||||
|
Pos bigpos;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObjectSelector(DuelLayers*);
|
||||||
|
void Add(T*);
|
||||||
|
void Remove(T*);
|
||||||
|
bool CheckUserInput(u32 key);
|
||||||
|
void Update(float dt);
|
||||||
|
void Render();
|
||||||
|
void Limit(LimitorFunctor<T>* limitor);
|
||||||
|
|
||||||
|
typedef T Target;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef ObjectSelector<> CardSelector;
|
||||||
|
typedef LimitorFunctor<CardSelector::Target> Limitor;
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
#ifndef _GUIAVATARS_H_
|
||||||
|
#define _GUIAVATARS_H_
|
||||||
|
|
||||||
|
#include "GuiLayers.h"
|
||||||
|
#include "CardSelector.h"
|
||||||
|
|
||||||
|
class GuiAvatar;
|
||||||
|
class GuiGraveyard;
|
||||||
|
class GuiLibrary;
|
||||||
|
|
||||||
|
class GuiAvatars : public GuiLayer
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
GuiAvatar* self, *opponent;
|
||||||
|
GuiGraveyard* selfGraveyard, *opponentGraveyard;
|
||||||
|
GuiLibrary* selfLibrary, *opponentLibrary;
|
||||||
|
CardSelector* cs;
|
||||||
|
GuiAvatar* active;
|
||||||
|
|
||||||
|
public:
|
||||||
|
GuiAvatars(CardSelector*);
|
||||||
|
~GuiAvatars();
|
||||||
|
// virtual void Render();
|
||||||
|
void Update(float dt);
|
||||||
|
void Activate(PlayGuiObject* c);
|
||||||
|
void Deactivate(PlayGuiObject* c);
|
||||||
|
int receiveEventPlus(WEvent*);
|
||||||
|
int receiveEventMinus(WEvent*);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _GUIAVATARS_H_
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#ifndef _GUIBACKGROUND_H_
|
||||||
|
#define _GUIBACKGROUND_H_
|
||||||
|
|
||||||
|
#include "GuiLayers.h"
|
||||||
|
#include "WEvent.h"
|
||||||
|
|
||||||
|
class GuiBackground : public GuiLayer
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
JQuad* quad;
|
||||||
|
|
||||||
|
public:
|
||||||
|
GuiBackground();
|
||||||
|
~GuiBackground();
|
||||||
|
virtual void Render();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _GUIBACKGROUND_H_
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
#ifndef _GUICOMBAT_H_
|
||||||
|
#define _GUICOMBAT_H_
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include "WEvent.h"
|
||||||
|
#include "CardGui.h"
|
||||||
|
#include "MTGCardInstance.h"
|
||||||
|
|
||||||
|
class GuiCombat : public GuiLayer
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
CardSelector* cs;
|
||||||
|
vector<MTGCardInstance*> attackers;
|
||||||
|
|
||||||
|
public:
|
||||||
|
GuiCombat(CardSelector* cs);
|
||||||
|
~GuiCombat();
|
||||||
|
virtual void Update(float dt);
|
||||||
|
virtual void Render();
|
||||||
|
virtual bool CheckUserInput(u32 key);
|
||||||
|
virtual int receiveEventPlus(WEvent* e);
|
||||||
|
virtual int receiveEventMinus(WEvent* e);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _GUICOMBAT_H_
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#ifndef _GUIFRAME_H_
|
||||||
|
#define _GUIFRAME_H_
|
||||||
|
|
||||||
|
#include "GuiLayers.h"
|
||||||
|
|
||||||
|
class GuiFrame : public GuiLayer
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
JQuad* wood;
|
||||||
|
JQuad* gold1, *gold2, *goldGlow;
|
||||||
|
float step;
|
||||||
|
|
||||||
|
public:
|
||||||
|
GuiFrame();
|
||||||
|
~GuiFrame();
|
||||||
|
virtual void Render();
|
||||||
|
void Update(float dt);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _GUIFRAME_H_
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
#ifndef _GUIHAND_H_
|
||||||
|
#define _GUIHAND_H_
|
||||||
|
|
||||||
|
#include "GuiLayers.h"
|
||||||
|
#include "WEvent.h"
|
||||||
|
#include "MTGGameZones.h"
|
||||||
|
#include "CardGui.h"
|
||||||
|
#include "GuiHand.h"
|
||||||
|
#include "CardSelector.h"
|
||||||
|
|
||||||
|
class GuiHand;
|
||||||
|
|
||||||
|
struct HandLimitor : public Limitor
|
||||||
|
{
|
||||||
|
GuiHand* hand;
|
||||||
|
virtual bool select(Target*);
|
||||||
|
virtual bool greyout(Target*);
|
||||||
|
|
||||||
|
HandLimitor(GuiHand* hand);
|
||||||
|
};
|
||||||
|
|
||||||
|
class GuiHand : public GuiLayer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static const float ClosedRowX = 459;
|
||||||
|
static const float LeftRowX = 420;
|
||||||
|
static const float RightRowX = 460;
|
||||||
|
|
||||||
|
static const float OpenX = 394;
|
||||||
|
static const float ClosedX = 494;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
const MTGHand* hand;
|
||||||
|
JQuad *back;
|
||||||
|
vector<CardView*> cards;
|
||||||
|
CardSelector* cs;
|
||||||
|
|
||||||
|
public:
|
||||||
|
GuiHand(CardSelector* cs, MTGHand* hand);
|
||||||
|
~GuiHand();
|
||||||
|
void Update(float dt);
|
||||||
|
|
||||||
|
friend class HandLimitor;
|
||||||
|
};
|
||||||
|
|
||||||
|
class GuiHandOpponent : public GuiHand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GuiHandOpponent(CardSelector* cs, MTGHand* hand);
|
||||||
|
virtual void Render();
|
||||||
|
virtual int receiveEventPlus(WEvent* e);
|
||||||
|
virtual int receiveEventMinus(WEvent* e);
|
||||||
|
};
|
||||||
|
|
||||||
|
class GuiHandSelf : public GuiHand
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
Open,
|
||||||
|
Closed
|
||||||
|
} state;
|
||||||
|
float backpos;
|
||||||
|
|
||||||
|
public:
|
||||||
|
GuiHandSelf(CardSelector* cs, MTGHand* hand);
|
||||||
|
virtual int receiveEventPlus(WEvent* e);
|
||||||
|
virtual int receiveEventMinus(WEvent* e);
|
||||||
|
|
||||||
|
bool CheckUserInput(u32 key);
|
||||||
|
virtual void Render();
|
||||||
|
float LeftBoundary();
|
||||||
|
|
||||||
|
HandLimitor* limitor;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _GUIHAND_H_
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
#include "string.h"
|
||||||
|
#include <vector>
|
||||||
|
#include <hge/hgeparticle.h>
|
||||||
|
#include "config.h"
|
||||||
|
#include "JGE.h"
|
||||||
|
#include "MTGDefinitions.h"
|
||||||
|
#include "GameApp.h"
|
||||||
|
#include "GuiLayers.h"
|
||||||
|
|
||||||
|
class ManaIcon : public Pos
|
||||||
|
{
|
||||||
|
static const float DESTX;
|
||||||
|
static const float DESTY;
|
||||||
|
|
||||||
|
hgeParticleSystem* particleSys;
|
||||||
|
JQuad* icon;
|
||||||
|
|
||||||
|
float zoomP1, zoomP2, zoomP3, zoomP4, zoomP5, zoomP6;
|
||||||
|
float xP1, xP2, xP3;
|
||||||
|
float yP1, yP2, yP3;
|
||||||
|
float tP1;
|
||||||
|
float f;
|
||||||
|
public:
|
||||||
|
enum { ALIVE, WITHERING, DROPPING, DEAD } mode;
|
||||||
|
int color;
|
||||||
|
void Render();
|
||||||
|
void Update(float dt);
|
||||||
|
void Wither();
|
||||||
|
void Drop();
|
||||||
|
ManaIcon(int color, float x, float y);
|
||||||
|
~ManaIcon();
|
||||||
|
};
|
||||||
|
|
||||||
|
class GuiMana : public GuiLayer
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
vector<ManaIcon*> manas;
|
||||||
|
public:
|
||||||
|
GuiMana();
|
||||||
|
virtual void Render();
|
||||||
|
virtual void Update(float dt);
|
||||||
|
virtual int receiveEventPlus(WEvent * e);
|
||||||
|
virtual int receiveEventMinus(WEvent * e);
|
||||||
|
};
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
#ifndef _GUIPLAY_H_
|
||||||
|
#define _GUIPLAY_H_
|
||||||
|
|
||||||
|
#include "GuiLayers.h"
|
||||||
|
#include "CardGui.h"
|
||||||
|
|
||||||
|
class GuiPlay : public GuiLayer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static const float HORZWIDTH = 300.0f;
|
||||||
|
static const float VERTHEIGHT = 80.0f;
|
||||||
|
typedef vector<CardView*>::iterator iterator;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
class CardStack {
|
||||||
|
protected:
|
||||||
|
float baseX, baseY;
|
||||||
|
float x, y;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void reset(float x, float y);
|
||||||
|
void Enstack(CardView*);
|
||||||
|
void RenderSpell(MTGCardInstance*, iterator begin, iterator end, float x, float y);
|
||||||
|
};
|
||||||
|
|
||||||
|
class HorzStack : public CardStack {
|
||||||
|
protected:
|
||||||
|
const float maxWidth;
|
||||||
|
float maxHeight;
|
||||||
|
public:
|
||||||
|
HorzStack(float width = HORZWIDTH);
|
||||||
|
void reset(float x, float y);
|
||||||
|
void Render(CardView*, iterator begin, iterator end);
|
||||||
|
void Enstack(CardView*);
|
||||||
|
};
|
||||||
|
class VertStack : public CardStack {
|
||||||
|
protected:
|
||||||
|
float maxHeight;
|
||||||
|
public:
|
||||||
|
VertStack(float height = VERTHEIGHT);
|
||||||
|
void Enstack(CardView*);
|
||||||
|
inline float nextX();
|
||||||
|
};
|
||||||
|
class BattleField : public HorzStack {
|
||||||
|
static const float HEIGHT;
|
||||||
|
unsigned attackers;
|
||||||
|
unsigned blockers;
|
||||||
|
unsigned currentAttacker;
|
||||||
|
float height;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void addAttacker(MTGCardInstance*);
|
||||||
|
void removeAttacker(MTGCardInstance*);
|
||||||
|
void reset(float x, float y);
|
||||||
|
BattleField(float width = HORZWIDTH);
|
||||||
|
void EnstackAttacker(CardView*);
|
||||||
|
void EnstackBlocker(CardView*);
|
||||||
|
void Update(float dt);
|
||||||
|
void Render();
|
||||||
|
};
|
||||||
|
|
||||||
|
class Lands : public HorzStack {};
|
||||||
|
class Creatures : public HorzStack {};
|
||||||
|
class Spells : public VertStack {};
|
||||||
|
|
||||||
|
protected:
|
||||||
|
GameObserver* game;
|
||||||
|
Creatures selfCreatures, opponentCreatures;
|
||||||
|
BattleField battleField;
|
||||||
|
Lands selfLands, opponentLands;
|
||||||
|
Spells selfSpells, opponentSpells;
|
||||||
|
CardSelector* cs;
|
||||||
|
iterator end_spells;
|
||||||
|
|
||||||
|
vector<CardView*> cards;
|
||||||
|
|
||||||
|
public:
|
||||||
|
GuiPlay(GameObserver*, CardSelector*);
|
||||||
|
~GuiPlay();
|
||||||
|
virtual void Render();
|
||||||
|
void Replace();
|
||||||
|
void Update(float dt);
|
||||||
|
virtual int receiveEventPlus(WEvent * e);
|
||||||
|
virtual int receiveEventMinus(WEvent * e);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _GUIPLAY_H_
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
#ifndef _GUISTATIC_H_
|
||||||
|
#define _GUISTATIC_H_
|
||||||
|
|
||||||
|
#include "Player.h"
|
||||||
|
#include "MTGGameZones.h"
|
||||||
|
#include "CardDisplay.h"
|
||||||
|
#include "CardGui.h"
|
||||||
|
#include "GuiAvatars.h"
|
||||||
|
|
||||||
|
class TransientCardView;
|
||||||
|
|
||||||
|
struct GuiStatic : public PlayGuiObject{
|
||||||
|
GuiAvatars* parent;
|
||||||
|
GuiStatic(float desiredHeight, float x, float y, bool hasFocus, GuiAvatars* parent);
|
||||||
|
virtual void Entering();
|
||||||
|
virtual bool Leaving(u32 key);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct GuiAvatar : public GuiStatic{
|
||||||
|
typedef enum { TOP_LEFT, BOTTOM_RIGHT } Corner;
|
||||||
|
static const unsigned Width = 35;
|
||||||
|
static const unsigned Height = 50;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int avatarRed;
|
||||||
|
int currentLife;
|
||||||
|
Corner corner;
|
||||||
|
public:
|
||||||
|
Player * player;
|
||||||
|
virtual void Render();
|
||||||
|
GuiAvatar(float x, float y, bool hasFocus, Player * player, Corner corner, GuiAvatars* parent);
|
||||||
|
virtual ostream& toString(ostream& out) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct GuiGameZone : public GuiStatic{
|
||||||
|
static const int Width = 20;
|
||||||
|
static const int Height = 25;
|
||||||
|
vector<TransientCardView*> cards;
|
||||||
|
|
||||||
|
public:
|
||||||
|
MTGGameZone * zone;
|
||||||
|
CardDisplay * cd;
|
||||||
|
int showCards;
|
||||||
|
virtual void Render();
|
||||||
|
virtual void Update(float dt);
|
||||||
|
GuiGameZone(float x, float y, bool hasFocus, MTGGameZone * zone, GuiAvatars* parent);
|
||||||
|
~GuiGameZone();
|
||||||
|
virtual void ButtonPressed(int controllerId, int controlId);
|
||||||
|
void toggleDisplay();
|
||||||
|
virtual ostream& toString(ostream& out) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
class GuiGraveyard: public GuiGameZone{
|
||||||
|
public:
|
||||||
|
Player * player;
|
||||||
|
GuiGraveyard(float _x, float _y, bool hasFocus, Player * player, GuiAvatars* parent);
|
||||||
|
int receiveEventPlus(WEvent*);
|
||||||
|
int receiveEventMinus(WEvent*);
|
||||||
|
virtual ostream& toString(ostream& out) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
class GuiLibrary: public GuiGameZone{
|
||||||
|
public:
|
||||||
|
Player * player;
|
||||||
|
GuiLibrary(float _x, float _y, bool hasFocus, Player * player, GuiAvatars* parent);
|
||||||
|
virtual ostream& toString(ostream& out) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _GUISTATIC_H_
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#ifndef _OSD_H_
|
||||||
|
#define _OSD_H_
|
||||||
|
|
||||||
|
class OSDLayer : public PlayGuiObjectController
|
||||||
|
{
|
||||||
|
virtual void Update(float dt);
|
||||||
|
virtual bool CheckUserInput(u32 key);
|
||||||
|
virtual void Render();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef _POS_H_
|
||||||
|
#define _POS_H_
|
||||||
|
|
||||||
|
#include "JGE.h"
|
||||||
|
|
||||||
|
struct Pos {
|
||||||
|
float actX, actY, actZ, actT, actA;
|
||||||
|
float x, y, zoom, t, alpha;
|
||||||
|
Pos(float, float, float, float, float);
|
||||||
|
virtual void Update(float dt);
|
||||||
|
virtual void Render();
|
||||||
|
void Render(JQuad*);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _POS_H_
|
||||||
@@ -0,0 +1,160 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include "../include/PlayGuiObject.h"
|
||||||
|
#include "../include/CardGui.h"
|
||||||
|
#include "../include/CardSelector.h"
|
||||||
|
#include "../include/GuiHand.h"
|
||||||
|
|
||||||
|
using std::cout;
|
||||||
|
|
||||||
|
#define closest(src, expr) \
|
||||||
|
{ \
|
||||||
|
float curdist = 1000000.0f; /* This is bigger than any possible distance */ \
|
||||||
|
for (vector<Target*>::iterator it = cards.begin(); it != cards.end(); ++it) \
|
||||||
|
{ \
|
||||||
|
if (!(expr)) continue; \
|
||||||
|
if ((*it)->actA < 32) continue; \
|
||||||
|
if ((NULL != limitor) && (!limitor->select(*it))) continue; \
|
||||||
|
if (active) \
|
||||||
|
{ \
|
||||||
|
float dist = ((*it)->x - active->x) * ((*it)->x - active->x) + \
|
||||||
|
((*it)->y - active->y) * ((*it)->y - active->y); \
|
||||||
|
if (dist < curdist) \
|
||||||
|
{ \
|
||||||
|
curdist = dist; \
|
||||||
|
card = *it; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
card = *it; \
|
||||||
|
} \
|
||||||
|
{ CardView* c = dynamic_cast<CardView*>(active); if (c) c->zoom = 1.0; } \
|
||||||
|
active = card; \
|
||||||
|
{ CardView* c = dynamic_cast<CardView*>(active); if (c) c->zoom = 1.4; } \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<>
|
||||||
|
CardSelector::ObjectSelector(DuelLayers* duel) : active(NULL), showBig(true), duel(duel), limitor(NULL), bigpos(300, 150, 1.0, 0.0, 220) {}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
void CardSelector::Add(CardSelector::Target* target)
|
||||||
|
{
|
||||||
|
if (NULL == active)
|
||||||
|
if (NULL == limitor || limitor->select(active))
|
||||||
|
active = target;
|
||||||
|
CardView* c = dynamic_cast<CardView*>(target);
|
||||||
|
if (c) c->zoom = 1.0;
|
||||||
|
c = dynamic_cast<CardView*>(active);
|
||||||
|
if (c) c->zoom = 1.4;
|
||||||
|
cards.push_back(target);
|
||||||
|
}
|
||||||
|
template<>
|
||||||
|
void CardSelector::Remove(CardSelector::Target* card)
|
||||||
|
{
|
||||||
|
for (vector<Target*>::iterator it = cards.begin(); it != cards.end(); ++it)
|
||||||
|
{
|
||||||
|
if (card == *it)
|
||||||
|
{
|
||||||
|
if (active == *it)
|
||||||
|
{
|
||||||
|
CardView* c = dynamic_cast<CardView*>(active); if (c) c->zoom = 1.0;
|
||||||
|
closest(active, active != (*it));
|
||||||
|
c = dynamic_cast<CardView*>(active); if (c) c->zoom = 1.4;
|
||||||
|
}
|
||||||
|
if (active == *it) active = NULL;
|
||||||
|
cards.erase(it);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
bool CardSelector::CheckUserInput(u32 key)
|
||||||
|
{
|
||||||
|
if (!active)
|
||||||
|
{
|
||||||
|
for (vector<Target*>::iterator it = cards.begin(); it != cards.end(); ++it)
|
||||||
|
if ((NULL == limitor) || (limitor->select(*it)))
|
||||||
|
{
|
||||||
|
active = *it;
|
||||||
|
active->Entering();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Target* oldactive = active;
|
||||||
|
Target* card = active;
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case PSP_CTRL_CIRCLE:
|
||||||
|
GameObserver::GetInstance()->ButtonPressed(active);
|
||||||
|
break;
|
||||||
|
case PSP_CTRL_LEFT:
|
||||||
|
closest(active, (
|
||||||
|
active->x - (*it)->x > fabs(active->y - (*it)->y)
|
||||||
|
));
|
||||||
|
if (active != oldactive) { oldactive->Leaving(key); active->Entering(); }
|
||||||
|
break;
|
||||||
|
case PSP_CTRL_RIGHT:
|
||||||
|
closest(active, (
|
||||||
|
(*it)->x - active->x > fabs(active->y - (*it)->y)
|
||||||
|
));
|
||||||
|
if (active != oldactive) { oldactive->Leaving(key); active->Entering(); }
|
||||||
|
break;
|
||||||
|
case PSP_CTRL_UP:
|
||||||
|
closest(active, (
|
||||||
|
active->y - (*it)->y > fabs(active->x - (*it)->x)
|
||||||
|
));
|
||||||
|
if (active != oldactive) { oldactive->Leaving(key); active->Entering(); }
|
||||||
|
break;
|
||||||
|
case PSP_CTRL_DOWN:
|
||||||
|
closest(active, (
|
||||||
|
(*it)->y - active->y > fabs(active->x - (*it)->x)
|
||||||
|
));
|
||||||
|
if (active != oldactive) { oldactive->Leaving(key); active->Entering(); }
|
||||||
|
break;
|
||||||
|
case PSP_CTRL_LTRIGGER:
|
||||||
|
showBig = !showBig;
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
void CardSelector::Update(float dt)
|
||||||
|
{
|
||||||
|
float boundary = duel->RightBoundary();
|
||||||
|
float position = boundary - CardGui::BigWidth / 2;
|
||||||
|
if (CardView* c = dynamic_cast<CardView*>(active))
|
||||||
|
if ((c->x + CardGui::Width / 2 > position - CardGui::BigWidth / 2) &&
|
||||||
|
(c->x - CardGui::Width / 2 < position + CardGui::BigWidth / 2))
|
||||||
|
position = CardGui::BigWidth / 2 - 10;
|
||||||
|
bigpos.x = position;
|
||||||
|
bigpos.Update(dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
void CardSelector::Render()
|
||||||
|
{
|
||||||
|
if (active)
|
||||||
|
{
|
||||||
|
active->Render();
|
||||||
|
if (CardView* c = dynamic_cast<CardView*>(active))
|
||||||
|
if (showBig)
|
||||||
|
c->RenderBig(bigpos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
void CardSelector::Limit(LimitorFunctor<Target>* limitor)
|
||||||
|
{
|
||||||
|
this->limitor = limitor;
|
||||||
|
if (limitor && !limitor->select(active))
|
||||||
|
{
|
||||||
|
Target* card = NULL;
|
||||||
|
closest(active, true);
|
||||||
|
if (limitor && !limitor->select(active)) active = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
#include "../include/config.h"
|
||||||
|
#include "../include/GameApp.h"
|
||||||
|
#include "../include/GuiAvatars.h"
|
||||||
|
|
||||||
|
GuiAvatars::GuiAvatars(CardSelector* cs) : cs(cs), active(NULL)
|
||||||
|
{
|
||||||
|
Add(self = NEW GuiAvatar (SCREEN_WIDTH, SCREEN_HEIGHT, false,
|
||||||
|
GameObserver::GetInstance()->players[0], GuiAvatar::BOTTOM_RIGHT, this));
|
||||||
|
Add(selfGraveyard = NEW GuiGraveyard(SCREEN_WIDTH - GuiAvatar::Width - GuiGameZone::Width/2, SCREEN_HEIGHT - GuiAvatar::Height - 10, false,
|
||||||
|
GameObserver::GetInstance()->players[0], this));
|
||||||
|
Add(selfLibrary = NEW GuiLibrary (SCREEN_WIDTH - GuiAvatar::Width - GuiGameZone::Width/2, SCREEN_HEIGHT - GuiAvatar::Height - 10 + GuiGameZone::Height + 5, false,
|
||||||
|
GameObserver::GetInstance()->players[0], this));
|
||||||
|
|
||||||
|
Add(opponent = NEW GuiAvatar (0, 0, false, GameObserver::GetInstance()->players[1], GuiAvatar::TOP_LEFT, this));
|
||||||
|
Add(opponentGraveyard = NEW GuiGraveyard(GuiAvatar::Width - GuiGameZone::Width / 2, 5, false, GameObserver::GetInstance()->players[1], this));
|
||||||
|
Add(opponentLibrary = NEW GuiLibrary (GuiAvatar::Width - GuiGameZone::Width / 2, 5 + GuiGameZone::Height + 5, false, GameObserver::GetInstance()->players[1], this));
|
||||||
|
|
||||||
|
cs->Add(self); cs->Add(selfGraveyard); cs->Add(selfLibrary);
|
||||||
|
cs->Add(opponent); cs->Add(opponentGraveyard); cs->Add(opponentLibrary);
|
||||||
|
selfGraveyard->alpha = selfLibrary->alpha = opponentGraveyard->alpha = opponentLibrary->alpha = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiAvatars::~GuiAvatars()
|
||||||
|
{
|
||||||
|
cs->Remove(self); cs->Remove(selfGraveyard); cs->Remove(selfLibrary);
|
||||||
|
cs->Remove(opponent); cs->Remove(opponentGraveyard); cs->Remove(opponentLibrary);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiAvatars::Activate(PlayGuiObject* c)
|
||||||
|
{
|
||||||
|
if ((opponentGraveyard == c) || (opponentLibrary == c) || (opponent == c))
|
||||||
|
{ opponentGraveyard->alpha = opponentLibrary->alpha = 255; active = opponent; }
|
||||||
|
else if ((selfGraveyard == c) || (selfLibrary == c) || (self == c))
|
||||||
|
{ selfGraveyard->alpha = selfLibrary->alpha = 255; self->zoom = 1.0; active = self; }
|
||||||
|
}
|
||||||
|
void GuiAvatars::Deactivate(PlayGuiObject* c)
|
||||||
|
{
|
||||||
|
if ((opponentGraveyard == c) || (opponentLibrary == c) || (opponent == c))
|
||||||
|
{ opponentGraveyard->alpha = opponentLibrary->alpha = 0; }
|
||||||
|
else if ((selfGraveyard == c) || (selfLibrary == c) || (self == c))
|
||||||
|
{ selfGraveyard->alpha = selfLibrary->alpha = 0; self->zoom = 0.3; }
|
||||||
|
active = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GuiAvatars::receiveEventPlus(WEvent* e)
|
||||||
|
{
|
||||||
|
return selfGraveyard->receiveEventPlus(e) | opponentGraveyard->receiveEventPlus(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
int GuiAvatars::receiveEventMinus(WEvent* e)
|
||||||
|
{
|
||||||
|
selfGraveyard->receiveEventMinus(e);
|
||||||
|
opponentGraveyard->receiveEventMinus(e);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiAvatars::Update(float dt)
|
||||||
|
{
|
||||||
|
self->Update(dt);
|
||||||
|
opponent->Update(dt);
|
||||||
|
selfGraveyard->Update(dt);
|
||||||
|
opponentGraveyard->Update(dt);
|
||||||
|
selfLibrary->Update(dt);
|
||||||
|
opponentLibrary->Update(dt);
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
#include "../include/config.h"
|
||||||
|
#include "../include/GameApp.h"
|
||||||
|
#include "../include/GuiBackground.h"
|
||||||
|
|
||||||
|
GuiBackground::GuiBackground()
|
||||||
|
{
|
||||||
|
JTexture* texture = GameApp::CommonRes->GetTexture("graphics/back.jpg");
|
||||||
|
if (texture)
|
||||||
|
quad = NEW JQuad(texture, 0, 0, 480, 255);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
quad = NULL;
|
||||||
|
GameApp::systemError = "Error loading background texture : " __FILE__;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiBackground::~GuiBackground()
|
||||||
|
{
|
||||||
|
delete(quad);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiBackground::Render()
|
||||||
|
{
|
||||||
|
JRenderer* renderer = JRenderer::GetInstance();
|
||||||
|
renderer->RenderQuad(quad, 0, 18);
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
#include "../include/config.h"
|
||||||
|
#include "../include/GameApp.h"
|
||||||
|
#include "../include/GuiCombat.h"
|
||||||
|
|
||||||
|
GuiCombat::GuiCombat(CardSelector* cs) : GuiLayer(), cs(cs)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiCombat::~GuiCombat()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiCombat::Update(float dt)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GuiCombat::CheckUserInput(u32 key)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiCombat::Render()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int GuiCombat::receiveEventPlus(WEvent* e)
|
||||||
|
{
|
||||||
|
if (WEventCreatureAttacker* event = dynamic_cast<WEventCreatureAttacker*>(e))
|
||||||
|
{
|
||||||
|
if (NULL == event->after) return 0;
|
||||||
|
cout << "Attacker : " << event->card->name << event->before << " -> " << event->after << endl;
|
||||||
|
attackers.push_back(event->card);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if (WEventCreatureBlocker* event = dynamic_cast<WEventCreatureBlocker*>(e))
|
||||||
|
{
|
||||||
|
if (NULL == event->after) return 0;
|
||||||
|
cout << "Blocker : " << event->card->name << event->before << " -> " << event->after << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if (WEventCreatureBlockerRank* event = dynamic_cast<WEventCreatureBlockerRank*>(e))
|
||||||
|
{
|
||||||
|
cout << "Order : " << event->card->name << event->exchangeWith << " -> " << event->attacker << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int GuiCombat::receiveEventMinus(WEvent* e)
|
||||||
|
{
|
||||||
|
// (WEventZoneChange* event = dynamic_cast<WEventZoneChange*>(e)
|
||||||
|
if (WEventCreatureAttacker* event = dynamic_cast<WEventCreatureAttacker*>(e))
|
||||||
|
{
|
||||||
|
if (NULL == event->before) return 0;
|
||||||
|
vector<MTGCardInstance*>::iterator it = find(attackers.begin(), attackers.end(), event->card);
|
||||||
|
if (it != attackers.end())
|
||||||
|
attackers.erase(it);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
#include "../include/config.h"
|
||||||
|
#include "../include/GameApp.h"
|
||||||
|
#include "../include/GuiFrame.h"
|
||||||
|
|
||||||
|
GuiFrame::GuiFrame()
|
||||||
|
{
|
||||||
|
if (JTexture* woodTex = GameApp::CommonRes->GetTexture("graphics/wood.png"))
|
||||||
|
wood = NEW JQuad(woodTex, 0, 0, SCREEN_WIDTH, 16);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wood = NULL;
|
||||||
|
GameApp::systemError += "Can't load wood texture : " __FILE__ "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (JTexture* goldTex = GameApp::CommonRes->GetTexture("graphics/gold.png"))
|
||||||
|
{
|
||||||
|
gold1 = NEW JQuad(goldTex, 0, 0, SCREEN_WIDTH, 6);
|
||||||
|
gold2 = NEW JQuad(goldTex, 0, 6, SCREEN_WIDTH, 6);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gold1 = gold2 = NULL;
|
||||||
|
GameApp::systemError += "Can't load gold texture : " __FILE__ "\n";
|
||||||
|
}
|
||||||
|
if (JTexture* goldGlowTex = GameApp::CommonRes->GetTexture("graphics/goldglow.png"))
|
||||||
|
goldGlow = NEW JQuad(goldGlowTex, 0, 1, SCREEN_WIDTH, 18);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
goldGlow = NULL;
|
||||||
|
GameApp::systemError += "Can't load gold glow texture : " __FILE__ "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
step = 0.0;
|
||||||
|
|
||||||
|
gold2->SetColor(ARGB(127, 255, 255, 255));
|
||||||
|
gold2->SetHFlip(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiFrame::~GuiFrame()
|
||||||
|
{
|
||||||
|
delete(gold2);
|
||||||
|
delete(gold1);
|
||||||
|
delete(wood);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiFrame::Render()
|
||||||
|
{
|
||||||
|
JRenderer* renderer = JRenderer::GetInstance();
|
||||||
|
float sized = step; if (sized > SCREEN_WIDTH) sized -= SCREEN_WIDTH;
|
||||||
|
renderer->RenderQuad(wood, 0, 0);
|
||||||
|
renderer->RenderQuad(gold1, -sized, 16);
|
||||||
|
renderer->RenderQuad(gold1, -sized + 479, 16);
|
||||||
|
|
||||||
|
goldGlow->SetColor(ARGB(100+(random()%50), 255, 255, 255));
|
||||||
|
renderer->RenderQuad(goldGlow, -sized, 9);
|
||||||
|
renderer->RenderQuad(goldGlow, -sized + 480, 9);
|
||||||
|
|
||||||
|
renderer->RenderQuad(gold2, step / 2, 16);
|
||||||
|
renderer->RenderQuad(gold2, step / 2 - 479, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiFrame::Update(float dt)
|
||||||
|
{
|
||||||
|
step += dt * 5;
|
||||||
|
if (step > 2*SCREEN_WIDTH) step -= 2*SCREEN_WIDTH;
|
||||||
|
}
|
||||||
@@ -0,0 +1,191 @@
|
|||||||
|
#include "../include/config.h"
|
||||||
|
#include "../include/GameApp.h"
|
||||||
|
#include "../include/GuiHand.h"
|
||||||
|
|
||||||
|
bool HandLimitor::select(Target* t)
|
||||||
|
{
|
||||||
|
vector<CardView*>::iterator it;
|
||||||
|
it = find(hand->cards.begin(), hand->cards.end(), t);
|
||||||
|
return (it != hand->cards.end());
|
||||||
|
}
|
||||||
|
bool HandLimitor::greyout(Target* t)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
HandLimitor::HandLimitor(GuiHand* hand) : hand(hand) {}
|
||||||
|
|
||||||
|
GuiHand::GuiHand(CardSelector* cs, MTGHand* hand) : GuiLayer(), hand(hand), cs(cs)
|
||||||
|
{
|
||||||
|
JTexture* texture = GameApp::CommonRes->GetTexture("graphics/handback.png");
|
||||||
|
if (texture)
|
||||||
|
{
|
||||||
|
back = NEW JQuad(texture, 0, 0, 101, 250);
|
||||||
|
back->SetTextureRect(1, 0, 100, 250);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
back = NULL;
|
||||||
|
GameApp::systemError = "Error loading hand texture : " __FILE__;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiHand::~GuiHand()
|
||||||
|
{
|
||||||
|
delete(back);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiHand::Update(float dt)
|
||||||
|
{
|
||||||
|
for (vector<CardView*>::iterator it = cards.begin(); it != cards.end(); ++it)
|
||||||
|
(*it)->Update(dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiHandOpponent::GuiHandOpponent(CardSelector* cs, MTGHand* hand) : GuiHand(cs, hand) {}
|
||||||
|
|
||||||
|
void GuiHandOpponent::Render()
|
||||||
|
{
|
||||||
|
JQuad * quad = GameApp::CommonRes->GetQuad("back_thumb");
|
||||||
|
|
||||||
|
float x = 45;
|
||||||
|
for (vector<CardView*>::iterator it = cards.begin(); it != cards.end(); ++it)
|
||||||
|
{
|
||||||
|
(*it)->x = x;
|
||||||
|
(*it)->y = 2;
|
||||||
|
(*it)->zoom = 0.3;
|
||||||
|
(*it)->Render(quad);
|
||||||
|
x += 18;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiHandSelf::GuiHandSelf(CardSelector* cs, MTGHand* hand) : GuiHand(cs, hand), state(Closed), backpos(ClosedX)
|
||||||
|
{
|
||||||
|
limitor = new HandLimitor(this);
|
||||||
|
}
|
||||||
|
bool GuiHandSelf::CheckUserInput(u32 key)
|
||||||
|
{
|
||||||
|
//u32 trigger = options[REVERSE_TRIGGERS];
|
||||||
|
u32 trigger = PSP_CTRL_LTRIGGER;
|
||||||
|
if (trigger == key)
|
||||||
|
{
|
||||||
|
state = (Open == state ? Closed : Open);
|
||||||
|
cs->Limit(Open == state ? limitor : NULL);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiHandSelf::Render()
|
||||||
|
{
|
||||||
|
if (Closed == state)
|
||||||
|
{
|
||||||
|
backpos += (ClosedX - backpos) / 100;
|
||||||
|
JRenderer::GetInstance()->RenderQuad(back, backpos, SCREEN_HEIGHT - 250);
|
||||||
|
float y = 48.0;
|
||||||
|
for (vector<CardView*>::iterator it = cards.begin(); it != cards.end(); ++it)
|
||||||
|
{
|
||||||
|
(*it)->x += (ClosedRowX - (*it)->x) / 100;
|
||||||
|
(*it)->y += (y - (*it)->y) / 70;
|
||||||
|
(*it)->Render();
|
||||||
|
y += 20;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
backpos += (OpenX - backpos) / 100;
|
||||||
|
JRenderer::GetInstance()->RenderQuad(back, backpos, SCREEN_HEIGHT - 250);
|
||||||
|
bool flip = false;
|
||||||
|
float y = 48.0;
|
||||||
|
for (vector<CardView*>::iterator it = cards.begin(); it != cards.end(); ++it)
|
||||||
|
{
|
||||||
|
if (flip)
|
||||||
|
(*it)->x += (RightRowX - (*it)->x) / 100;
|
||||||
|
else
|
||||||
|
(*it)->x += (LeftRowX - (*it)->x) / 100;
|
||||||
|
// I wanna write it like that. GCC doesn't want me to without -O.
|
||||||
|
// I'm submitting a bug report.
|
||||||
|
// it->x = (it->x + (flip ? RightRowX : LeftRowX)) / 2;
|
||||||
|
(*it)->y += (y - (*it)->y) / 70;
|
||||||
|
(*it)->Render();
|
||||||
|
if (flip) y += 65;
|
||||||
|
flip = !flip;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float GuiHandSelf::LeftBoundary()
|
||||||
|
{
|
||||||
|
float min = SCREEN_WIDTH + 10;
|
||||||
|
for (vector<CardView*>::iterator it = cards.begin(); it != cards.end(); ++it)
|
||||||
|
if ((*it)->x - CardGui::Width / 2 < min) min = (*it)->x - CardGui::Width / 2;
|
||||||
|
return min;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GuiHandSelf::receiveEventPlus(WEvent* e)
|
||||||
|
{
|
||||||
|
if (WEventZoneChange* event = dynamic_cast<WEventZoneChange*>(e))
|
||||||
|
if (hand == event->to)
|
||||||
|
{
|
||||||
|
CardView* card;
|
||||||
|
if (event->card->view)
|
||||||
|
card = NEW CardView(event->card, *(event->card->view));
|
||||||
|
else
|
||||||
|
card = NEW CardView(event->card, ClosedRowX, 0);
|
||||||
|
card->t = 6*M_PI;
|
||||||
|
cards.push_back(card);
|
||||||
|
cs->Add(card);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int GuiHandSelf::receiveEventMinus(WEvent* e)
|
||||||
|
{
|
||||||
|
if (WEventZoneChange* event = dynamic_cast<WEventZoneChange*>(e))
|
||||||
|
{
|
||||||
|
if (hand == event->from)
|
||||||
|
for (vector<CardView*>::iterator it = cards.begin(); it != cards.end(); ++it)
|
||||||
|
if (event->card->previous == (*it)->card)
|
||||||
|
{
|
||||||
|
CardView* cv = *it;
|
||||||
|
cs->Remove(cv);
|
||||||
|
cards.erase(it);
|
||||||
|
delete cv;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GuiHandOpponent::receiveEventPlus(WEvent* e)
|
||||||
|
{
|
||||||
|
if (WEventZoneChange* event = dynamic_cast<WEventZoneChange*>(e))
|
||||||
|
if (hand == event->to)
|
||||||
|
{
|
||||||
|
CardView* card;
|
||||||
|
if (event->card->view)
|
||||||
|
card = NEW CardView(event->card, *(event->card->view));
|
||||||
|
else
|
||||||
|
card = NEW CardView(event->card, ClosedRowX, 0);
|
||||||
|
card->t = -4*M_PI;
|
||||||
|
cards.push_back(card);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int GuiHandOpponent::receiveEventMinus(WEvent* e)
|
||||||
|
{
|
||||||
|
if (WEventZoneChange* event = dynamic_cast<WEventZoneChange*>(e))
|
||||||
|
{
|
||||||
|
if (hand == event->from)
|
||||||
|
for (vector<CardView*>::iterator it = cards.begin(); it != cards.end(); ++it)
|
||||||
|
if (event->card->previous == (*it)->card)
|
||||||
|
{
|
||||||
|
CardView* cv = *it;
|
||||||
|
cards.erase(it);
|
||||||
|
delete cv;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include "../include/GuiMana.h"
|
||||||
|
|
||||||
|
using std::cout;
|
||||||
|
using std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
const float ManaIcon::DESTX = 440;
|
||||||
|
const float ManaIcon::DESTY = 20;
|
||||||
|
|
||||||
|
ManaIcon::ManaIcon(int color, float x, float y) : Pos(x, y, 0.5, 0.0, 255), f(-1), mode(ALIVE), color(color)
|
||||||
|
{
|
||||||
|
switch (color)
|
||||||
|
{
|
||||||
|
case Constants::MTG_COLOR_RED :
|
||||||
|
particleSys = NEW hgeParticleSystem("graphics/manared.psi", GameApp::CommonRes->GetQuad("stars"));
|
||||||
|
break;
|
||||||
|
case Constants::MTG_COLOR_BLUE :
|
||||||
|
particleSys = NEW hgeParticleSystem("graphics/manablue.psi", GameApp::CommonRes->GetQuad("stars"));
|
||||||
|
break;
|
||||||
|
case Constants::MTG_COLOR_GREEN :
|
||||||
|
particleSys = NEW hgeParticleSystem("graphics/managreen.psi", GameApp::CommonRes->GetQuad("stars"));
|
||||||
|
break;
|
||||||
|
case Constants::MTG_COLOR_BLACK :
|
||||||
|
particleSys = NEW hgeParticleSystem("graphics/manablack.psi", GameApp::CommonRes->GetQuad("stars"));
|
||||||
|
break;
|
||||||
|
case Constants::MTG_COLOR_WHITE :
|
||||||
|
particleSys = NEW hgeParticleSystem("graphics/manawhite.psi", GameApp::CommonRes->GetQuad("stars"));
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
particleSys = NEW hgeParticleSystem("graphics/mana.psi", GameApp::CommonRes->GetQuad("stars"));
|
||||||
|
}
|
||||||
|
icon = manaIcons[color];
|
||||||
|
|
||||||
|
particleSys->FireAt(x, y);
|
||||||
|
|
||||||
|
zoomP1 = 0.2 + 0.1 * drand48();
|
||||||
|
zoomP2 = 0.2 + 0.1 * drand48();
|
||||||
|
zoomP3 = 2 * M_PI * drand48();
|
||||||
|
zoomP4 = 2 * M_PI * drand48();
|
||||||
|
zoomP5 = 0.5 + drand48();
|
||||||
|
zoomP6 = 0.5 + drand48();
|
||||||
|
|
||||||
|
xP1 = 2 * M_PI * drand48();
|
||||||
|
xP2 = 5 + 30 * drand48();
|
||||||
|
xP3 = 0.5 + drand48();
|
||||||
|
yP1 = 2 * M_PI * drand48();
|
||||||
|
yP2 = 5 + 10 * drand48();
|
||||||
|
yP3 = 0.5 + drand48();
|
||||||
|
|
||||||
|
actT = 0;
|
||||||
|
tP1 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ManaIcon::~ManaIcon()
|
||||||
|
{
|
||||||
|
SAFE_DELETE(particleSys);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ManaIcon::Render()
|
||||||
|
{
|
||||||
|
JRenderer* renderer = JRenderer::GetInstance();
|
||||||
|
|
||||||
|
renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE);
|
||||||
|
particleSys->Render();
|
||||||
|
renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);
|
||||||
|
renderer->RenderQuad(icon, actX, actY, actT, actZ + zoomP1 * sinf(M_PI * zoomP3), actZ + zoomP2 * cosf(M_PI * zoomP4));
|
||||||
|
}
|
||||||
|
void ManaIcon::Update(float dt)
|
||||||
|
{
|
||||||
|
xP1 += xP3 * dt;
|
||||||
|
actX = x + xP2 * sinf(M_PI * xP1);
|
||||||
|
zoomP3 += zoomP5 * dt;
|
||||||
|
zoomP4 += zoomP6 * dt;
|
||||||
|
|
||||||
|
switch (mode)
|
||||||
|
{
|
||||||
|
case DROPPING :
|
||||||
|
f += dt * 700;
|
||||||
|
actY += f * dt;
|
||||||
|
if (actY > SCREEN_HEIGHT * 2) mode = DEAD;
|
||||||
|
break;
|
||||||
|
case WITHERING :
|
||||||
|
actT += dt * 4;
|
||||||
|
actZ /= f; zoomP1 /= f; zoomP2 /= f;
|
||||||
|
f -= dt;
|
||||||
|
actZ *= f; zoomP1 *= f; zoomP2 *= f;
|
||||||
|
yP1 += yP3 * dt;
|
||||||
|
actY = y + yP2 * sinf(M_PI * yP1);
|
||||||
|
if (f < 0) mode = DEAD;
|
||||||
|
break;
|
||||||
|
case ALIVE :
|
||||||
|
x += 10 * dt * (DESTX - x);
|
||||||
|
y += 10 * dt * (DESTY - y);
|
||||||
|
yP1 += yP3 * dt;
|
||||||
|
actY = y + yP2 * sinf(M_PI * yP1);
|
||||||
|
break;
|
||||||
|
case DEAD :
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
particleSys->MoveTo(actX, actY);
|
||||||
|
particleSys->Update(dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ManaIcon::Wither()
|
||||||
|
{
|
||||||
|
mode = WITHERING;
|
||||||
|
f = 1.0;
|
||||||
|
particleSys->Stop();
|
||||||
|
}
|
||||||
|
void ManaIcon::Drop()
|
||||||
|
{
|
||||||
|
mode = DROPPING;
|
||||||
|
if (f < 0) f = 0;
|
||||||
|
particleSys->Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiMana::GuiMana()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiMana::Render()
|
||||||
|
{
|
||||||
|
for (vector<ManaIcon*>::iterator it = manas.begin(); it != manas.end(); ++it)
|
||||||
|
(*it)->Render();
|
||||||
|
}
|
||||||
|
bool remove_dead(ManaIcon* m) { return ManaIcon::DEAD != m->mode; }
|
||||||
|
void GuiMana::Update(float dt)
|
||||||
|
{
|
||||||
|
for (vector<ManaIcon*>::iterator it = manas.begin(); it != manas.end(); ++it)
|
||||||
|
(*it)->Update(dt);
|
||||||
|
vector<ManaIcon*>::iterator it = partition(manas.begin(), manas.end(), &remove_dead);
|
||||||
|
if (it != manas.end())
|
||||||
|
{
|
||||||
|
for (vector<ManaIcon*>::iterator q = it; q != manas.end(); ++q)
|
||||||
|
SAFE_DELETE(*q);
|
||||||
|
manas.erase(it, manas.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int GuiMana::receiveEventPlus(WEvent* e)
|
||||||
|
{
|
||||||
|
if (WEventEngageMana *event = dynamic_cast<WEventEngageMana*>(e))
|
||||||
|
{
|
||||||
|
if (event->card->view)
|
||||||
|
manas.push_back(NEW ManaIcon(event->color, event->card->view->actX, event->card->view->actY));
|
||||||
|
else
|
||||||
|
manas.push_back(NEW ManaIcon(event->color, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GuiMana::receiveEventMinus(WEvent* e)
|
||||||
|
{
|
||||||
|
if (WEventConsumeMana *event = dynamic_cast<WEventConsumeMana*>(e))
|
||||||
|
{
|
||||||
|
for (vector<ManaIcon*>::iterator it = manas.begin(); it != manas.end(); ++it)
|
||||||
|
if (event->color == (*it)->color) { (*it)->Wither(); return 1; }
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if (WEventPhaseChange *event = dynamic_cast<WEventPhaseChange*>(e))
|
||||||
|
{
|
||||||
|
for (vector<ManaIcon*>::iterator it = manas.begin(); it != manas.end(); ++it)
|
||||||
|
(*it)->Drop();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,222 @@
|
|||||||
|
#include "../include/config.h"
|
||||||
|
#include "../include/GameApp.h"
|
||||||
|
#include "../include/GuiPlay.h"
|
||||||
|
|
||||||
|
#define CARD_WIDTH (31)
|
||||||
|
|
||||||
|
void GuiPlay::CardStack::reset(float x, float y)
|
||||||
|
{
|
||||||
|
this->x = 0; baseX = x;
|
||||||
|
this->y = 0; baseY = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiPlay::CardStack::RenderSpell(MTGCardInstance* card, iterator begin, iterator end, float x, float y)
|
||||||
|
{
|
||||||
|
while (begin != end)
|
||||||
|
{
|
||||||
|
if ((*begin)->card->target == card)
|
||||||
|
{
|
||||||
|
RenderSpell(card, begin+1, end, x, y - 10);
|
||||||
|
(*begin)->x = x; (*begin)->y = y;
|
||||||
|
(*begin)->Render();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
++begin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiPlay::HorzStack::HorzStack(float width) : maxWidth(width) {}
|
||||||
|
GuiPlay::VertStack::VertStack(float height) : maxHeight(height) {}
|
||||||
|
|
||||||
|
void GuiPlay::HorzStack::reset(float x, float y)
|
||||||
|
{
|
||||||
|
GuiPlay::CardStack::reset(x, y);
|
||||||
|
maxHeight = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiPlay::HorzStack::Render(CardView* card, iterator begin, iterator end)
|
||||||
|
{
|
||||||
|
RenderSpell(card->card, begin, end, card->x, card->y - 10);
|
||||||
|
card->Render();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiPlay::HorzStack::Enstack(CardView* card)
|
||||||
|
{
|
||||||
|
card->x = x + baseX; card->y = y + baseY;
|
||||||
|
x += CARD_WIDTH;
|
||||||
|
if (maxHeight < card->mHeight) maxHeight = card->mHeight;
|
||||||
|
if (x > maxWidth) { x = 0; y += maxHeight + 2; maxHeight = 0; }
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiPlay::VertStack::Enstack(CardView* card)
|
||||||
|
{
|
||||||
|
if (y > maxHeight) x += CARD_WIDTH;
|
||||||
|
card->x = x + baseX; card->y = y + baseY;
|
||||||
|
y += 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float GuiPlay::VertStack::nextX() { return x + CARD_WIDTH; }
|
||||||
|
|
||||||
|
GuiPlay::BattleField::BattleField(float width) : HorzStack(width), attackers(0), blockers(0), height(0.0) {}
|
||||||
|
const float GuiPlay::BattleField::HEIGHT = 80.0f;
|
||||||
|
void GuiPlay::BattleField::addAttacker(MTGCardInstance*) { ++attackers; }
|
||||||
|
void GuiPlay::BattleField::removeAttacker(MTGCardInstance*) { --attackers; }
|
||||||
|
void GuiPlay::BattleField::reset(float x, float y) { HorzStack::reset(x, y); currentAttacker = 1; }
|
||||||
|
void GuiPlay::BattleField::EnstackAttacker(CardView* card)
|
||||||
|
{
|
||||||
|
GameObserver* game = GameObserver::GetInstance();
|
||||||
|
card->x = currentAttacker * (HORZWIDTH-20) / (attackers + 1); card->y = baseY + (game->players[0] == card->card->controller() ? 20 + y : -20 - y);
|
||||||
|
++currentAttacker;
|
||||||
|
// JRenderer::GetInstance()->RenderQuad(GameApp::CommonRes->GetQuad("BattleIcon"), card->actX, card->actY, 0, 0.5 + 0.1 * sinf(JGE::GetInstance()->GetTime()), 0.5 + 0.1 * sinf(JGE::GetInstance()->GetTime()));
|
||||||
|
}
|
||||||
|
void GuiPlay::BattleField::EnstackBlocker(CardView* card)
|
||||||
|
{
|
||||||
|
GameObserver* game = GameObserver::GetInstance();
|
||||||
|
card->x = card->card->defenser->view->x; card->y = baseY + (game->players[0] == card->card->controller() ? 20 + y : -20 - y);
|
||||||
|
}
|
||||||
|
void GuiPlay::BattleField::Update(float dt)
|
||||||
|
{
|
||||||
|
if (0 == attackers)
|
||||||
|
height -= 10 * dt * height;
|
||||||
|
else
|
||||||
|
height += 10 * dt * (HEIGHT - height);
|
||||||
|
}
|
||||||
|
void GuiPlay::BattleField::Render()
|
||||||
|
{
|
||||||
|
if (height > 3)
|
||||||
|
JRenderer::GetInstance()->FillRect(22, SCREEN_HEIGHT / 2 + 10 - height / 2, 250, height, ARGB(127, 0, 0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiPlay::GuiPlay(GameObserver* game, CardSelector* cs) : game(game), cs(cs)
|
||||||
|
{
|
||||||
|
end_spells = cards.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiPlay::~GuiPlay()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isSpell(CardView* c) { return c->card->isSpell(); }
|
||||||
|
void GuiPlay::Replace()
|
||||||
|
{
|
||||||
|
opponentSpells.reset(18, 80);
|
||||||
|
selfSpells.reset(18, 200);
|
||||||
|
end_spells = stable_partition(cards.begin(), cards.end(), &isSpell);
|
||||||
|
|
||||||
|
for (iterator it = cards.begin(); it != end_spells; ++it)
|
||||||
|
if (!(*it)->card->target)
|
||||||
|
{
|
||||||
|
if (game->players[0] == (*it)->card->controller()) selfSpells.Enstack(*it);
|
||||||
|
else opponentSpells.Enstack(*it);
|
||||||
|
}
|
||||||
|
|
||||||
|
float x = 24 + MAX(opponentSpells.nextX(), selfSpells.nextX());
|
||||||
|
opponentLands.reset(x, 50);
|
||||||
|
opponentCreatures.reset(x, 95);
|
||||||
|
battleField.reset(x, 145);
|
||||||
|
selfCreatures.reset(x, 195);
|
||||||
|
selfLands.reset(x, 240);
|
||||||
|
|
||||||
|
for (iterator it = end_spells; it != cards.end(); ++it)
|
||||||
|
{
|
||||||
|
if ((*it)->card->isCreature())
|
||||||
|
{
|
||||||
|
if ((*it)->card->isAttacker()) battleField.EnstackAttacker(*it);
|
||||||
|
else if ((*it)->card->isDefenser()) battleField.EnstackBlocker(*it);
|
||||||
|
else if (game->players[0] == (*it)->card->controller()) selfCreatures.Enstack(*it);
|
||||||
|
else opponentCreatures.Enstack(*it);
|
||||||
|
}
|
||||||
|
else if ((*it)->card->isLand())
|
||||||
|
{
|
||||||
|
if (game->players[0] == (*it)->card->controller()) selfLands.Enstack(*it);
|
||||||
|
else opponentLands.Enstack(*it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiPlay::Render()
|
||||||
|
{
|
||||||
|
battleField.Render();
|
||||||
|
for (iterator it = cards.begin(); it != end_spells; ++it)
|
||||||
|
if (!(*it)->card->target)
|
||||||
|
(*it)->Render();
|
||||||
|
for (iterator it = end_spells; it != cards.end(); ++it)
|
||||||
|
if ((*it)->card->isCreature())
|
||||||
|
{
|
||||||
|
if (game->players[0] == (*it)->card->controller()) selfCreatures.Render(*it, cards.begin(), end_spells);
|
||||||
|
else opponentCreatures.Render(*it, cards.begin(), end_spells);
|
||||||
|
}
|
||||||
|
else if ((*it)->card->isLand())
|
||||||
|
{
|
||||||
|
if (game->players[0] == (*it)->card->controller()) selfLands.Render(*it, cards.begin(), end_spells);
|
||||||
|
else opponentLands.Render(*it, cards.begin(), end_spells);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void GuiPlay::Update(float dt)
|
||||||
|
{
|
||||||
|
battleField.Update(dt);
|
||||||
|
for (iterator it = cards.begin(); it != cards.end(); ++it)
|
||||||
|
(*it)->Update(dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
int GuiPlay::receiveEventPlus(WEvent * e)
|
||||||
|
{
|
||||||
|
if (WEventZoneChange *event = dynamic_cast<WEventZoneChange*>(e))
|
||||||
|
{
|
||||||
|
if ((game->players[0]->inPlay() == event->to) ||
|
||||||
|
(game->players[1]->inPlay() == event->to))
|
||||||
|
{
|
||||||
|
CardView * card;
|
||||||
|
cout << "Play Plus " << event->card << endl;
|
||||||
|
if (event->card->view)
|
||||||
|
card = NEW CardView(event->card, *(event->card->view));
|
||||||
|
else
|
||||||
|
card = NEW CardView(event->card, 0, 0);
|
||||||
|
cards.push_back(card);
|
||||||
|
card->t = 0;
|
||||||
|
cs->Add(card);
|
||||||
|
Replace();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (WEventCreatureAttacker* event = dynamic_cast<WEventCreatureAttacker*>(e))
|
||||||
|
{
|
||||||
|
if (NULL != event->after)
|
||||||
|
battleField.addAttacker(event->card);
|
||||||
|
else if (NULL != event->before)
|
||||||
|
battleField.removeAttacker(event->card);
|
||||||
|
Replace();
|
||||||
|
}
|
||||||
|
else if (WEventCreatureBlocker* event = dynamic_cast<WEventCreatureBlocker*>(e))
|
||||||
|
{
|
||||||
|
Replace();
|
||||||
|
}
|
||||||
|
else if (WEventCardTap* event = dynamic_cast<WEventCardTap*>(e))
|
||||||
|
{
|
||||||
|
if (CardView* cv = dynamic_cast<CardView*>(event->card->view))
|
||||||
|
cv->t = event->after ? M_PI / 2 : 0;
|
||||||
|
else
|
||||||
|
event->card->view->actT = event->after ? M_PI / 2 : 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int GuiPlay::receiveEventMinus(WEvent * e)
|
||||||
|
{
|
||||||
|
if (WEventZoneChange *event = dynamic_cast<WEventZoneChange*>(e))
|
||||||
|
{
|
||||||
|
if ((game->players[0]->inPlay() == event->from) ||
|
||||||
|
(game->players[1]->inPlay() == event->from))
|
||||||
|
for (iterator it = cards.begin(); it != cards.end(); ++it)
|
||||||
|
if (event->card->previous == (*it)->card)
|
||||||
|
{
|
||||||
|
CardView* cv = *it;
|
||||||
|
cs->Remove(cv);
|
||||||
|
cards.erase(it);
|
||||||
|
delete cv;
|
||||||
|
Replace();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,199 @@
|
|||||||
|
#include "../include/config.h"
|
||||||
|
#include "../include/GuiStatic.h"
|
||||||
|
|
||||||
|
GuiStatic::GuiStatic(float desiredHeight, float x, float y, bool hasFocus, GuiAvatars* parent) : PlayGuiObject(desiredHeight, x, y, hasFocus), parent(parent) {}
|
||||||
|
void GuiStatic::Entering()
|
||||||
|
{
|
||||||
|
parent->Activate(this);
|
||||||
|
}
|
||||||
|
bool GuiStatic::Leaving(u32 key)
|
||||||
|
{
|
||||||
|
parent->Deactivate(this);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiAvatar::GuiAvatar(float x, float y, bool hasFocus, Player * player, Corner corner, GuiAvatars* parent) : GuiStatic(GuiAvatar::Height, x, y, hasFocus, parent), avatarRed(255), currentLife(player->life), corner(corner), player(player) {
|
||||||
|
type = GUI_AVATAR;
|
||||||
|
switch (corner)
|
||||||
|
{
|
||||||
|
case TOP_LEFT : player->mAvatar->SetHotSpot(0, 0); break;
|
||||||
|
case BOTTOM_RIGHT : player->mAvatar->SetHotSpot(35, 50); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiAvatar::Render()
|
||||||
|
{
|
||||||
|
GameObserver * game = GameObserver::GetInstance();
|
||||||
|
JRenderer * r = JRenderer::GetInstance();
|
||||||
|
int life = player->life;
|
||||||
|
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT);
|
||||||
|
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
|
||||||
|
//Avatar
|
||||||
|
int lifeDiff = life - currentLife;
|
||||||
|
if (lifeDiff < 0 && currentLife > 0){
|
||||||
|
avatarRed = 192 + (3* 255 * lifeDiff) / currentLife / 4;
|
||||||
|
if (avatarRed < 0) avatarRed = 0;
|
||||||
|
}
|
||||||
|
currentLife = life;
|
||||||
|
|
||||||
|
r->FillRect(actX+2, actY+2, Width, Height, ARGB((int)(actA / 2), 0, 0, 0));
|
||||||
|
|
||||||
|
JQuad * quad = player->mAvatar;
|
||||||
|
if (quad)
|
||||||
|
{
|
||||||
|
quad->SetColor(ARGB((int)actA, 255, avatarRed, avatarRed));
|
||||||
|
r->RenderQuad(quad, actX, actY, actT, actZ, actZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (avatarRed < 255){
|
||||||
|
avatarRed += 3;
|
||||||
|
if (avatarRed > 255)
|
||||||
|
avatarRed = 255;
|
||||||
|
}
|
||||||
|
if (game->currentPlayer == player)
|
||||||
|
r->DrawRect(actX-1, actY-1, 37, 52, ARGB((int)actA, 0, 255, 0));
|
||||||
|
else if (game->currentActionPlayer == player)
|
||||||
|
r->DrawRect(actX, actY, 35, 50, ARGB((int)actA, 0, 0, 255));
|
||||||
|
if (game->isInterrupting == player)
|
||||||
|
r->DrawRect(actX, actY, 35, 50, ARGB((int)actA, 255, 0, 0));
|
||||||
|
|
||||||
|
//Life
|
||||||
|
char buffer[5];
|
||||||
|
sprintf(buffer, "%i",life);
|
||||||
|
switch (corner)
|
||||||
|
{
|
||||||
|
case TOP_LEFT :
|
||||||
|
mFont->SetColor(ARGB((int)actA / 4, 0, 0, 0));
|
||||||
|
mFont->DrawString(buffer, actX+2, actY+2);
|
||||||
|
mFont->SetColor(ARGB((int)actA, 255, 255, 255));
|
||||||
|
mFont->DrawString(buffer, actX+1, actY+1);
|
||||||
|
break;
|
||||||
|
case BOTTOM_RIGHT :
|
||||||
|
mFont->SetColor(ARGB((int)actA, 255, 255, 255));
|
||||||
|
mFont->DrawString(buffer, actX, actY-10, JGETEXT_RIGHT);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
PlayGuiObject::Render();
|
||||||
|
}
|
||||||
|
|
||||||
|
ostream& GuiAvatar::toString(ostream& out) const
|
||||||
|
{
|
||||||
|
return out << "GuiAvatar ::: avatarRed : " << avatarRed
|
||||||
|
<< " ; currentLife : " << currentLife
|
||||||
|
<< " ; player : " << player;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiGameZone::toggleDisplay(){
|
||||||
|
if (showCards)
|
||||||
|
showCards = 0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
showCards = 1;
|
||||||
|
cd->init(zone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiGameZone::Render(){
|
||||||
|
//Texture
|
||||||
|
JQuad * quad = GameApp::CommonRes->GetQuad("back_thumb");
|
||||||
|
float scale = defaultHeight / quad->mHeight;
|
||||||
|
quad->SetColor(ARGB((int)(actA/2),255,255,255));
|
||||||
|
|
||||||
|
JRenderer::GetInstance()->RenderQuad(quad, actX, actY, 0.0, scale, scale);
|
||||||
|
|
||||||
|
//Number of cards
|
||||||
|
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT);
|
||||||
|
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
|
||||||
|
char buffer[11];
|
||||||
|
sprintf(buffer,"%i", zone->nb_cards);
|
||||||
|
mFont->SetColor(ARGB((int)(actA/4),0,0,0));
|
||||||
|
mFont->DrawString(buffer, actX+1, actY+1);
|
||||||
|
mFont->SetColor(ARGB((int)actA,255,255,255));
|
||||||
|
mFont->DrawString(buffer, actX, actY);
|
||||||
|
|
||||||
|
if (showCards) cd->Render();
|
||||||
|
for (vector<TransientCardView*>::iterator it = cards.begin(); it != cards.end(); ++it)
|
||||||
|
(*it)->Render();
|
||||||
|
PlayGuiObject::Render();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiGameZone::ButtonPressed(int controllerId, int controlId){
|
||||||
|
GameObserver::GetInstance()->ButtonPressed(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiGameZone::Update(float dt){
|
||||||
|
for (vector<TransientCardView*>::iterator it = cards.begin(); it != cards.end(); ++it)
|
||||||
|
(*it)->Update(dt);
|
||||||
|
if (showCards) cd->Update(dt);
|
||||||
|
PlayGuiObject::Update(dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiGameZone::GuiGameZone(float x, float y, bool hasFocus, MTGGameZone* zone, GuiAvatars* parent): GuiStatic(GuiGameZone::Height, x, y, hasFocus, parent), zone(zone){
|
||||||
|
cd = NEW CardDisplay(0, GameObserver::GetInstance(), x, y, this);
|
||||||
|
showCards = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiGameZone::~GuiGameZone(){
|
||||||
|
if (cd) delete cd;
|
||||||
|
}
|
||||||
|
|
||||||
|
ostream& GuiGameZone::toString(ostream& out) const
|
||||||
|
{
|
||||||
|
return out << "GuiGameZone ::: zone : " << zone
|
||||||
|
<< " ; cd : " << cd
|
||||||
|
<< " ; showCards : " << showCards;
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiGraveyard::GuiGraveyard(float x, float y, bool hasFocus, Player * player, GuiAvatars* parent) : GuiGameZone(x, y, hasFocus, player->game->graveyard, parent), player(player) {
|
||||||
|
type = GUI_GRAVEYARD;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GuiGraveyard::receiveEventPlus(WEvent* e)
|
||||||
|
{
|
||||||
|
if (WEventZoneChange* event = dynamic_cast<WEventZoneChange*>(e))
|
||||||
|
if (event->to == zone)
|
||||||
|
{
|
||||||
|
cout << "Goes to Graveyard " << event->card->view << endl;
|
||||||
|
TransientCardView* t;
|
||||||
|
if (event->card->view)
|
||||||
|
t = NEW TransientCardView(event->card, *(event->card->view));
|
||||||
|
else
|
||||||
|
t = NEW TransientCardView(event->card, x, y);
|
||||||
|
t->x = x + Width / 2; t->y = y + Height / 2; t->zoom = 0.3; t->alpha = 0;
|
||||||
|
cards.push_back(t);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GuiGraveyard::receiveEventMinus(WEvent* e)
|
||||||
|
{
|
||||||
|
if (WEventZoneChange* event = dynamic_cast<WEventZoneChange*>(e))
|
||||||
|
if (event->from == zone)
|
||||||
|
for (vector<TransientCardView*>::iterator it = cards.begin(); it != cards.end(); ++it)
|
||||||
|
if (event->card->previous == (*it)->card)
|
||||||
|
{
|
||||||
|
TransientCardView* cv = *it;
|
||||||
|
cards.erase(it);
|
||||||
|
delete cv;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ostream& GuiGraveyard::toString(ostream& out) const
|
||||||
|
{
|
||||||
|
return out << "GuiGraveyard :::";
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiLibrary::GuiLibrary(float x, float y, bool hasFocus, Player * player, GuiAvatars* parent) : GuiGameZone(x, y, hasFocus,player->game->library, parent), player(player) {
|
||||||
|
type = GUI_LIBRARY;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ostream& GuiLibrary::toString(ostream& out) const
|
||||||
|
{
|
||||||
|
return out << "GuiLibrary :::";
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#include "JRenderer.h"
|
||||||
|
#include "../include/Pos.h"
|
||||||
|
|
||||||
|
Pos::Pos(float x, float y, float z, float t, float a) : actX(x), actY(y), actZ(z), actT(t), actA(a), x(x), y(y), zoom(z), t(t), alpha(a) {}
|
||||||
|
void Pos::Update(float dt)
|
||||||
|
{
|
||||||
|
actX += 10 * dt * (x - actX);
|
||||||
|
actY += 10 * dt * (y - actY);
|
||||||
|
actT += 10 * dt * (t - actT);
|
||||||
|
actZ += 10 * dt * (zoom - actZ);
|
||||||
|
actA += 10 * dt * (alpha - actA);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Pos::Render(){}
|
||||||
|
void Pos::Render(JQuad* quad)
|
||||||
|
{
|
||||||
|
quad->SetColor(ARGB((int)actA, 255, 255, 255));
|
||||||
|
JRenderer::GetInstance()->RenderQuad(quad, actX, actY, actT, actZ, actZ);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user