Exemple #1
0
    private void GenerateLevel(int tabletQuantity)
    {
        UpdateScore(_score);

        ClearTablets();

        Debug.Log("Creating Tablets...");

        var innerCircleOccupated = new List <int>();
        var outerCircleOccupated = new List <int>();
        var finalVectors         = new List <Vector2>();
        var totalOccupated       = 0;

        if (tabletQuantity > _allPossibleVectors)
        {
            tabletQuantity = _allPossibleVectors;
        }

        while (totalOccupated < tabletQuantity)
        {
            if (innerCircleOccupated.Count < _innerCircle.Count)
            {
                var rngValue = Random.Range(0, _innerCircle.Count);
                if (!innerCircleOccupated.Contains(rngValue))
                {
                    innerCircleOccupated.Add(rngValue);
                    finalVectors.Add(_innerCircle.ElementAt(rngValue));
                }
            }
            else
            {
                var rngValue = Random.Range(0, _outerCircle.Count);
                if (!outerCircleOccupated.Contains(rngValue))
                {
                    outerCircleOccupated.Add(rngValue);
                    finalVectors.Add(_outerCircle.ElementAt(rngValue));
                }
            }
            totalOccupated = innerCircleOccupated.Count + outerCircleOccupated.Count;
        }

        var characterList = new List <HCharacter>();

        for (int i = 0; i < tabletQuantity; i++)
        {
            var newList = _characters.Where(
                x => !characterList.Select(y => y.id).Contains(x.id)
                ).ToList();
            characterList.Add(newList.ElementAt(Random.Range(0, newList.Count)));

            _tabletObjs.Add(Instantiate(_endScreenResource, transform) as GameObject);
            _tabletObjs.ElementAt(i).transform.position = TranslateTablet(finalVectors.ElementAt(i));
            _tabletObjs.ElementAt(i).transform.Find("DisplayedCharacter").GetComponent <Text>().text = characterList.ElementAt(i).character;

            if (i > 0)
            {
                _tabletObjs.ElementAt(i).GetComponent <Button>().onClick.AddListener(() => OnTabletClick(false));
            }
            else
            {
                _tabletObjs.ElementAt(i).GetComponent <Button>().onClick.AddListener(() => OnTabletClick(true));
            }

            Debug.Log(
                "Tablet Created: "
                + _tabletObjs.ElementAt(i).transform.Find("DisplayedCharacter").GetComponent <Text>().text,
                _tabletObjs.ElementAt(i)
                );
        }

        _chosenCharacter = characterList.First();
        transform.Find("TargetPanel").Find("TargetText").GetComponent <Text>().text = _chosenCharacter.roman;
        Debug.Log(
            "Character Chosen: "
            + _chosenCharacter.character
            + " - "
            + transform.Find("TargetPanel").Find("TargetText").GetComponent <Text>().text
            + " ("
            + _chosenCharacter.id
            + ")"
            );
    }
Exemple #2
0
 private void LoadCharacter(HCharacter hCharacter)
 {
     _characters.Add(hCharacter);
     Debug.Log("Loaded: " + hCharacter.id + " - " + hCharacter.roman + " (" + hCharacter.character + ")");
 }