private void CreatePartialResults() { string charsToDistribute = result; int nbPlayers = playerIdentities.Count; partialResults = new List <string>(); for (int i = 0; i < nbPlayers; i++) { partialResults.Add(CreateEmptyResult()); } int k = 0; while (charsToDistribute.Length > 0) { int removedIndex = Alea.GetInt(0, charsToDistribute.Length); char symbol = charsToDistribute[removedIndex]; charsToDistribute = charsToDistribute.Remove(removedIndex, 1); int realPos = result.IndexOf(symbol); int id = k % nbPlayers; partialResults[id] = ReplaceCharAtPos(partialResults[id], realPos, symbol); k++; } }
private Tree GenerateTree(Vector3 position) { int id = Alea.GetInt(0, treesTemplates.Count); Tree tree = Instantiate(treesTemplates[id], Vector3.zero, Quaternion.identity, transform); tree.transform.localPosition = position; tree.transform.localScale = Vector3.one * 0.3f; return(tree); }
private void CreateHouse(Vector3 position) { GameObject template = _templates.First(x => x.buildType == _currentBuildChoice).template; GameObject house = Instantiate(template, position, Quaternion.Euler(0, Alea.GetInt(0, 360), 0), transform); foreach (Waypoint w in house.GetComponentsInChildren <Waypoint>()) { WaypointManager.Instance.AddWaypoint(w); } }
public BaseTileData GetRandomFloodableTile(WaterCluster cluster) { IEnumerable <BaseTileData> floodableTiles = GetFloodableTiles(cluster); if (floodableTiles.Any()) { int selectedIndex = Alea.GetInt(0, floodableTiles.Count()); return(floodableTiles.ElementAt(selectedIndex)); } return(null); }
public Waypoint GetRandomConnectedWaypoint(Waypoint w) { List <Waypoint> possibleWaypoints = new List <Waypoint>(); possibleWaypoints.AddRange(w.ConnectedWaypoints); possibleWaypoints.AddRange(GetLocalWaypointsConnectedTo(w)); if (possibleWaypoints.Count == 0) { return(null); } int id = Alea.GetInt(0, possibleWaypoints.Count); return(possibleWaypoints.ToArray()[id]); }
public override void Init() { _resourceType = ResourceType.Stone; _resourceAmount = Alea.GetInt(2, 5); base.Init(); }
public Waypoint GetRandomWaypoint() { int id = Alea.GetInt(0, _waypoints.Count); return(_waypoints.ToArray()[id]); }
private char CreateSymbol(string possibleChars) { int index = Alea.GetInt(0, possibleChars.Length); return(possibleChars[index]); }
public override void Init() { _resourceType = ResourceType.Wood; _resourceAmount = Alea.GetInt(300, 500); base.Init(); }