#include "stdafx.h" #include "SGameOtherPlayer.h" #include "KSeqModel.h" #include "SGameViewPort.h" #include "GameDefine.h" #include "SGameMessage.h" #include "SAvatarStateMachine.h" bool SGameOtherPlayer::m_bUseStoreModel = false; int SGameOtherPlayer::m_nBoothRenderType = BOOTH_TYPE::RENDER_AVATAR_BOOTH; SGameOtherPlayer::SGameOtherPlayer() : SGamePlayer() , m_bActivateBattleInArena( false ) { m_pStateVM = new SOtherPlayerStateMachine; //상태 머신 m_pStateVM->SetReceiver( this ); m_bIsRequestedBoothName = false; m_pStoreModel = NULL; } SGameOtherPlayer::~SGameOtherPlayer() { SAFE_DELETE( m_pStoreModel ); } void SGameOtherPlayer::SetStatus( unsigned status ) { bool bIsBooth = IsBooth(); SGameAvatarEx::SetStatus( status ); // 노점이었다가 노점이 아니게 되었으므로 노점이름을 지운다. if( bIsBooth && !IsBooth() ) { SetBoothName( "" ); m_bIsRequestedBoothName = false; DeleteRenderBooth(); } } void SGameOtherPlayer::onChangeBoothName() { SMSG_BOOTH_NAME_CHANGED msg( GetArID(), GetBoothName() ); // UI 에 알려줘야함 SendGameMsg( &msg ); } bool SGameOtherPlayer::IsNeedBoothName( DWORD time ) { if( !IsBooth() ) return false; float fDistance = ( *GetPosition() - *m_pLocalPlayer->GetPosition() ).Magnitude(); // 노점 이름이 보일만큼 가까이 있다면.. if( VIEW_NAME_PLATE_CULL_SIZE * 0.7 > fDistance ) { if( GetBoothName().empty() && !m_bIsRequestedBoothName ) { m_bIsRequestedBoothName = true; return true; } } else { m_bIsRequestedBoothName = false; } return false; } bool SGameOtherPlayer::IsOtherPlayerBooth() { if( GetStatus() & TS_ENTER::PlayerInfo::FLAG_SELL_BOOTH || GetStatus() & TS_ENTER::PlayerInfo::FLAG_BUY_BOOTH ) return true; else return false; } bool SGameOtherPlayer::Render( unsigned long uRenderBitVector, class KViewportObject** ppViewportList, int nViewportCount) { /// 2011.04.20 거대화 - prodongi float scale; K3DMatrix mat; beginScaling(scale, mat); _renderThread(); /// 2011.04.20 스케일링이 들어가면서 수정됨 - prodongi // if( !m_bVisible || !m_bIsActivated || !m_bIsInit || !m_xRenderFlag.IsOn( AV_BASIC ) ) return false; if( !m_bVisible || !m_bIsActivated || !m_bIsInit || !m_xRenderFlag.IsOn( AV_BASIC ) ) { SetTransformPure(mat); return false; } if( IsPendLoading() ) return false; //판매 노점 추가로 판매 노점도 상점으로 랜더링 되어야 한다. -N4- if( IsOtherPlayerBooth() ) { bool bModelRender = false; switch( m_nBoothRenderType ) { case BOOTH_TYPE::RENDER_NONE_BOOTH: return true; //상점모드 중일 때 랜더링을 전혀 안하겠다는 것 case BOOTH_TYPE::RENDER_SIMPLE_BOOTH: bModelRender = true; break; //간단한 리소스 상점을 랜더 case BOOTH_TYPE::RENDER_DETAIL_BOOTH: bModelRender = true; break; //기존의 상점 리소스로 랜더 case BOOTH_TYPE::RENDER_AVATAR_BOOTH: break; //그냥 아바타로 랜더 } if( bModelRender ) { if( m_pStoreModel ) { if( nViewportCount >= 1 && ppViewportList[0] && ppViewportList[0]->GetAttributes() & KViewportObject::VIEWPORT_GAME) { m_pStoreModel->SetTransform( *GetTransform() ); m_pStoreModel->Render( ppViewportList[0] ); } } endScaling( scale, mat ); return true; } } /// 2012.08.09 _renderEffectLoading에서 아이템 데이타가 바뀔 수 있기 때문에, _renderAvatar 보다 먼저 호출 되어야 된다 - prodongi _renderEffectLoading(); _renderAvatar( uRenderBitVector, ppViewportList, nViewportCount ); _renderEtc( uRenderBitVector, ppViewportList, nViewportCount ); /// 2011.04.20 거대화 - prodongi endScaling(scale, mat); return true; } bool SGameOtherPlayer::Process( DWORD time, unsigned long uProcessBitVector ) { //상점일때도 Process는 처리돼야함 SGamePlayer::Process( time, uProcessBitVector ); //판매 노점 추가로 판매 노점도 상점으로 랜더링 되어야 한다. -N4- if( IsOtherPlayerBooth() ) { bool bStoreModelProcess = false; switch( m_nBoothRenderType ) { case BOOTH_TYPE::RENDER_NONE_BOOTH: return true; case BOOTH_TYPE::RENDER_SIMPLE_BOOTH: bStoreModelProcess = true; break; case BOOTH_TYPE::RENDER_DETAIL_BOOTH: bStoreModelProcess = true; break; case BOOTH_TYPE::RENDER_AVATAR_BOOTH: break; } if( bStoreModelProcess ) { if( m_pStoreModel ) m_pStoreModel->Process( time ); else CreateRenderBooth(); return true; } } // SGamePlayer::Process( time, uProcessBitVector ); return true; } void SGameOtherPlayer::CreateRenderBooth() { switch( m_nBoothRenderType ) { case BOOTH_TYPE::RENDER_NONE_BOOTH: break; case BOOTH_TYPE::RENDER_SIMPLE_BOOTH: { SAFE_DELETE( m_pStoreModel ); NX3LoadPack loadpack; loadpack.Init(); m_pStoreModel = new KSeqModel; m_pStoreModel->AddAnimation( "default", "etc_stall_simple.nx3", KNX3Manager::SEQTYPE_ALL, &loadpack ); m_pStoreModel->PlayAnimation( m_dwTime, "default", SEQTYPE_LOOP ); } break; case BOOTH_TYPE::RENDER_DETAIL_BOOTH: { SAFE_DELETE( m_pStoreModel ); NX3LoadPack loadpack; loadpack.Init(); m_pStoreModel = new KSeqModel; m_pStoreModel->AddAnimation( "default", "common_store.nx3", KNX3Manager::SEQTYPE_ALL, &loadpack ); m_pStoreModel->PlayAnimation( m_dwTime, "default", SEQTYPE_LOOP ); } break; } } void SGameOtherPlayer::DeleteRenderBooth() { SAFE_DELETE( m_pStoreModel ); }