コード例 #1
0
    public List <MirrorProperties> CartesianProduct(string[] colors, string[] shapes, string[] numbers)
    {
        var configs          = new List <MirrorProperties>();
        var cartesianProduct =
            from color in colors
            from shape in shapes
            from number in numbers
            select new { color, shape, number };

        foreach (var pair in cartesianProduct)
        {
            var tuple = new MirrorProperties(pair.color, pair.shape, pair.number);
            configs.Add(tuple);
        }
        return(configs);
    }
コード例 #2
0
    public void AssignClues(MirrorProperties goalSpec, List <GameObject> cluePool1, List <GameObject> cluePool2, List <GameObject> cluePool3, GameObject clue, GameObject player)
    {
        GameObject        randomCluePoint1 = cluePool1[UnityEngine.Random.Range(0, cluePool1.Count)];
        GameObject        randomCluePoint2 = cluePool2[UnityEngine.Random.Range(0, cluePool2.Count)];
        GameObject        randomCluePoint3 = cluePool3[UnityEngine.Random.Range(0, cluePool3.Count)];
        List <GameObject> cluepoints       = new List <GameObject> {
            randomCluePoint1, randomCluePoint2, randomCluePoint3
        };
        List <string> mp = new List <string> {
            goalSpec.color, goalSpec.shape, goalSpec.number
        };

        Shuffle(cluepoints);
        for (int i = 0; i < cluepoints.Count; i++)
        {
            GameObject newClue = Instantiate(clue);
            newClue.transform.SetParent(clueParent.transform);
            newClue.transform.position = cluepoints[i].transform.position;
            Grab grabObject = newClue.GetComponent <Grab>();
            grabObject.player = player;
            TMPro.TextMeshPro text = newClue.transform.Find("TEXT").GetComponent <TMPro.TextMeshPro>();
            text.text = mp[i];
        }
    }