//SH Add 20130908, GraphicBlockType mapping to BlockType public static BlockType GetBlockType(BlockGraphicType graphicType) { switch (graphicType) { case BlockGraphicType.River_BL: case BlockGraphicType.River_BR: case BlockGraphicType.River_TL: case BlockGraphicType.River_TR: return(BlockType.River); case BlockGraphicType.Sand: return(BlockType.Sand); case BlockGraphicType.Hole: return(BlockType.Hole); case BlockGraphicType.House: return(BlockType.House); case BlockGraphicType.Pyramid: return(BlockType.Pyramid); default: return(BlockType.Sand); } }
private static GameObject GenerateBlock(BlockGraphicType graphicType, int x, int y) { GameObject newBlock = null; switch (graphicType) { case BlockGraphicType.Sand: newBlock = GameObject.Instantiate(Resources.Load(Const.DIR_Prefab + "Sand")) as GameObject; break; case BlockGraphicType.River_TL: newBlock = GameObject.Instantiate(Resources.Load(Const.DIR_Prefab + "River_TL")) as GameObject; break; case BlockGraphicType.River_TR: newBlock = GameObject.Instantiate(Resources.Load(Const.DIR_Prefab + "River_TR")) as GameObject; break; case BlockGraphicType.River_BL: newBlock = GameObject.Instantiate(Resources.Load(Const.DIR_Prefab + "River_BL")) as GameObject; break; case BlockGraphicType.River_BR: newBlock = GameObject.Instantiate(Resources.Load(Const.DIR_Prefab + "River_BR")) as GameObject; break; case BlockGraphicType.Hole: newBlock = GameObject.Instantiate(Resources.Load(Const.DIR_Prefab + "Hole")) as GameObject; if (firstHolePos == null) { firstHolePos = new IVector2(x, y); } else { secondHolePos = new IVector2(x, y); } if (firstHolePos != null && secondHolePos != null) { _generatedHoleData.Add(firstHolePos, secondHolePos); _generatedHoleData.Add(secondHolePos, firstHolePos); } break; case BlockGraphicType.House: newBlock = GameObject.Instantiate(Resources.Load(Const.DIR_Prefab + "House")) as GameObject; break; case BlockGraphicType.Pyramid: newBlock = GameObject.Instantiate(Resources.Load(Const.DIR_Prefab + "Pyramid")) as GameObject; break; } if (newBlock) { float xPos = offset_x / 2f + Tile_Width * x; float yPos = offset_y / 2f - Tile_Height * y; OTSprite sprite = newBlock.GetComponent <OTSprite>(); sprite.position = new Vector2(xPos, yPos); sprite.size = new Vector2(Tile_Width, Tile_Height); newBlock.transform.parent = root.transform; } return(newBlock); }