資源上的浪費.

嘗試做 Dungeon Editor 的時候.
從 OOP 的層面想, 每個 block 需要知道每個鄰近的 block 是甚麼所以弄了一個 list 把 26 個 block 都放進去.

#region variable
List<IBlock> mNeighbor = new List<IBlock>(26);
#endregion

#region getter/setter
// Upper level
// 00,01,02
// 03,04,05
// 06,07,08
public bool IsEmptyUNW		{get{return ReferenceEquals(null,mNeighbor[0]);}}
public bool IsEmptyUN		{get{return ReferenceEquals(null,mNeighbor[1]);}}
public bool IsEmptyUNE		{get{return ReferenceEquals(null,mNeighbor[2]);}}
public bool IsEmptyUW		{get{return ReferenceEquals(null,mNeighbor[3]);}}
public bool IsEmptyU		{get{return ReferenceEquals(null,mNeighbor[4]);}}
public bool IsEmptyUE		{get{return ReferenceEquals(null,mNeighbor[5]);}}
public bool IsEmptyUSW		{get{return ReferenceEquals(null,mNeighbor[6]);}}
public bool IsEmptyUS		{get{return ReferenceEquals(null,mNeighbor[7]);}}
public bool IsEmptyUSE		{get{return ReferenceEquals(null,mNeighbor[8]);}}

// Current level
// 09,10,11
// 12,  ,13
// 14,15,16
public bool IsEmptyNW		{get{return ReferenceEquals(null,mNeighbor[9]);}}
public bool IsEmptyN		{get{return ReferenceEquals(null,mNeighbor[10]);}}
public bool IsEmptyNE		{get{return ReferenceEquals(null,mNeighbor[11]);}}
public bool IsEmptyW		{get{return ReferenceEquals(null,mNeighbor[12]);}}
public bool IsEmpty			{get{return transform.childCount==0;}}
public bool IsEmptyE		{get{return ReferenceEquals(null,mNeighbor[13]);}}
public bool IsEmptySW		{get{return ReferenceEquals(null,mNeighbor[14]);}}
public bool IsEmptyS		{get{return ReferenceEquals(null,mNeighbor[15]);}}
public bool IsEmptySE		{get{return ReferenceEquals(null,mNeighbor[16]);}}

// Lower level
// 17,18,19
// 20,21,22
// 23,24,25
public bool IsEmptyLNW		{get{return ReferenceEquals(null,mNeighbor[17]);}}
public bool IsEmptyLN		{get{return ReferenceEquals(null,mNeighbor[18]);}}
public bool IsEmptyLNE		{get{return ReferenceEquals(null,mNeighbor[19]);}}
public bool IsEmptyLW		{get{return ReferenceEquals(null,mNeighbor[20]);}}
public bool IsEmptyL		{get{return ReferenceEquals(null,mNeighbor[21]);}}
public bool IsEmptyLE		{get{return ReferenceEquals(null,mNeighbor[22]);}}
public bool IsEmptyLSW		{get{return ReferenceEquals(null,mNeighbor[23]);}}
public bool IsEmptyLS		{get{return ReferenceEquals(null,mNeighbor[24]);}}
public bool IsEmptyLSE		{get{return ReferenceEquals(null,mNeighbor[25]);}}

這是一個不成熟的 mindset 弄出來的東東. 26 個 list 即代表有 26*4byte = 104byte 的資訊.有 100 個 block 就有 1kb 多的資料…

基本上要做到同樣效果可以經旁邊的 block 用類似 link list 的方式回傳給 target , 目的地的資料.

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

*

這個網站採用 Akismet 服務減少垃圾留言。進一步瞭解 Akismet 如何處理網站訪客的留言資料