Ejemplo n.º 1
0
//Area내부가 클릭되었는지 체크. UIBUTTION클래스 함수 참조함
bool CMapObstacle::CheckClickArea()
{
	NNPoint cursorPosition = NNInputSystem::GetInstance()->GetMousePosition();

	bool isInXCoordRange = (m_pObstacle_sprite->GetPositionX() < 
		cursorPosition.GetX()) && ( ( m_pObstacle_sprite->GetPositionX()
		+ m_pObstacle_sprite->GetImageWidth() ) > cursorPosition.GetX() );

	bool isInYCoordRange = (m_pObstacle_sprite->GetPositionY() < 
		cursorPosition.GetY()) && ( ( m_pObstacle_sprite->GetPositionY()
		+ m_pObstacle_sprite->GetImageHeight() ) > cursorPosition.GetY() );

	if ( !(isInXCoordRange && isInYCoordRange))
	{
		return false;
	}
	else
	{
		if (NNInputSystem::GetInstance()->GetKeyState( VK_LBUTTON ) == KEY_UP )
			return true;
	}
	
	return false;

}
Ejemplo n.º 2
0
NNPoint CGameMap::positionToArrayIndex( NNPoint p )
{
	p.SetX( p.GetX() / TILESIZE );
	p.SetY( p.GetY() / TILESIZE );

	return p;
}
Ejemplo n.º 3
0
// 현재 마우스 커서의 위치가 UIbutton 위에 있는지를 체크함
// parameter : void
// return  : button 위에 있을 시 1, button밖에 있을 시 0을 반환
bool CUIButton::CheckButtonArea( void )
{
	NNPoint cursorPosition = NNInputSystem::GetInstance()->GetMousePosition();
	bool isInXCoordRange = (m_Position.GetX() < cursorPosition.GetX()) && ( ( m_Position.GetX() + m_pNormalImage->GetImageWidth() ) > cursorPosition.GetX() );
	bool isInYCoordRange = (m_Position.GetY() < cursorPosition.GetY()) && ( ( m_Position.GetY() + m_pNormalImage->GetImageHeight() ) > cursorPosition.GetY() );
	
	if ( !(isInXCoordRange && isInYCoordRange) ) {
		m_pNormalImage->SetVisible(true);
		m_pPressedImage->SetVisible(false);
		return false;
	} else {
		if (NNInputSystem::GetInstance()->GetKeyState( VK_LBUTTON ) == KEY_PRESSED ) {
			m_pNormalImage->SetVisible(false);
			m_pPressedImage->SetVisible(true);
		}
		if (NNInputSystem::GetInstance()->GetKeyState( VK_LBUTTON ) == KEY_UP ||
			NNInputSystem::GetInstance()->GetKeyState( VK_LBUTTON ) == KEY_DOWN){
			m_pNormalImage->SetVisible(true);
			m_pPressedImage->SetVisible(false);
			return true;
		}
	}
	
	return false;
}
Ejemplo n.º 4
0
void CHumanInFarm::CollectMeatPointFromGrownUp()
{
	if( NNInputSystem::GetInstance()->GetKeyState(VK_LBUTTON) == KEY_UP ) {
		NNPoint cursorPosition = NNInputSystem::GetInstance()->GetMousePosition();
		bool isInXCoordRange = (m_pGrownUp->GetPositionX() < cursorPosition.GetX()) && ( ( m_pGrownUp->GetPositionX() + 50 ) > cursorPosition.GetX() );
		bool isInYCoordRange = (m_pGrownUp->GetPositionY() < cursorPosition.GetY()) && ( ( m_pGrownUp->GetPositionY() + 90 ) > cursorPosition.GetY() );
		
		if(isInXCoordRange && isInYCoordRange){
			if(m_AgeState == DEAD && m_pDead){
				printf_s("거둔다\n");
				RemoveChild(m_pDead,true);
				RemoveChild(m_pGrownUp,true);
				CPlayer* m_pPlayer = CPlayer::GetInstance();
				m_pPlayer->SetMeatPoint(m_pPlayer->GetMeatPoint() + 30);
				return;
			}
			else if(m_AgeState == GROWN_UP && m_pGrownUp){
				printf_s("터뜨린다\n");
				int rannum = rand()%6;
				m_AgeState = DEAD;
				NNPoint NowPosition = m_pGrownUp->GetPosition();
				//RemoveChild(m_pGrownUp,true);
				m_pGrownUp->SetVisible(false);
				m_pDead = NNSprite::Create(DeadImagePath[rannum]);
				m_pDead->SetPosition(NowPosition);
				AddChild(m_pDead,100);
				return;
			}
		}
	}
}
Ejemplo n.º 5
0
void NNBulletManager::MakeBullet( BULLET_TYPE type, NNPoint PlayerPosition )
{
	if (m_AmmoLeft > 0)
	{
		BULLET_PROPERTY bullet_property;
		NNBullet* newBullet; 
		newBullet = new NNBullet();

		switch ( type )
		{
		case NORMAL_BULLET:
			bullet_property.imageHeight		=	NORMAL_BULLET_HEIGHT;
			bullet_property.imageWidth		=	NORMAL_BULLET_WIDTH;
			bullet_property.speed			=	NORMAL_BULLET_SPEED;
			bullet_property.sprite_path		=	NORMAL_BULLET_SPRITE;
			bullet_property.zIndex			=	NORMAL_BULLET_ZINDEX;
			bullet_property.type			=	NORMAL_BULLET;
			NNSoundManager::GetInstance()->Play(NNSoundManager::GetInstance()->SE_NormalGunShot[rand()%NNSoundManager::GetInstance()->SE_NormalGunShot.size()]);
			break;
		default:
			break;
		}

		bullet_property.position.SetPoint( PlayerPosition.GetX()+ GUN_WIDTH, PlayerPosition.GetY() );
		newBullet->SetBulletProperty( bullet_property);
		newBullet->SetPosition( PlayerPosition.GetX()+ GUN_WIDTH, PlayerPosition.GetY() );
		m_Bullet.push_back( newBullet );
		AddChild( newBullet );
		--m_AmmoLeft;
	}
}
Ejemplo n.º 6
0
bool CGameMap::isValidTile( NNPoint p )
{
	NNPoint temp = positionToArrayIndex(p);
	int i = (int)temp.GetX();
	int j = (int)temp.GetY();

	CTile *tile = mTile[i][j];

	// 이 타일이 빈 타일이거나
	// 움직일 수 없는 타일이거나
	if(tile->misFull == false ||
		tile->mattribute & ATTRIBUTE_MOVE )
		return false;

	return true;
}
Ejemplo n.º 7
0
void CPlayScene::CollectDeadPoliceByClick()
{
	if( NNInputSystem::GetInstance()->GetKeyState(VK_LBUTTON) == KEY_UP ) {
		NNPoint cursorPosition = NNInputSystem::GetInstance()->GetMousePosition();
		for ( auto& iter = m_llistDeadPolice.begin() ; iter != m_llistDeadPolice.end() ; iter++ )
		{
			bool isInXCoordRange = (static_cast<CDeadPolice*>(*iter)->GetDeadPosition().GetX() < cursorPosition.GetX()) && ( ( static_cast<CDeadPolice*>(*iter)->GetDeadPosition().GetX() + DEAD_POLICE_IMAGE_WIDTH ) > cursorPosition.GetX() );
			bool isInYCoordRange = (static_cast<CDeadPolice*>(*iter)->GetDeadPosition().GetY() < cursorPosition.GetY()) && ( ( static_cast<CDeadPolice*>(*iter)->GetDeadPosition().GetY() + DEAD_POLICE_IMAGE_HEIGHT ) > cursorPosition.GetY() );
			if(isInXCoordRange && isInYCoordRange)
			{
				// 감염확률에 따라 감염된 포돌이 생성, 기본은 POOR_ZOMBIE로, 
				if ( rand()% 100 <= m_pPlayer->GetInfectionRate()) {
					NNPoint deadPosition = static_cast<CDeadPolice*>(*iter)->GetDeadPosition();
					MakeZombie(POOR_ZOMBIE, &deadPosition );
				}

				CCharacter *tmp = *iter;
				m_llistDeadPolice.erase(iter);
				RemoveChild(tmp,true);

				

				m_pPlayer->SetMeatPoint(m_pPlayer->GetMeatPoint() + 10);
				break;
			}
		}
	}
}
Ejemplo n.º 8
0
void CTile::Update( float dTime )
{
	if (CPlayerManager::GetInstance()->GetMyPlayer() == nullptr)
		return;

	NNPoint PlayerPosition = CPlayerManager::GetInstance()->GetMyPlayer()->GetPosition();
	NNPoint TilePosition = this->GetPosition();
	int Width = 200;// NNApplication::GetInstance()->GetScreenWidth();
	int Height = 200;// NNApplication::GetInstance()->GetScreenHeight();

	if (!((TilePosition.GetX() > PlayerPosition.GetX() - Width/2 && TilePosition.GetX() < PlayerPosition.GetX() + Width/2) &&
		(TilePosition.GetY() > PlayerPosition.GetY() - Height / 2 && TilePosition.GetY() < PlayerPosition.GetY() + Height / 2)))
		return;

	NNObject::Update( dTime );
}
Ejemplo n.º 9
0
//버튼위에 마우스가 올려져있는지를 판단. 올려져 있으면 true, 아니면 false
bool CUIButton::CheckButtonOn( void )
{
	NNPoint cursorPosition = NNInputSystem::GetInstance()->GetMousePosition();
	bool isInXCoordRange = (m_Position.GetX() < cursorPosition.GetX()) && ( ( m_Position.GetX() + m_pNormalImage->GetImageWidth() ) > cursorPosition.GetX() );
	bool isInYCoordRange = (m_Position.GetY() < cursorPosition.GetY()) && ( ( m_Position.GetY() + m_pNormalImage->GetImageHeight() ) > cursorPosition.GetY() );

	if ( !(isInXCoordRange && isInYCoordRange) ) 
	{
		m_pNormalImage->SetVisible(true);
		m_pOnImage->SetVisible(false);
		return false;
	} 
	else 
	{
		m_pNormalImage->SetVisible(false);
		m_pOnImage->SetVisible(true);
		
		return true;
	}
	
}
Ejemplo n.º 10
0
 /*
 정인호. 11/20
 광역 공격 처리. 현재 로직은 PlayScene의 모든 Enemy를 리스트로 돌면서
 지정된 SplashRange내부에 있는 적들은 모두 데미지를 받도록 처리함
 */
void CCharacter::SplashAttack( NNPoint splashPoint, clock_t currentTime )
{
	
	 switch (m_Identity)
	 {
	 case ZOMBIE:
		 for (const auto& enemy : *CPlayScene::GetInstance()->GetPoliceList()) {		 
			 if(this->m_SplashAttackRange >= splashPoint.GetDistance(enemy->GetPosition())) {
				 NormalAttack(enemy, currentTime);
			 }
		 }
		 break;
	 case POLICE:
		 for (const auto& enemy : *CPlayScene::GetInstance()->GetZombieList()) {
			 if(this->m_SplashAttackRange >= splashPoint.GetDistance(enemy->GetPosition())) {
				 NormalAttack(enemy, currentTime);
			 }
		 }
		 break;
	 default:
		 break;

	 }
}
Ejemplo n.º 11
0
NNPoint NNPoint::operator-( const NNPoint& point ) const
{
	return NNPoint( this->m_X-point.GetX(), this->m_Y-point.GetY() );
}