1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using UnityEngine;
- using UnityEngine.UI;
- using System.Collections;
- public class ItemResult : MonoBehaviour {
- public Text rankTxt;
- public Text nickTxt;
- public Text killTxt;
- public Text deadTxt;
- public Image bgImage;
- void Awake()
- {
- string name = this.gameObject.name;
- int index = int.Parse(name.Substring(5));
- RectTransform rt = GetComponent<RectTransform>();
- Vector3 pos = rt.localPosition;
- pos.y = 285-index*30f;
- rt.localPosition = pos;
- }
- public void SetData(int rank, PlayerStatsData data, Sprite bgSprite, bool isMe=false)
- {
- if(rank > 0)
- {
- bgImage.enabled = true;
- rankTxt.text = rank.ToString();
- nickTxt.text = data.nick;
- killTxt.text = data.kill.ToString();
- deadTxt.text = data.death.ToString();
- bgImage.sprite = bgSprite;
- if(isMe)
- rankTxt.color = nickTxt.color =
- killTxt.color = deadTxt.color = new Color(1f, 0.5f, 0);
- }
- else
- {
- rankTxt.text =
- nickTxt.text =
- killTxt.text =
- deadTxt.text = "";
- bgImage.enabled = false;
- }
- }
- }
|