public void DisplayWoodGatherUI(Vector3 position, int amount) { Vector3 noise = Alea.GetFloat(0.2f, 1.0f) * Vector3.up; GameObject obj = Instantiate(_woodGatherTemplate, position + noise, Quaternion.identity, transform); obj.GetComponentInChildren <TextMeshProUGUI>().text = "+ " + amount + " wood"; }
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++; } }
public static Alea Instance() { if (monAlea == null) { monAlea = new Alea(); } return(monAlea); }
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 CreateTree(Vector2Int position) { float noiseX = Alea.GetFloat(0.0f, noise); float noiseZ = Alea.GetFloat(0.0f, noise); Vector3 pos = new Vector3((position.x + noiseX - _numberSteps) * stepSize, 0.0f, (position.y + noiseZ - _numberSteps) * stepSize); Tree tree = GenerateTree(pos); _createdTrees.Add(new Vector2Int(position.x, position.y), tree); }
private void GenerateRandomWaypoints(int number) { for (int i = 0; i < number; i++) { Waypoint newWaypoint = Instantiate(_waypointTemplate, Vector3.zero, Quaternion.identity, transform); newWaypoint.transform.localPosition = new Vector3(Alea.GetFloat(-5.0f, 5.0f), 0.0f, Alea.GetFloat(-5.0f, 5.0f)); _waypoints.Add(newWaypoint); } }
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 void GenerateRandomTrees() { _createdTrees = new Dictionary <Vector2Int, Tree>(); if (density == 0.0f) { return; } for (int i = 0; i < 2 * _numberSteps; i++) { for (int j = 0; j < 2 * _numberSteps; j++) { if (Alea.GetFloat(0.0f, 1.0f) <= density) { CreateTree(new Vector2Int(i, j)); } } } }
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]); }
public void Jeter() { valeur = Alea.Instance().Nouveau(1, 6); }
private bool ShouldAttachToBuilding(Building b) { return(Alea.GetFloat(0.0f, 1.0f) <= 0.5f); }
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(); }