コード例 #1
0
ファイル: ounita.cpp プロジェクト: 112212/7k2
//-------- Begin of function UnitArray::unit_class_size --------//
//
// Return the size of the class.
//
int UnitArray::unit_class_size(int unitId)
{
	UnitInfo* unitInfo = unit_res[unitId];

	switch(unitId)
	{
		case UNIT_CARAVAN:
			return sizeof(UnitCaravan);

//		case UNIT_VESSEL:
//		case UNIT_TRANSPORT:
//		case UNIT_CARAVEL:
//		case UNIT_GALLEON:
//			return sizeof(UnitMarine);

		case UNIT_WAGON:
			return sizeof(UnitWagon);
			break;

		case UNIT_EXPLOSIVE_CART:
			return sizeof(UnitExpCart);

		default:
			if( unitInfo->is_monster() )
				return sizeof(UnitMonster);

			else if( god_res.is_god_unit(unitId) )
				return sizeof(UnitGod);

			else
				return sizeof(Unit);
	}
}
コード例 #2
0
ファイル: ounita.cpp プロジェクト: 112212/7k2
//-------- Begin of function UnitArray::create_unit --------//
//
Unit* UnitArray::create_unit(int unitId)
{
	Unit* 	 unitPtr;
	UnitInfo* unitInfo = unit_res[unitId];

	switch(unitId)
	{
		case UNIT_CARAVAN:
			unitPtr = new UnitCaravan;
			break;

//		case UNIT_VESSEL:
//		case UNIT_TRANSPORT:
//		case UNIT_CARAVEL:
//		case UNIT_GALLEON:
//			unitPtr = new UnitMarine;
//			break;

		case UNIT_WAGON:
			unitPtr = new UnitWagon;
			break;

		case UNIT_EXPLOSIVE_CART:
			unitPtr = new UnitExpCart;
			break;

		default:
			if( unitInfo->is_monster() )
				unitPtr = new UnitMonster;

			else if( god_res.is_god_unit(unitId) )
				unitPtr = new UnitGod;

			else
				unitPtr = new Unit;
	}

	SpriteArray::add(unitPtr);			// it set Sprite::sprite_recno

 	return unitPtr;
}