Last active
February 22, 2020 12:35
-
-
Save abebemukuru/3b2b358dc0ceab0b384be35814a68270 to your computer and use it in GitHub Desktop.
部屋作成
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// シーケンス 部屋作成 | |
/// </summary> | |
private void SeqCreateRoom() | |
{ | |
FieldData cPivotData = null; | |
for(int i = 0;i < m_aRoomData.Length;++i ) | |
{ | |
// 部屋の基準位置(部屋の左下を基準とする) | |
int nPivotWidth = Random.Range( 0,m_nWidth ); | |
int nPivotHeight = Random.Range( 0,m_nHeight ); | |
bool bSuccess = false; | |
var cRoomData = m_aRoomData[ i ]; | |
while( !bSuccess ) | |
{ | |
cPivotData = GetFieldData( nPivotWidth,nPivotHeight ); | |
if( cPivotData == null ) | |
{ | |
nPivotWidth = Random.Range( 0,m_nWidth ); | |
nPivotHeight = Random.Range( 0,m_nHeight ); | |
continue; | |
} | |
// 部屋生成ができるかどうか | |
if( !IsCreateRoom( cPivotData.m_nPosX,cPivotData.m_nPosY,cRoomData.m_nWidth,cRoomData.m_nHeight ) ) | |
{ | |
nPivotWidth = Random.Range( 0,m_nWidth ); | |
nPivotHeight = Random.Range( 0,m_nHeight ); | |
continue; | |
} | |
bSuccess = true; | |
} | |
// タイプを部屋に変更 | |
for( int x = 0; x < cRoomData.m_nWidth; ++x ) | |
{ | |
for( int y = 0; y < cRoomData.m_nHeight; ++y ) | |
{ | |
int nX = x + cPivotData.m_nPosX; | |
int nY = y + cPivotData.m_nPosY; | |
var cData = GetFieldData( nX,nY ); | |
cData.m_eType = EFIELD_TYPE.eROOM; | |
// 配列Index取得 | |
int nIndex = GetFieldDataIndex( nX,nY ); | |
// 格納 | |
cRoomData.m_lstFieldIndex.Add( nIndex ); | |
} | |
} | |
// 部屋データに格納 | |
m_lstRoomData.Add( new RoomData( cRoomData ) ); | |
} | |
// 道作成へ遷移 | |
m_cSeqController.ChangeState( (int)ESEQ_TYPE.eCREATE_PATH ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment