Beispiel #1
0
 static AvatarFactory()
 {
     icons = new Dictionary <AvatarType, Sprite>
     {
         { AvatarType.Student, ResourceLoader.Avatar(AvatarType.Student) },
         { AvatarType.Businessman, ResourceLoader.Avatar(AvatarType.Businessman) }
     };
 }
Beispiel #2
0
    public void UpdatePlayerList()
    {
        var children = new List <GameObject>();

        foreach (Transform child in playerListContent.transform)
        {
            children.Add(child.gameObject);
        }
        children.ForEach(child => Destroy(child));

        int playerListOffset       = 0;
        List <EnemyPlayer> players = GameManager.Instance.PlayerListManager.PlayerList;

        for (int i = 0; i < players.Count; i++)
        {
            GameObject prefab = null;
            if (i % 2 == 0)
            {
                prefab = playerLeftPrefab;
            }
            else
            {
                prefab = playerRightPrefab;
            }


            GameObject player = Instantiate(prefab, playerListContent.transform);
            var        t      = player.GetComponent <RectTransform>();
            t.anchoredPosition          = new Vector2(0.0f, playerListOffset);
            player.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);

            Text[] textField = player.GetComponentsInChildren <Text>();
            textField[0].text = players[i].Name;
            player.transform.Find("Icon").gameObject.GetComponent <Image>().sprite = ResourceLoader.Avatar(players[i].Avatar);
            playerListOffset -= 250;
        }
    }