You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
128 lines
3.7 KiB
128 lines
3.7 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class SettlementUI : MonoBehaviour
|
|
{
|
|
GameObject[] pieces;
|
|
Character maincharacter;
|
|
public Image expMask;
|
|
float originalSize;
|
|
PointsBar expBar;
|
|
Text levelText;
|
|
Text cashText;
|
|
Text expText;
|
|
// 可加点属性
|
|
Text strText;
|
|
Text dexText;
|
|
Text sanText;
|
|
Text inteText;
|
|
Text defText;
|
|
Text vigText;
|
|
// 剩余可加点数
|
|
Text pointsText;
|
|
|
|
void Awake()
|
|
{
|
|
pieces = GameObject.FindGameObjectsWithTag("Pieces");
|
|
foreach (var piece in pieces)
|
|
{
|
|
if(piece.GetComponent<Character>().id == 0)
|
|
{
|
|
maincharacter = piece.GetComponent<Character>();
|
|
break;
|
|
}
|
|
}
|
|
|
|
originalSize = expMask.rectTransform.rect.width;
|
|
levelText = transform.GetChild(0).GetChild(0).GetComponent<Text>();
|
|
cashText = transform.GetChild(0).GetChild(1).GetComponent<Text>();
|
|
expText = transform.GetChild(0).GetChild(2).GetComponent<Text>();
|
|
strText = transform.GetChild(0).GetChild(3).GetComponent<Text>();
|
|
dexText = transform.GetChild(0).GetChild(4).GetComponent<Text>();
|
|
sanText = transform.GetChild(0).GetChild(5).GetComponent<Text>();
|
|
inteText = transform.GetChild(0).GetChild(6).GetComponent<Text>();
|
|
defText = transform.GetChild(0).GetChild(7).GetComponent<Text>();
|
|
vigText = transform.GetChild(0).GetChild(8).GetComponent<Text>();
|
|
pointsText = transform.GetChild(0).GetChild(9).GetComponent<Text>();
|
|
}
|
|
|
|
public void Update()
|
|
{
|
|
levelText.GetComponent<Text>().text = maincharacter.level.ToString();
|
|
cashText.GetComponent<Text>().text = maincharacter.money.ToString();
|
|
expText.GetComponent<Text>().text = maincharacter.exp.ToString();
|
|
strText.GetComponent<Text>().text = maincharacter.str.ToString();
|
|
dexText.GetComponent<Text>().text = maincharacter.dex.ToString();
|
|
sanText.GetComponent<Text>().text = maincharacter.san.ToString();
|
|
inteText.GetComponent<Text>().text = maincharacter.inte.ToString();
|
|
defText.GetComponent<Text>().text = maincharacter.def.ToString();
|
|
vigText.GetComponent<Text>().text = maincharacter.vig.ToString();
|
|
pointsText.GetComponent<Text>().text = maincharacter.points.ToString();
|
|
expMask.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, originalSize * maincharacter.exp / maincharacter.levelUp[maincharacter.level-1]);
|
|
}
|
|
|
|
public void StrAdd()
|
|
{
|
|
if(maincharacter.points > 0)
|
|
{
|
|
maincharacter.str++;
|
|
maincharacter.points--;
|
|
}
|
|
|
|
}
|
|
|
|
public void DexAdd()
|
|
{
|
|
if(maincharacter.points > 0)
|
|
{
|
|
maincharacter.dex++;
|
|
maincharacter.points--;
|
|
}
|
|
}
|
|
|
|
public void SanAdd()
|
|
{
|
|
if(maincharacter.points > 0)
|
|
{
|
|
maincharacter.san++;
|
|
maincharacter.points--;
|
|
}
|
|
}
|
|
|
|
public void InteAdd()
|
|
{
|
|
if(maincharacter.points > 0)
|
|
{
|
|
maincharacter.inte++;
|
|
maincharacter.points--;
|
|
}
|
|
}
|
|
|
|
public void DefAdd()
|
|
{
|
|
if(maincharacter.points > 0)
|
|
{
|
|
maincharacter.def++;
|
|
maincharacter.points--;
|
|
}
|
|
}
|
|
|
|
public void VigAdd()
|
|
{
|
|
if(maincharacter.points > 0)
|
|
{
|
|
maincharacter.vig++;
|
|
maincharacter.points--;
|
|
}
|
|
}
|
|
|
|
public void PointsCheck(GameObject gameobject)
|
|
{
|
|
if(maincharacter.points <= 0)
|
|
gameobject.SetActive(false);
|
|
}
|
|
|
|
}
|