예제 #1
0
파일: fight.cpp 프로젝트: q4a/attal
void Fight::moveUnit( FightCell * cell )
{
	GenericFightCell * current;
	QStack<GenericFightCell> path = _map->computePath( _activeUnit, cell );

	while( ! path.isEmpty() ) {
		current = path.pop();
		_socket->sendFightUnitMove( giveClass( _activeUnit ), giveNum( _activeUnit ), current );
	}

	_socket->sendFightUnitEndMove();
	_activeUnit->setActive( false );
	_map->clearPath();
}
예제 #2
0
파일: fight.cpp 프로젝트: q4a/attal
void Fight::slot_mouseLeftPressed( FightCell * cell )
{
	if( _activeUnit && _isActive ) {
		switch( cell->getAccess() ) {
		case NEAR:
			moveUnit( cell );
			break;
		case NEAR_OCCUPIED:
			moveUnit( cell );
			break;
		case FAR_OCCUPIED:
			if( ( _activeUnit->getDistAttack() > 0 ) && ( isOpponent( cell->getUnit() ) ) ) {
				_socket->sendFightDistAttack( giveClass( cell->getUnit() ), giveNum( cell->getUnit() ) );
				_socket->sendFightUnitEndMove();
			}
			break;
		default:
			break;
		}
	}
}
예제 #3
0
파일: fight.cpp 프로젝트: q4a/attal
void Fight::slot_mouseLeftPressed( FightCell * cell, bool isUnit )
{

	AttalPopup * popup = this->findChild<AttalPopup *>("AttalFightPopup");
	
	if( popup && popup->isVisible() ) {
		popup->hide();
		popup->setType();
		return;
	}

	AttalCommon::FightCellAccess access = cell->getAccess();
	TRACE("left pressed cell access %d, active unit %p , isActive %d", access, _activeUnit, _isActive);
	TRACE("cell->getUnit %p, isUnit %d dist %d", cell->getUnit(), isUnit, cell->getDist() );
	TRACE("cell row %d, col %d", cell->getRow(), cell->getCol() );
	
	GenericFightCell * neib = NULL;
	GenericFightUnit * oppunit = cell->getUnit();

	if( oppunit && !isOpponent( oppunit )  ) {
		return;
	}
	
	if( _activeUnit && _isActive ) {

		switch( access ) {
			case AttalCommon::NEAR_FREE :
				TRACE("NEAR_FREE");
				moveUnit( cell );
				break;
			case AttalCommon::NEAR_OCCUPIED:
				TRACE("NEAR_OCCUPIED");
				if( _activeUnit->getDistAttack() > 0 && oppunit ) {
					_socket->sendFightDistAttack( giveClass( oppunit ), giveNum( oppunit ) );
					_socket->sendFightUnitEndMove();
				} else if ( oppunit  ) {
					moveUnit( cell );
				} else {
					neib = _map->getHeadCell( cell ,_activeUnit->isLookingToRight() );

					if( neib ) {
						oppunit = neib->getUnit();
						if ( ( oppunit ) && ( isOpponent ( oppunit  ) ) ) {
							moveUnit( neib );
						}
					}
				}
				break;
			case AttalCommon::FAR_OCCUPIED:
				TRACE("FAR_OCCUPIED");
				if( ( oppunit ) && ( _activeUnit->getDistAttack() > 0 ) ) {
					_socket->sendFightDistAttack( giveClass( oppunit ), giveNum( oppunit ) );
					_socket->sendFightUnitEndMove();
				} else {
					neib = _map->getHeadCell( cell , !_activeUnit->isLookingToRight() );
					if( neib ) {
						oppunit = neib->getHeadUnit();
						if( oppunit && neib->getAccess()== AttalCommon::NEAR_OCCUPIED  && ( isOpponent ( oppunit  ) ) ) {
							moveUnit( neib );
						}
					}
				}
				break;
			default:
				break;
		}
	}
}
예제 #4
0
파일: Main.c 프로젝트: Andreiphontes/CMake
int main(int argc, const char* argv[])
{
  int out;
  out = giveNum();
  return out;
}