private async Task <IGameWorld> GenerateWorld(IWorldMakerListener worldGeneratorListener) { await Task.Delay(1); var outsideArea = new OutsideArea(); var world = new GameWorld(outsideArea) { TileSize = 8 }; var bmp = new Bitmap(AreaWidth, AreaHeight); var tiles = new Tile[AreaWidth, AreaHeight]; for (var i = 0; i < AreaWidth; i++) { for (var j = 0; j < AreaHeight; j++) { tiles[i, j] = new Tile(TileTypes.None, i, j) { GameWorld = world, GameArea = outsideArea }; } } var poo = 0; for (var i = 0; i < AreaWidth; i++) { poo = 0; for (var j = (int)(AreaHeight / 2.0f); j < AreaHeight; j++) { poo++; if (poo > 3) { tiles[i, j].TileType = TileTypes.Stone; bmp.SetPixel(i, j, Color.Gray); } else { tiles[i, j].TileType = TileTypes.Dirt; bmp.SetPixel(i, j, Color.Brown); } } } bmp.Save("Map.png"); worldGeneratorListener.OnWorldGenerationUpdate("Initiating Landing Sequence..."); outsideArea.Tiles = tiles; outsideArea.AreaWidth = AreaWidth; outsideArea.AreaHeight = AreaHeight; return(world); }
public Location(string name, int number, int survivorSpots, int outsideSpots, Canvas canvas) { Name = name; Number = number; SurvivorSpots = survivorSpots; OutsideArea = new OutsideArea { NumberOfBarricades = 0, OutsideSpots = outsideSpots, Zombies = 0 }; Canvas = canvas; ZombieImage = ImageLoader.InitializeMedia(@"Zombie.png"); _barricadeImage = ImageLoader.InitializeMedia(@"Barricade.png"); Deck = new Deck(); }
public IEnumerator UpdateOutsidePosition() { List <ActionCardCtl> InCd = new List <ActionCardCtl>(); foreach (var p in Cards) { if (p.Pos == EventCardPos.Outside) { // if (p.GetComponent<ActionCardCtl>().Pos == type_pos.outside) { InCd.Add(p); } } float insideX = OutsideArea.GetComponent <RectTransform>().rect.width; float cardlistwidth = 66 * (InCd.Count - 1); if (66 * (InCd.Count) > insideX) { for (int f = 0; f < InCd.Count; f++) { float padd = insideX / (InCd.Count + 1); var yy = InCd[f].OutsidePos; yy.x = OutsideArea.transform.localPosition.x - insideX / 2 + f * padd + 20; InCd[f].OutsidePos = yy; yield return(f); } } else { for (int f = 0; f < InCd.Count; f++) { var yy = InCd[f].OutsidePos; yy.x = OutsideArea.transform.localPosition.x - cardlistwidth / 2 + f * 66; InCd[f].OutsidePos = yy; yield return(f); } } yield return(true); }
public void BuildBarricade() { OutsideArea.BuildBarricade(); }
private async Task <IGameWorld> GetWorldFromNetwork(IWorldMakerListener worldGeneratorListener) { await Task.Delay(1000); _tilesReceived = 0; AreaWidth = 200; AreaHeight = 200; _tiles = new Tile[AreaWidth, AreaHeight]; var outsideArea = new OutsideArea() { Tiles = _tiles, AreaWidth = AreaWidth, AreaHeight = AreaHeight, }; var world = new GameWorld(outsideArea) { TileSize = 8 }; for (var i = 0; i < AreaWidth; i++) { for (var j = 0; j < AreaHeight; j++) { _tiles[i, j] = new Tile(TileTypes.None, i, j) { GameWorld = world, GameArea = outsideArea }; } } Bitmap = new Bitmap(AreaWidth, AreaHeight); var mapRequest = new MapRequestPacket(); var toSend = _networkMessagePackager.Package(mapRequest); _networkManager.SendMessage(toSend); while (_tilesReceived < AreaWidth * AreaHeight) { var percent = ((float)_tilesReceived / (AreaWidth * AreaHeight)) * 100; worldGeneratorListener.OnWorldGenerationUpdate($"Receiving tiles... {percent}%"); } worldGeneratorListener.OnWorldGenerationUpdate("Got tiles..."); while (!ReceivedMap) { worldGeneratorListener.OnWorldGenerationUpdate("Waiting for players..."); } foreach (var tile in _tiles) { Bitmap.SetPixel(tile.TileX, tile.TileY, tile.TileType == TileTypes.None ? Color.Black : tile.TileType == TileTypes.Dirt ? Color.White : Color.Orange); } return(world); }