void BlockSet::rotate( RotDirect dir ) { if( baseBlock_ && subBlock_ && canControl() ){ switch( dir ){ case X: { Vector2 subPos; for( int i = 1; i <= 4; ++i ){ subPos = subBlock_->getPosition(); Matrix23 mat; Vector2 basePos = baseBlock_->getPosition(); mat.setTranslation( basePos.x, basePos.y ); mat.rotate( 90 * i ); mat.translate( -basePos.x, -basePos.y ); mat.mul( &subPos, subPos ); int subColumn = Stage::getColumnNumber( subPos.x ); int subNbRow = BlockContainer::getSize( subColumn ); int subMaxY = Stage::HEIGHT - ((subNbRow + 1) * Block::HEIGHT); // 計算誤差を考慮 if( -Block::WIDTH/2 <= subPos.x && subPos.x <= Block::MAX_X + Block::WIDTH/2 && -Block::WIDTH/2 <= subPos.y && subPos.y <= subMaxY + Block::WIDTH/2 ){ break; } } subBlock_->setPosition( subPos ); break; } case INV_X: break; } //! とりあえず、ベースが発行する baseBlock_->ExecuteRoteteEffect(); } }
bool VerbSetStructureActive::canContinueStructure( NounStructure * pStructure, NounShip * pWho ) { if ( ! canControl( pStructure, pWho ) ) return false; if ( ! pStructure->isPaused() ) return false; // structure is not paused return true; }
bool VerbSetStructureActive::canPauseStructure( NounStructure * pStructure, NounShip * pWho ) { if ( ! canControl( pStructure, pWho ) ) return false; if ( pStructure->isPaused() ) return false; // structure already paused NounPlanet * pPlanet = pStructure->planet(); if (! pPlanet ) return false; // not on a planet! if (! pPlanet->canPauseStructure(pStructure) ) return false; // planet won't allow structure to be paused.. return true; }
void BlockSet::move( float x, float y ) { if( canControl() ){ Math::Vector2 basePos; if( baseBlock_ ){ basePos = baseBlock_->getPosition(); basePos += Math::Vector2( x, y ); } if( baseBlock_ && subBlock_ ){ Math::Vector2 subPos = subBlock_->getPosition(); subPos += Math::Vector2( x, y ); //誤差考慮 if( -0.5f <= basePos.x && basePos.x <= static_cast<float>(Block::MAX_X + 0.5f) && -0.5f <= subPos.x && subPos.x <= static_cast<float>(Block::MAX_X + 0.5f) ){ int baseColumn = Stage::getColumnNumber( basePos.x ); int baseNbRow = BlockContainer::getSize( baseColumn ); int baseMaxY = Stage::HEIGHT - ((baseNbRow + 1) * Block::HEIGHT); int subColumn = Stage::getColumnNumber( subPos.x ); int subNbRow = BlockContainer::getSize( subColumn ); int subMaxY = Stage::HEIGHT - ((subNbRow + 1) * Block::HEIGHT); if( -Block::WIDTH <= basePos.y && basePos.y <= baseMaxY && -Block::WIDTH <= subPos.y && subPos.y <= subMaxY ){ baseBlock_->setPosition(basePos); subBlock_->setPosition(subPos); //! とりあえず、ベースが発行する baseBlock_->ExecuteMoveEffect(); } } } // else{ // if( 0 <= basePos.x && basePos.x <= Block::MAX_X ){ // int baseColumn = Stage::getColumnNumber( basePos.x ); // int baseNbRow = BlockContainer::getSize( baseColumn ); // int baseMaxY = Stage::HEIGHT - ((baseNbRow + 1) * Block::HEIGHT); // if( -Block::WIDTH <= basePos.y && basePos.y <= baseMaxY ){ // baseBlock_->setPosition(basePos); // //! とりあえず、ベースが発行する // baseBlock_->ExecuteMoveEffect(); // } // } // } } }