void ribi::QtBeerWanterWidget::mousePressEvent(QMouseEvent *)
{
  //#define DEBUG_SHOW_MOUSE_CLICK_POSITION
  #ifdef DEBUG_SHOW_MOUSE_CLICK_POSITION
  const int mouse_x = event->x();
  const int mouse_y = event->y();
  m_debug_text
    = "CLICK: ("
    + boost::lexical_cast<std::string>(mouse_x)
    + ","
    + boost::lexical_cast<std::string>(mouse_y)
    + ")";
  #endif
  if (m_dialog->Click())
  {
    //Inform user of level-up
    emit LevelUp(m_dialog->GetWindowTitle());
  }
  this->repaint();
}
Ejemplo n.º 2
0
void BattleCharacter::BuildCharacter(CCDictionary* dic)
{	
	int nID = ((CCString*)dic->objectForKey("ID"))->intValue();
	int x = ((CCString*)dic->objectForKey("x"))->intValue()+SQUARE_LENTH/2;
	int y = ((CCString*)dic->objectForKey("y"))->intValue()+SQUARE_LENTH/2;
	int nForceFlag = ((CCString*)dic->objectForKey("FORCE"))->intValue();
	//初始化角色属性
	m_nCharID = nID;
	CharacterDataLoader* pData = CharacterDataLoader::instance();
	pData->GetCharacterValue(DATA_CHARACTER_STR,m_nCharID,&m_nStr);
	pData->GetCharacterValue(DATA_CHARACTER_DEF,m_nCharID,&m_nDef);
	pData->GetCharacterValue(DATA_CHARACTER_SPD,m_nCharID,&m_nSpd);
	pData->GetCharacterValue(DATA_CHARACTER_HP,m_nCharID,&m_nMaxHP);
	pData->GetCharacterValue(DATA_CHARACTER_SP,m_nCharID,&m_nMaxSP);
	m_nSP = m_nMaxSP;
	m_nHP = m_nMaxHP;
	pData->GetCharacterValue(DATA_CHARACTER_MAG,m_nCharID,&m_nMag);
	pData->GetCharacterValue(DATA_CHARACTER_DEX,m_nCharID,&m_nDex);
	pData->GetCharacterValue(DATA_CHARACTER_LUK,m_nCharID,&m_nLuk);
	pData->GetCharacterValue(DATA_CHARACTER_MOVE,m_nCharID,&m_nMove);
	pData->GetCharacterValue(DATA_CHARACTER_MINRANGE,m_nCharID,&m_nMinAtkRange);
	pData->GetCharacterValue(DATA_CHARACTER_MAXRANGE,m_nCharID,&m_nMaxAtkRange);
	m_nForceFlag = nForceFlag;
	CCString* pLevel = (CCString*)dic->objectForKey("Level");
	if (pLevel!=NULL)
	{
		int nLevel  = pLevel->intValue();
		LevelUp(nLevel-1);
		RecoverSPToMax();
		RecoverHPToMax();
	}	
	//初始化角色技能、能力
	pData->GetLevelSkills(m_nCharID,m_nLevel,m_vSkills);
	pData->GetLevelAbilities(m_nCharID,m_nLevel,m_vAbilities);
	//初始化角色状态
	InitSpritesAndStatus(x,y);
}
Ejemplo n.º 3
0
void GameTable::RemoveBlocksAndUpdateTable(Uint32 linkNr)
{
    // Let's check if we should level up
    if (experience > expToLevelUp)
    {
        LevelUp();
        ClearTable();
    }
    else
    {
        // Let's stop the timer
        timer->stop();

        for (auto blockPos : blockLinks[linkNr - 1])
        {
            auto col = table->at(blockPos->x);
            col->erase(blockPos->y);

            if (col->size() == 0)
            {
                table->erase(blockPos->x);
                delete col;
            }

            delete blockPos;
        }

        UpdateTable();

        ClearBlocks(true);
        CalcLinkedBlocks();

        // Begin destruction animation
        animTimer->start();
        state = GameTableState::InputDisabled;
    }
}
Ejemplo n.º 4
0
void BattleCharacter::ExpForLevelCallBack( CCNode* pSender,void* pData )
{
	m_nExp += m_nExpGot;
	int nLevelUp = m_nExp/100;
	m_nExp = m_nExp%100;
	//当exp>100时升级
	//清空获取的exp
	m_nExpGot = 0;
	if(nLevelUp>0)
	{
		LevelUp(nLevelUp);
		char chImage[50] = {0};
		sprintf(chImage,"%s.png",LEVELUP_LOGO_NAME);
		CCSprite* pLogo = CCSprite::createWithSpriteFrameName(chImage);
		m_pMapSprites->getParent()->addChild(pLogo,MAX_LAYER_ZORDER);
		pLogo->setPosition(ccp(GetMapPositionX(),GetMapPositionY()));
		pLogo->runAction(CCSequence::createWithTwoActions(CCMoveBy::create(LEVELUP_LOGO_MOVE_DUR,ccp(0,SQUARE_LENTH/2)),CCCallFuncND::create(this,callfuncND_selector(BattleCharacter::RemoveLevelLogoCallBack),(void*)pLogo)));
	}
	//else
	//{
	//	//判断事件
	//	EventHandler::instance()->OnCharacterActionEnd(this);
	//}
}
Ejemplo n.º 5
0
void CAPet::CalcLevelup()
{
	if ( m_exp < 0 )
		m_exp = 0;

	if (m_nSP > MAX_SKILLPOINT)
		m_nSP = MAX_SKILLPOINT;

	if ( GetNeedExp() <= m_exp && m_level < MAX_APET_LEVEL)
	{
		do
		{
			GAMELOG << init("APET LEVEL UP", GetOwner() )
					<< m_level
					<< " ==> "
					<< m_level + 1
					<< end;
			m_exp -= GetNeedExp();
			m_level++;

			// 레벨업 효과
			LevelUp(true);

			if( m_level >= MAX_APET_LEVEL )
				m_exp = 0;

		}
		while ( GetNeedExp() <= m_exp );
	}

	{
		CNetMsg::SP rmsg(new CNetMsg);
		ExAPetStatusMsg(rmsg, this);
		SEND_Q(rmsg, GetOwner()->m_desc);
	}
}
Ejemplo n.º 6
0
void CProfile::LoadData()
{
	FuncDefs::Load();
	LevelUp();
	LoadRegistry();
}
Ejemplo n.º 7
0
void Player::TEST_LevelUp()
{
	_exp = _expMax;
	LevelUp();
}
Ejemplo n.º 8
0
	void Player::Update(bool keys[], Map &map)
	{
		const int FRAMES_PER_ANIMATION = frameArraySize.x * frameArraySize.x;
		hasMoved = false;

		if(health <= 0 && state != DYING && state != DEAD)
		{
			Die();
			state = DYING;
		}

		const bool moveUp		=	keys[KEY_UP]	|| keys[KEY_W];
		const bool moveLeft		=	keys[KEY_LEFT]	|| keys[KEY_A];
		const bool moveDown		=	keys[KEY_DOWN]	|| keys[KEY_S];
		const bool moveRight	=	keys[KEY_RIGHT] || keys[KEY_D];

		const bool attack		=	keys[KEY_SPACE];

		if(state == DYING || state == DEAD)
		{
			if(attackCounter++ == FRAMES_PER_ANIMATION)
			{
				state = DEAD;
				attackCounter = 0;
			}
		}
		else if(attack)
		{
			if(attacking == false)
			{
				attackCounter = 0;
				attacking = true;
				Attack();
			}
		}

		if(experience >= pow(2.0, level + 1))
		{
			LevelUp();   
		}

		if(state != DYING && state != DEAD)
		{
			if((moveUp || moveLeft || moveDown || moveRight || attacking) == false)
			{
				Rest();
			}
			else if(attacking)
			{
				if(attackCounter++ == FRAMES_PER_ANIMATION) 
				{
					for(std::vector<Enemy*>::iterator it = map.enemies.begin(); it != map.enemies.end(); ++it)
					{
						if(GenerateHitBox(direction).Intersects((*it)->GetBounds()))
						{
							(*it)->health -= 10;
						}
					}

					attacking = false;
					attackCounter = 0;
				}
			}
			else
			{
				Vector2 coords = GetCoords();
				if((coords == previousCoords) == false)
				{
					previousCoords = coords;
					hasMoved = true;
				}

				if(moveUp)
				{
					if(moveLeft)
					{
						Move(map, NORTH_WEST);
					}
					else if(moveRight)
					{
						Move(map, NORTH_EAST);
					}
					else
					{
						Move(map, NORTH);
					}
				}
				else if(moveDown)
				{
					if(moveLeft)
					{
						Move(map, SOUTH_WEST);
					}
					else if(moveRight)
					{
						Move(map, SOUTH_EAST);
					}
					else
					{
						Move(map, SOUTH);
					}
				}
				else if(moveLeft)
				{
					Move(map, WEST);
				}
				else if(moveRight)
				{
					Move(map, EAST);
				}
			}
		}
	}
Ejemplo n.º 9
0
void ForceLevelUp(void)
{
	GrantExperience(characterData.xpForNextLevel - characterData.xp);
	LevelUp();
}
Ejemplo n.º 10
0
void Robot::EarnExp(int xp)
{ 
   exp += xp; 
   while(level < 100 && exp > level * 100) 
      LevelUp();
}
Ejemplo n.º 11
0
void BPMiniGame_UnderTheHat::Start() {
	LevelUp();
	
	TimeStarted = TheGame->TickCount;
}
Ejemplo n.º 12
0
void BPMiniGame_UnderTheHat::Tick() {
	if (SuccessTime != -1 && SuccessTime + 250 < TheGame->TickCount) {
		Success();
		return;
	}
	
	if (BackgroundUp) {
		BackgroundFade += 0.0025f;
		if (BackgroundFade >= 1.0f) {
			BackgroundUp = false;
		}
	} else {
		BackgroundFade -= 0.0025f;
		
		if (BackgroundFade <= 0.0f) {
			BackgroundUp = true;
		}
	}
	
	switch (State) {
		case SHOWING:
			break;
			
		case WAITING:
			if (LastStateChange + 1000 < TheGame->TickCount) {
				State = MOVING;
				MoveAmount = 0.0f;
			}
			break;
			
		case CORRECT:
			if (LastStateChange + 1750 < TheGame->TickCount) {
				LevelUp();
				State = MOVING;
			}
			
			break;
			
		case WRONG:
			if (LastStateChange + 1750 < TheGame->TickCount) {
				GenerateMoves();
				State = MOVING;
			}
			
			break;
			
		case MOVING:
			if (MoveAmount < 1.0f) {
				MoveAmount += 0.1f * TheGame->ElapsedSeconds * MoveSpeed;
				
				for (int i = 0; i < Hats.Count; ++i) {
					BPMiniGame_UnderTheHat_Hat* hat = Hats[i];
					hat->X = TheGame->SmoothStep(hat->StartX, hat->DestX, MoveAmount);
					hat->Y = TheGame->SmoothStep(hat->StartY, hat->DestY, MoveAmount);
				}
			} else {
				if (MovesLeft > 0) {
					// finished a previous move, but we have more moves to do
					MakeMove();
				} else {
					// finished moving - time to guess!
					State = GUESSING;
					ChosenHat = NULL;
				}
			}			
			break;
	}
}
Ejemplo n.º 13
0
void BPMiniGame_ShortCircuitSudoku::Start() {
	TimeStarted = TheGame->TickCount;
	LevelUp();
}