Пример #1
0
    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++;
        }
    }
Пример #2
0
    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);
    }
Пример #3
0
    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);
        }
    }
Пример #4
0
    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);
    }
Пример #5
0
    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]);
    }
Пример #6
0
 public override void Init()
 {
     _resourceType   = ResourceType.Stone;
     _resourceAmount = Alea.GetInt(2, 5);
     base.Init();
 }
Пример #7
0
    public Waypoint GetRandomWaypoint()
    {
        int id = Alea.GetInt(0, _waypoints.Count);

        return(_waypoints.ToArray()[id]);
    }
Пример #8
0
    private char CreateSymbol(string possibleChars)
    {
        int index = Alea.GetInt(0, possibleChars.Length);

        return(possibleChars[index]);
    }
Пример #9
0
 public override void Init()
 {
     _resourceType   = ResourceType.Wood;
     _resourceAmount = Alea.GetInt(300, 500);
     base.Init();
 }