private void GenerateMap() { List <string> itemsInMap = new List <string>(AllItems.Keys); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if ((i == 4 || i == 5) && (j == 4 || j == 5)) { Map[i, j] = new HomeTile(i, j); } else { if (rand.Next(1, 5) >= 3) { Map[i, j] = new ExploreTile(i, j, AllItems[itemsInMap[rand.Next(0, itemsInMap.Count - 1)]], AllResources[rand.Next(1, 5)], rand.Next(1, 5)); } else { Map[i, j] = new ExploreTile(i, j, AllResources[rand.Next(1, 5)], rand.Next(1, 5)); } } } } }
private void generateMap() { int startingX = 25; int startingY = 25; foreach (WorldTile t in currentGame.Map) { checkBoxes[t.posX, t.posY] = new CheckBox(); groupBoxMap.Controls.Add(checkBoxes[t.posX, t.posY]); checkBoxes[t.posX, t.posY].Width = 15; checkBoxes[t.posX, t.posY].Height = 15; checkBoxes[t.posX, t.posY].Anchor = (AnchorStyles.Left | AnchorStyles.Top); checkBoxes[t.posX, t.posY].Location = new Point((t.posX * 20) + startingX, (t.posY * 20) + startingY); checkBoxes[t.posX, t.posY].Visible = true; checkBoxes[t.posX, t.posY].Enabled = false; checkBoxes[t.posX, t.posY].Show(); if (t is HomeTile) { checkBoxes[t.posX, t.posY].BackColor = Color.Green; checkBoxes[t.posX, t.posY].Checked = true; } else if (t is ExploreTile) { ExploreTile f = t as ExploreTile; switch (f.Resource.Name) { case "Wood": checkBoxes[t.posX, t.posY].BackColor = Color.SaddleBrown; break; case "Iron": checkBoxes[t.posX, t.posY].BackColor = Color.Silver; break; case "Grain": checkBoxes[t.posX, t.posY].BackColor = Color.Yellow; break; case "Wool": checkBoxes[t.posX, t.posY].BackColor = Color.White; break; case "Stone": checkBoxes[t.posX, t.posY].BackColor = Color.DarkGray; break; } } } }
public int TakeResources() { int returnValue = 0; if (MovesLeft <= 0) { return(0); } WorldTile currentTile = CurrentTile(); if (currentTile is HomeTile) { return(1); } else if (currentTile is ExploreTile) { ExploreTile ex = currentTile as ExploreTile; if (ex.isLooted) { return(2); } else { if (ex.Resource != null || ex.resourceAmount != 0) { Player.AddResources(ex.Resource, ex.resourceAmount); returnValue = 3; } if (ex.Item != null) { Player.MakeItem(ex.Item); returnValue = 3; } Map[Player.posX, Player.posY].LootResources(); MovesLeft -= 1; if (rand.Next(0, 5) > 2) { returnValue = 4; } } } return(returnValue); }