备份CatanBuilding瘦身独立工程
This commit is contained in:
47
Assets/Scripts/UI/FishingRewardSocial.cs
Normal file
47
Assets/Scripts/UI/FishingRewardSocial.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class FishingRewardSocial : MonoBehaviour
|
||||
{
|
||||
List<GameObject> gameObjects = new List<GameObject>();
|
||||
int childCount;
|
||||
private void Awake()
|
||||
{
|
||||
childCount = transform.childCount;
|
||||
for (int i = 0; i < childCount; i++)
|
||||
{
|
||||
gameObjects.Add(transform.GetChild(i).gameObject);
|
||||
}
|
||||
}
|
||||
public void ShowSocial(bool isSocial)
|
||||
{
|
||||
if (isSocial)
|
||||
{
|
||||
int index = Random.Range(0, childCount);
|
||||
GameObject go = gameObjects[index];
|
||||
go.SetActive(true);
|
||||
TMP_Text tMP_Text = go.transform.Find("info/text_name").GetComponent<TMP_Text>();
|
||||
int count = Random.Range(6, 25);
|
||||
tMP_Text.text = LocalizationMgr.GetFormatTextValue("UI_FishingRewardPanel_101010", count);
|
||||
|
||||
var userAvatars = GContext.container.Resolve<Tables>().TbUserAvatar.DataList;
|
||||
List<UserAvatar> userAvatars1 = new List<UserAvatar>(userAvatars);
|
||||
UserAvatar userAvatar;
|
||||
Image image;
|
||||
for (int i = 1; i <= 4; i++)
|
||||
{
|
||||
userAvatar = userAvatars1[UnityEngine.Random.Range(0, userAvatars1.Count)];
|
||||
userAvatars1.Remove(userAvatar);
|
||||
image = go.transform.Find($"player{i}/icon").GetComponent<Image>();
|
||||
IUIService uiService = GContext.container.Resolve<IUIService>();
|
||||
uiService.SetImageSprite(image, userAvatar.Avatar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user