public void CreateUnit(int x, int y, int owner) { UnitProperties unit = new UnitProperties(); unitcontroller.unitProperties.Add(new Vector2Int(x, y), unit); Vector3 truecoords = hexcalculator.HexToPixel(x, y); GameObject instance = Instantiate(infantry, truecoords, Quaternion.Euler(0, 0, 0)); }
void CreateHex(int x, int y) { HexProperties hex; fieldController.AddToDictionary(x, y); // Creating actual hex fieldController.hexProperties.TryGetValue(new Vector2Int(x, y), out hex); hex.type = fieldController.RandomTileType(); //rolling hex type switch (hex.type) //WHAT THE F**K { case "grass": Hex = grass; break; case "forest": Hex = forest; break; case "rocks": Hex = rocks; break; case "lake": Hex = lake; break; case "water": Hex = water; break; default: Debug.Log("smthing goes wrong"); break; } if (x == 0 && (y == gridsize - 1 || y == -gridsize + 1)) { hex.type = "flag"; Hex = flag; } truecoords = hexCalculator.HexToPixel(x, y); GameObject instance = Instantiate(Hex, truecoords, Quaternion.Euler(0, 0, 0)); //Creating visual hex instance.transform.SetParent(fieldcontainer); fieldController.hextiles.Add(instance); }