public void Initialize() { _player = _playerFilter.Components1[0]; _map = _world.CreateEntityWith <MapComponent>(); _map.LastCoords = new CubeCoords(0, 0); _map.PoolB = PoolContainer.CreatePool(Utils.BackPrefabPath); _map.PoolF = PoolContainer.CreatePool(Utils.ForePrefabPath); MapGenRandomNeighbours.GenerateMap(out _map.MapB, out _map.MapF, MapSize, MapSeed); RenderFull(new CubeCoords(0, 0), Fow); }
public void RenderHexBackground(CubeCoords coords) { if (!_map.MapB.ExistAt(coords) || _map.MapB[coords.x, coords.y].IsNew) { MapGenRandomNeighbours.GenerateHex(coords, _map.MapB, _map.MapF); } HexBackgroundComponent hexComponent = _map.MapB[coords.x, coords.y]; if (hexComponent.Parent != null) { return; //_poolBackground.Recycle(hexComponent.Parent); } hexComponent.Parent = _map.PoolB.Get(); hexComponent.Parent.PoolTransform.localPosition = HexMath.Hex2Pix(coords, HexSize); switch (hexComponent.BackgroundType) { case BackroundTypes.Grass: hexComponent.Parent.PoolTransform.GetComponent <SpriteRenderer>().sprite = Grass; hexComponent.SpeedDown = 1; break; case BackroundTypes.Water: hexComponent.Parent.PoolTransform.GetComponent <SpriteRenderer>().sprite = Water; hexComponent.SpeedDown = 0.1f; break; case BackroundTypes.Swamp: hexComponent.Parent.PoolTransform.GetComponent <SpriteRenderer>().sprite = Swamp; hexComponent.SpeedDown = 0.02f; break; case BackroundTypes.Forest: hexComponent.Parent.PoolTransform.GetComponent <SpriteRenderer>().sprite = Forest; hexComponent.SpeedDown = 0.5f; break; default: throw new Exception("Null ground type"); } hexComponent.Parent.PoolTransform.gameObject.SetActive(true); }