public Border CreateSpriteVBorder(string id, Vector2 pos, Vector2 size, Transform parentTransform, bool bTop) { var coef = bTop ? 0.5f : -0.5f; var border = EGHelpers.CreateSpriteByScript <Border>(new Vector2(pos.x, pos.y + coef * size.y), _gameLevel.border, "vBorder" + id, parentTransform, "Border"); border.GetComponent <SpriteRenderer>().color = new Color(0.1f, 0.1f, 0.1f); border.transform.localScale = new Vector3(size.x * 100f / _gameLevel.border.rect.width, size.y * 100f / _gameLevel.border.rect.height, 1.0f); return(border); }
public bool Load(FullSerializer.fsData jsIsland) { var jsIslandData = jsIsland.AsDictionary; Id = (int)jsIslandData["id"].AsInt64; var islandPos = GameLevelJsonLoader.GetPos(jsIslandData["pos"]); var size = GameLevelJsonLoader.GetSize(jsIslandData["size"]); var resIndex = jsIslandData["res"].AsInt64; Pos = islandPos; Size = size; // back var sprite = _gameLevel.spriteLevelBack[(int)resIndex]; var backObj = EGHelpers.CreateSprite(Pos, sprite, "back_" + Id, _parentTransform, false); DebugLogger.WriteInfo("Island.Load sprite.rect = " + sprite.rect.ToString()); backObj.transform.localScale = new Vector3(Size.x * 100f / sprite.rect.width, Size.y * 100f / sprite.rect.height, 1f); var sprRender = backObj.GetComponent <SpriteRenderer>(); sprRender.sortingOrder = -2; if (jsIslandData.ContainsKey("backMesgColor")) { var sBackMesgColor = jsIslandData["backMesgColor"].AsString; float[] colors = sBackMesgColor.Split <float>(','); sprRender.color = new Color(colors[0], colors[1], colors[2]); } if (jsIslandData.ContainsKey("trees")) { var jsTreeList = jsIslandData["trees"].AsList; foreach (var jsTree in jsTreeList) { var jsTreeData = jsTree.AsDictionary; var treePos = GameLevelJsonLoader.GetPos(jsTreeData["pos"]); var treeObj = EGHelpers.CreateSpriteByScript <Tree>(islandPos + treePos, _gameLevel.spriteTree, "tree", _parentTransform, GameLevel.TerrainTagName); } } return(true); }