60 lines
1.2 KiB
C#
60 lines
1.2 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.EventSystems;
|
|
using System.Collections.Generic;
|
|
using System.Collections;
|
|
|
|
public class ManaStack : MonoBehaviour {
|
|
|
|
public GameObject manaItem;
|
|
public Transform contentPanel;
|
|
|
|
// Use this for initialization
|
|
void Start () {
|
|
|
|
//création de la barre de mana.
|
|
for(int i=0; i<10; i++){
|
|
createMana ();
|
|
GameObject.Find("ManaItem(Clone)").name="ManaItem"+i;
|
|
//GameObject.Find("ManaItem"+i).GetComponent("Button").
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update () {
|
|
|
|
}
|
|
|
|
//crée un cristaux de mana. (appelée dix fois lors de la fonction Start).
|
|
void createMana(){
|
|
GameObject myNewButton = Instantiate (manaItem) as GameObject;
|
|
ManaItem mana = myNewButton.GetComponent<ManaItem> ();
|
|
myNewButton.transform.SetParent (contentPanel);
|
|
}
|
|
|
|
|
|
//ajoute le bon nombre de cristaux de mana chaque jour
|
|
public void addDaily(int nbDay){
|
|
|
|
GameObject manaItemObject;
|
|
Button manaButton;
|
|
|
|
|
|
if (nbDay > 9) {
|
|
nbDay = 9;
|
|
}
|
|
|
|
for (int i=0; i<=nbDay; i++) {
|
|
manaItemObject = GameObject.Find("ManaItem"+i);
|
|
manaButton = manaItemObject.GetComponent<Button> ();
|
|
manaButton.interactable=true;
|
|
//GameObject.Find("ManaItem"+i).GetComponent("Button").int
|
|
}
|
|
|
|
}
|
|
|
|
}
|