因此,我正在製作基於平鋪的遊戲,並且我想爲這些貼磚添加一些假陰影。這是有點難以解釋,所以我會用圖片做:我如何有效地製作假瓷磚陰影?
比方說,這是我的瓷磚世界:
而且我希望它有一個像這樣的陰影:
因爲世界是基於瓦,我可以將所有的陰影部分拆分成獨立的圖像:
但現在我不知道如何將它帶入代碼。其實,我確實有想法,但它們令人難以置信,而且它們不能以最佳方式工作。
我已經嘗試了大量的if語句...
bool ul = adjacentBlocks[0, 0] == Block.Type.Rock; //Upper Left
bool um = adjacentBlocks[1, 0] == Block.Type.Rock; //Upper Middle
bool ur = adjacentBlocks[2, 0] == Block.Type.Rock; //Upper Right
bool ml = adjacentBlocks[0, 1] == Block.Type.Rock; //Center Left
//bool cm = adjacentBlocks[1, 1] == Block.Type.Rock; //CURRENT BLOCK - NOT NEEDED
bool mr = adjacentBlocks[2, 1] == Block.Type.Rock; //Center Right
bool ll = adjacentBlocks[0, 2] == Block.Type.Rock; //Lower Left
bool lm = adjacentBlocks[1, 2] == Block.Type.Rock; //Lower Middle
bool lr = adjacentBlocks[2, 2] == Block.Type.Rock; //Lower Right
if (ml) { texture = "Horizontal"; flipX = false; flipY = false; }
if (mr) { texture = "Horizontal"; flipX = true; flipY = false; }
if (um) { texture = "Vertical"; flipX = false; flipY = false; }
if (lm) { texture = "Vertical"; flipX = false; flipY = true; }
if (ml && ul && um) texture = "HorizontalVertical";
//More if statements I can't be bothered to write
if (ul && um && ur && ml && mr && ll && lm & lr) texture = "Full";
和龐大的查找表...
var table = new List<TextureBlockLayout>
{
new TextureBlockLayout("Horizontal", false, false, new[,]
{
{ true, true, false },
{ true, true, false },
{ true, true, false }
}),
new TextureBlockLayout("Horizontal", true, false, new[,]
{
{ false, true, true },
{ false, true, true },
{ false, true, true }
}),
new TextureBlockLayout("Full", false, false, new[,]
{
{ true, true, true },
{ true, true, true },
{ true, true, true }
})
};
但無論我做錯事或者他們只是拒絕一起工作。有任何想法嗎?
你說的「他們拒絕在所有的工作」是什麼意思? – millimoose
基本上他們給完全錯誤的陰影紋理。 – Dlaor
好的,但由於您沒有列出任何繪圖代碼,「完全錯誤」並沒有多大幫助。 – millimoose