//是否為空 bool isEmpty(int x, int y) { TileMapValue tile = (TileMapValue)tileData.getTileMapValue(x, y); return(tile == TileMapValue.None || tile == TileMapValue.Player || tile == TileMapValue.Monster || tile == TileMapValue.Money || tile == TileMapValue.FakeBick || tile == TileMapValue.Destination); }
//建立「箭頭圖」 void buildArrowMap() { Debug.Log("buildArrowMap()"); //初始化為None for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { arrowMap[remap(x, y)] = (byte)Arrow.None; } } for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { TileMapValue tile = (TileMapValue)tileData.getTileMapValue(x, y); switch (tile) { case TileMapValue.Brick: case TileMapValue.Stone: //方塊的上面是否為通道 if (isInMap(x, y + 1) && !isBlock(x, y + 1)) { int t3 = (byte)Arrow.Dot; if (isInMap(x + 1, y + 1) && !isBlock(x + 1, y + 1)) { t3 = t3 + (byte)Arrow.Right; } if (isInMap(x - 1, y + 1) && !isBlock(x - 1, y + 1)) { t3 = t3 + (byte)Arrow.Left; } arrowMap[remap(x, y + 1)] = (byte)t3; //右上是否為JumpPoint if (checkIsJumpPoint(x + 1, y + 1)) { arrowMap[remap(x + 1, y + 1)] = (byte)(Arrow.JumpPoint); } //左上是否為JumpPoint if (checkIsJumpPoint(x - 1, y + 1)) { arrowMap[remap(x - 1, y + 1)] = (byte)(Arrow.JumpPoint); } } break; case TileMapValue.Rope: //下邊是否為JP if (checkIsJumpPoint(x, y - 1)) { arrowMap[remap(x, y - 1)] = (byte)(Arrow.JumpPoint); } //右邊是否為JP if (checkIsJumpPoint(x + 1, y)) { arrowMap[remap(x + 1, y)] = (byte)(Arrow.JumpPoint); } //左邊是否為JP if (checkIsJumpPoint(x - 1, y)) { arrowMap[remap(x - 1, y)] = (byte)(Arrow.JumpPoint); } //中間為那種通道 int t1 = (byte)Arrow.Dot; if (isInMap(x, y - 1) && !isBlock(x, y - 1)) { t1 = t1 + (byte)Arrow.Down; } if (isInMap(x + 1, y) && !isBlock(x + 1, y)) { t1 = t1 + (byte)Arrow.Right; } if (isInMap(x - 1, y) && !isBlock(x - 1, y)) { t1 = t1 + (byte)Arrow.Left; } arrowMap[remap(x, y)] = (byte)t1; break; case TileMapValue.Ladder: //右邊是否為JumpPoint if (checkIsJumpPoint(x + 1, y)) { arrowMap[remap(x + 1, y)] = (byte)(Arrow.JumpPoint); } //左邊是否為JumpPoint if (checkIsJumpPoint(x - 1, y)) { arrowMap[remap(x - 1, y)] = (byte)(Arrow.JumpPoint); } //上邊是否為通道 if (isInMap(x, y + 1) && !isBlock(x, y + 1)) { int temp = (byte)Arrow.Down; if (isInMap(x + 1, y + 1) && !isBlock(x + 1, y + 1)) { temp = temp + (byte)Arrow.Right; } if (isInMap(x - 1, y + 1) && !isBlock(x - 1, y + 1)) { temp = temp + (byte)Arrow.Left; } arrowMap[remap(x, y + 1)] = (byte)temp; //右上是否為JP if (checkIsJumpPoint(x + 1, y + 1)) { arrowMap[remap(x + 1, y + 1)] = (byte)Arrow.JumpPoint; } //左上是否為JP if (checkIsJumpPoint(x - 1, y + 1)) { arrowMap[remap(x - 1, y + 1)] = (byte)Arrow.JumpPoint; } } //下邊是否為JP if (isInMap(x, y - 1) && !isBlock(x, y - 1)) { if (checkIsJumpPoint(x, y - 1)) { arrowMap[remap(x, y - 1)] = (byte)Arrow.JumpPoint; } //右下是否為JP if (checkIsJumpPoint(x + 1, y - 1)) { arrowMap[remap(x + 1, y - 1)] = (byte)Arrow.JumpPoint; } //左下是否為JP if (checkIsJumpPoint(x - 1, y - 1)) { arrowMap[remap(x - 1, y - 1)] = (byte)Arrow.JumpPoint; } } //中間為那種通道 int t2 = (byte)Arrow.Dot; if (isInMap(x, y + 1) && !isBlock(x, y + 1)) { t2 = t2 + (byte)Arrow.Up; } if (isInMap(x, y - 1) && !isBlock(x, y - 1)) { t2 = t2 + (byte)Arrow.Down; } if (isInMap(x + 1, y) && !isBlock(x + 1, y)) { t2 = t2 + (byte)Arrow.Right; } if (isInMap(x - 1, y) && !isBlock(x - 1, y)) { t2 = t2 + (byte)Arrow.Left; } arrowMap[remap(x, y)] = (byte)t2; break; } } } }
public bool isNull(int x, int y) { TileMapValue tile = (TileMapValue)tileData.getTileMapValue(x, y); return(tile == TileMapValue.None); }
public bool isRope(int x, int y) { TileMapValue tile = (TileMapValue)tileData.getTileMapValue(x, y); return(tile == TileMapValue.Rope); }
public bool isLadder(int x, int y) { TileMapValue tile = (TileMapValue)tileData.getTileMapValue(x, y); return(tile == TileMapValue.Ladder); }
public bool isBrick(int x, int y) { TileMapValue tile = (TileMapValue)tileData.getTileMapValue(x, y); return(tile == TileMapValue.Brick); }
public bool isBlock(int x, int y) { TileMapValue tile = (TileMapValue)tileData.getTileMapValue(x, y); return((tile == TileMapValue.Brick) || (tile == TileMapValue.Stone)); }