Ejemplo n.º 1
0
void GameAudio::processHealSound()
{
	if (soundEffectRegistrationMap[ENUM_SOUND_EFFECT_HEAL] == true)
	{
		Game *game = Game::getSingleton();
		GameStateManager *gsm = game->getGSM();
		SpriteManager *spriteMgr = gsm->getSpriteManager();
		PlayerSprite *player = spriteMgr->getPlayer();

		bool isHealing = player->getIshealing();

		if (isHealing == true)
		{
			IXAudio2SourceVoice *healSound = soundEffectMap[ENUM_SOUND_EFFECT_HEAL];

			XAUDIO2_VOICE_STATE voiceState;
			healSound->GetState(&voiceState);

			//// [voiceState.BuffersQueued <= 0] means there are nothing in the buffer
			//// so let's make a new buffer to queue the sound
			if (voiceState.BuffersQueued <= 0)
			{
				XAUDIO2_BUFFER *proto = audioBufferPrototypeMap[ENUM_SOUND_EFFECT_HEAL];
				bool ssbSuccess = SUCCEEDED(healSound->SubmitSourceBuffer(proto));
				healSound->Start();
				//// After all, there will be only one buffer node in the queue always ...
			}
			//// if there is something in the buffer
			else
			{
				/// do nothing
			}
		}
	}
}
Ejemplo n.º 2
0
void GameAudio::processPunchSound()
{
	if (soundEffectRegistrationMap[ENUM_SOUND_EFFECT_PUNCH] == true)
	{
		Game *game = Game::getSingleton();
		GameStateManager *gsm = game->getGSM();
		SpriteManager *spriteMgr = gsm->getSpriteManager();
		PlayerSprite *player = spriteMgr->getPlayer();

		wstring playerState = player->getCurrentState();

		if (playerState.compare(L"PUNCH_LEFT") == 0 || playerState.compare(L"PUNCH_RIGHT") == 0
			|| playerState.compare(L"PUNCH_BACK") == 0 || playerState.compare(L"PUNCH_FRONT") == 0)
		{
			IXAudio2SourceVoice *punchSound = soundEffectMap[ENUM_SOUND_EFFECT_PUNCH];

			XAUDIO2_VOICE_STATE voiceState;
			punchSound->GetState(&voiceState);

			//// [voiceState.BuffersQueued <= 0] means there are nothing in the buffer
			//// so let's make a new buffer to queue the sound
			if (voiceState.BuffersQueued <= 0)
			{
				XAUDIO2_BUFFER *proto = audioBufferPrototypeMap[ENUM_SOUND_EFFECT_PUNCH];
				bool ssbSuccess = SUCCEEDED(punchSound->SubmitSourceBuffer(proto));
				punchSound->Start();
			}
			//// if there is something in the buffer
			else
			{
				/// do nothing
			}
		}
	}
}
Ejemplo n.º 3
0
PlayerSprite* PlayerSprite::create(GameLayer * game, int type, CCPoint position) {
    PlayerSprite *sprite = new PlayerSprite(game, type, position);
    if (sprite) {
        sprite->initPlayer();
        sprite->autorelease();
        return sprite;
    }
    CC_SAFE_DELETE(sprite);
    return NULL;
}
Ejemplo n.º 4
0
void GameLayer::addPlayer(Player &player) {
    PlayerSprite* sprite = PlayerSprite::create(player);
    sprite->retain();
    sprite->setPosition(getPlayerInitPos());
    
    addChild(sprite);
    mPlayers.pushBack(sprite);
    
    placePlayers();
}
Ejemplo n.º 5
0
PlayerSprite* PlayerSprite::create(string name, string photo, float winRate) {
    PlayerSprite *sprite = new (std::nothrow) PlayerSprite(name, photo, winRate);
    if (sprite && sprite->init())
    {
        sprite->autorelease();
        
        return sprite;
    }
    CC_SAFE_DELETE(sprite);
    return nullptr;
}
Ejemplo n.º 6
0
void GameLayer::placePlayers() {
    size_t count = mPlayers.size();
    float degree = 2*PI / count;
    Vec2 initPos = getPlayerInitPos();

    for (int i = 0; i < mPlayers.size(); i++) {
        PlayerSprite* player = mPlayers.at(i);
        Vec2 newPos = initPos.rotateByAngle(mDiceCup->getPosition(), degree*i);
        player->runAction(MoveTo::create(PlayerPlaceDuration, newPos));
    }
}
Ejemplo n.º 7
0
float GameLayer::getPlayerRadiusToCenter() {
    static float r = -1;
    if (r == -1) {
        PlayerSprite* player = PlayerSprite::create("tmp");
        float cupLength = MAX(mDiceCup->getContentSize().height/2, mDiceCup->getContentSize().width/2);
        float playerLength = MAX(player->getContentSize().height/2, player->getContentSize().width/2);
        r = cupLength+playerLength+PlayerRadiusMargin;
    }
    
    return r;
}
void RebelleUpgradeScreenGUI::loadPlayerStats()
{
	Game* game = Game::getSingleton();
	GameStateManager* gsm = game->getGSM();
	SpriteManager* spriteMgr = gsm->getSpriteManager();
	GameGraphics *graphics = game->getGraphics();
	TextureManager *guiTextureManager = graphics->getGUITextureManager();

	PlayerSprite *player = spriteMgr->getPlayer();
	int speed = player->getSpeed();
	int attack = player->getAttack();
	int defense = player->getDefense();
	unsigned int speedIconTID = guiTextureManager->loadTexture(SPEED_ICON_PATH);
	unsigned int attackIconTID = guiTextureManager->loadTexture(ATTACK_ICON_PATH);
	unsigned int defenseIconTID = guiTextureManager->loadTexture(DEFENSE_ICON_PATH);

	//// - first speed icon will be rendered at 20px right to upgrade button
	int speedIconY = statListY + statLineHeight + ydistBetweenStats;
	int nextSpeedIconX = statListX + statTitleWidth + statTitleWidth + upgradeButtonWidth + 20;
	for (int i = 0; i < speed; i++)
	{
		OverlayImage *speedIcon = new OverlayImage();
		speedIcon->alpha = 255;
		speedIcon->width = STAT_ICON_WIDTH;
		speedIcon->height = STAT_ICON_HEIGHT;
		speedIcon->x = nextSpeedIconX;
		speedIcon->y = speedIconY;
		speedIcon->z = 0;
		speedIcon->imageID = speedIconTID;

		this->addOverlayImage(speedIcon);
		nextSpeedIconX += STAT_ICON_WIDTH + 3;
	}

	//// attack icons should be next to Attack stat title and the button.
	int attackIconY = speedIconY + statLineHeight + ydistBetweenStats;
	int nextAttackIconX = statListX + statTitleWidth + statTitleWidth + upgradeButtonWidth + 20;
	for (int i = 0; i < attack; i++)
	{
		OverlayImage *attackIcon = new OverlayImage();
		attackIcon->alpha = 255;
		attackIcon->width = STAT_ICON_WIDTH;
		attackIcon->height = STAT_ICON_HEIGHT;
		attackIcon->x = nextAttackIconX;
		attackIcon->y = attackIconY;
		attackIcon->z = 0;
		attackIcon->imageID = attackIconTID;

		this->addOverlayImage(attackIcon);
		nextAttackIconX += STAT_ICON_WIDTH + 3;
	}

	//// defense icons
	int defenseIconY = attackIconY + statLineHeight + ydistBetweenStats;
	int nextDefenseIconX = statListX + statTitleWidth + statTitleWidth + upgradeButtonWidth + 20;
	for (int i = 0; i < attack; i++)
	{
		OverlayImage *defenseIcon = new OverlayImage();
		defenseIcon->alpha = 255;
		defenseIcon->width = STAT_ICON_WIDTH;
		defenseIcon->height = STAT_ICON_HEIGHT;
		defenseIcon->x = nextDefenseIconX;
		defenseIcon->y = defenseIconY;
		defenseIcon->z = 0;
		defenseIcon->imageID = defenseIconTID;

		this->addOverlayImage(defenseIcon);
		nextDefenseIconX += STAT_ICON_WIDTH + 3;
	}
}