コード例 #1
0
ファイル: Containers.cpp プロジェクト: mmaulwurff/FREG
 bool Workbench::Drop(const int src, const int dest,
         const int num, Inventory* const inv_to)
 {
     if ( inv_to == nullptr
             || src  >= GetSize()
             || dest >= inv_to->GetSize()
             || IsEmpty(src) )
     {
         return false;
     }
     for (int i=0; i<num; ++i) {
         if ( not inv_to->Get(ShowBlock(src), dest) ) return false;
         Pull(src);
         if ( src < Start() ) {
             // remove materials:
             for (int slot=Start(); slot<GetSize(); ++slot) {
                 while ( not IsEmpty(slot) ) {
                     Block* const to_pull = ShowBlock(slot);
                     Pull(slot);
                     delete to_pull;
                 }
             }
         } else {
             Craft();
         }
     }
     return true;
 }
コード例 #2
0
ファイル: Containers.cpp プロジェクト: mmaulwurff/FREG
 void Converter::DoRareAction() {
     if ( isOn && fuelLevel < World::SECONDS_IN_DAY/DamageLevel() ) {
         for (int i=GetSize()-1; i>=0; --i) {
             Block* const block = ShowBlock(i);
             if ( block ) {
                 const int add = ConvertRatio(block->Sub());
                 if ( add > 0 ) {
                     fuelLevel += add;
                     Pull(i);
                     delete block;
                     break;
                 }
             }
         }
     }
     World* const world = World::GetWorld();
     if ( fuelLevel <= 0
             || ( Sub() == STONE
                 && world->GetBlock(X(), Y(), Z()+1)->Sub() == WATER ) )
     {
         Damage(1, damageKindOff);
     } else {
         if (world->Damage(X(), Y(), Z()+1, DamageLevel(), damageKindOn)<=0)
         {
             world->DestroyAndReplace(X(), Y(), Z()+1);
         }
         fuelLevel -= DamageLevel();
     }
 }
コード例 #3
0
void BaseDemo::DrawScene()
{
	SwapChainPtr->Begin();
	ShowBlock(100, 100, 300, 200, { 0, 0, 1, 1 }, mTimer.TotalTime());

	vector<VertexPositionColor> vertices;
	vertices.resize(mClientWidth);
	for (int xval = 0; xval < mClientWidth; ++xval)
	{
		float yval = (float)m_Curve->Evaluate(xval);
		vertices[xval] = DirectX::VertexPositionColor(XMFLOAT3((float)xval, yval, 0.0f), XMFLOAT4(0.5f, 1.0f, 0.5f, 1));
	}
	XMMATRIX toTexSpace = GetShow2DMatrix(mClientWidth, mClientHeight);
	DrawPrimitiveUP(PRIMITIVE_LINESTRIP, mClientWidth, &vertices[0], toTexSpace);

	static int kkkkkk = 0;
	if (kkkkkk >= mClientWidth - 1)
	{
		kkkkkk = 0;
	}
	else
	{
		kkkkkk++;
	}
	int xPos = (int)vertices[kkkkkk].position.x;
	int yPos = (int)vertices[kkkkkk].position.y;

	ShowBlock(xPos - 5, yPos - 5, xPos + 5, yPos + 5, XMFLOAT4(DirectX::Colors::Blue));

	for (int i = 0; i < m_Curve->Size(); ++i)
	{
		int xPos = (int)m_Curve->Key(i);// +mClientWidth / 2;
		int yPos = (int)m_Curve->Value(i);
		ShowBlock(xPos - 5, yPos - 5, xPos + 5, yPos + 5, XMFLOAT4(DirectX::Colors::Red));
	}

	SwapChainPtr->Flip();
}