public static GameFieldBlock Create(GameField field, EnumBlockType type, EnumBlockDirection direction) { var block = new GameFieldBlock(); block.type = type; block.direction = direction; var path = "field_items/blocks/"; if (type == EnumBlockType.barrier) { path += string.Format("barrier_{0}", direction); } else { path += type; } block.obj = Assets.TryReuse(path, parent: field.transform); Error.Verify(block.obj != null); var pos = new Vector2(); var border = direction == EnumBlockDirection.up ? field.upper_left_border : field.bottom_left_border; var blocks = direction == EnumBlockDirection.up ? field.blocks.GetUpperBlocks() : field.blocks.GetBottomBlocks(); GameFieldBlock last_block = null; if (blocks != null && blocks.Count > 0) { last_block = blocks[blocks.Count - 1]; } pos.x = last_block != null ? last_block.obj.transform.position.x + block.obj.transform.localScale.x : border.x; pos.y = border.y; block.obj.transform.position = pos; return(block); }