Modification sur la barre de mana.
Le prefab ne contient plus de component Button, il s'agit juste d'un sprite. Les deux scripts associés aux deux classes manaItem et ManaStack ont été corrigés. 1) manaItem décrit le comportement de chaque cristal de mana. trois méthodes ont été ajoutées: setDisabled, setEnabled, setSelected tous les trois afin de gérer l'apparence de chaque cristal. 2) ManaStack décrit le comportement de la barre de mana. Le maximum de cristaux est une variable publique manaMax attaché à l'objet mana_controller. Pour connaitre le nombre de cristaux de mana disponible, il est possible d'appeler la fonction getMana. La fonction addDaily est maintenant fonctionnelle. En prévision de la suite, les prototype de addMana, subMana et selMana ont été écris mais non implémenté.
This commit is contained in:
parent
a7c9aaa5a2
commit
e3b75bacd3
@ -10,7 +10,6 @@ GameObject:
|
||||
- 224: {fileID: 22400000}
|
||||
- 222: {fileID: 22200000}
|
||||
- 114: {fileID: 11400004}
|
||||
- 114: {fileID: 11400002}
|
||||
- 114: {fileID: 11400000}
|
||||
- 114: {fileID: 11400006}
|
||||
m_Layer: 5
|
||||
@ -38,47 +37,6 @@ MonoBehaviour:
|
||||
m_PreferredHeight: -1
|
||||
m_FlexibleWidth: -1
|
||||
m_FlexibleHeight: -1
|
||||
--- !u!114 &11400002
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 100000}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 1392445389, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Navigation:
|
||||
m_Mode: 3
|
||||
m_SelectOnUp: {fileID: 0}
|
||||
m_SelectOnDown: {fileID: 0}
|
||||
m_SelectOnLeft: {fileID: 0}
|
||||
m_SelectOnRight: {fileID: 0}
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: .189121976, g: .461876631, b: .779411793, a: 1}
|
||||
m_HighlightedColor: {r: .188235298, g: .4627451, b: .78039217, a: 1}
|
||||
m_PressedColor: {r: .784313738, g: .784313738, b: .784313738, a: 1}
|
||||
m_DisabledColor: {r: .531520367, g: .694621027, b: .83088237, a: .501960814}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: .100000001
|
||||
m_SpriteState:
|
||||
m_HighlightedSprite: {fileID: 0}
|
||||
m_PressedSprite: {fileID: 0}
|
||||
m_DisabledSprite: {fileID: 0}
|
||||
m_AnimationTriggers:
|
||||
m_NormalTrigger: Normal
|
||||
m_HighlightedTrigger: Highlighted
|
||||
m_PressedTrigger: Pressed
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 0
|
||||
m_TargetGraphic: {fileID: 11400004}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0,
|
||||
Culture=neutral, PublicKeyToken=null
|
||||
--- !u!114 &11400004
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
@ -111,6 +69,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 9781d92cb7268914f9a8d87ccf55e3a4, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
manaImage: {fileID: 11400004}
|
||||
--- !u!222 &22200000
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 1
|
||||
|
@ -15903,6 +15903,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
manaItem: {fileID: 100000, guid: 19394ecd1b3a67b45b66a7d5904bd53d, type: 2}
|
||||
contentPanel: {fileID: 1711588717}
|
||||
manaMax: 10
|
||||
--- !u!4 &1356086184
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -21,6 +21,10 @@ public class DayController : MonoBehaviour {
|
||||
GameObject createScrollListObject;
|
||||
CreateScrollList createScrollList;
|
||||
|
||||
//appel de ManaStack
|
||||
GameObject manaStackObject;
|
||||
ManaStack manaStack;
|
||||
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
@ -38,8 +42,13 @@ public class DayController : MonoBehaviour {
|
||||
createScrollListObject = GameObject.Find ("log_controller");
|
||||
createScrollList = createScrollListObject.GetComponent<CreateScrollList> ();
|
||||
|
||||
//appel de ManaStack
|
||||
manaStackObject = GameObject.Find ("mana_controller");
|
||||
manaStack = manaStackObject.GetComponent<ManaStack> ();
|
||||
|
||||
dayNb = 1;
|
||||
chatWindow.writeDay (dayNb);
|
||||
manaStack.addDaily (dayNb);
|
||||
|
||||
}
|
||||
|
||||
@ -87,8 +96,8 @@ public class DayController : MonoBehaviour {
|
||||
timer = 0;
|
||||
dayNb ++;
|
||||
|
||||
string message = "\n\n\n JOUR "+ dayNb.ToString()+"\n";
|
||||
chatWindow.writeDay(dayNb);
|
||||
manaStack.addDaily (dayNb);
|
||||
print("le jour se lève, discutez!");
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,27 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ManaItem : MonoBehaviour {
|
||||
|
||||
string message;
|
||||
public Image manaImage;
|
||||
|
||||
void Start () {
|
||||
//manaImage = GetComponent<Image> ();
|
||||
|
||||
}
|
||||
|
||||
public void setDisabled(){
|
||||
manaImage.color = Color.red;
|
||||
|
||||
}
|
||||
|
||||
public void setEnabled(){
|
||||
manaImage.color = Color.blue;
|
||||
}
|
||||
|
||||
public void setSelected(){
|
||||
manaImage.color = Color.white;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,52 +8,61 @@ public class ManaStack : MonoBehaviour {
|
||||
|
||||
public GameObject manaItem;
|
||||
public Transform contentPanel;
|
||||
public int manaMax;
|
||||
int manaLeft;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
|
||||
//création de la barre de mana.
|
||||
for(int i=0; i<10; i++){
|
||||
for(int i=0; i<manaMax; i++){
|
||||
createMana ();
|
||||
GameObject.Find("ManaItem(Clone)").name="ManaItem"+i;
|
||||
//GameObject.Find("ManaItem"+i).GetComponent("Button").
|
||||
|
||||
//GameObject.Find("ManaItem"+i).GetComponent("ManaItem").setDisabled();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
}
|
||||
|
||||
public int getMana(){return manaLeft;}
|
||||
|
||||
//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> ();
|
||||
mana.setDisabled ();
|
||||
myNewButton.transform.SetParent (contentPanel);
|
||||
}
|
||||
|
||||
|
||||
//ajoute le bon nombre de cristaux de mana chaque jour
|
||||
public void addDaily(int nbDay){
|
||||
|
||||
nbDay--;
|
||||
GameObject manaItemObject;
|
||||
Button manaButton;
|
||||
|
||||
|
||||
if (nbDay > 9) {
|
||||
nbDay = 9;
|
||||
ManaItem manaButton;
|
||||
|
||||
if (nbDay > manaMax-1) {
|
||||
nbDay = manaMax-1;
|
||||
}
|
||||
|
||||
manaLeft = nbDay + 1;
|
||||
|
||||
for (int i=0; i<=nbDay; i++) {
|
||||
manaItemObject = GameObject.Find("ManaItem"+i);
|
||||
manaButton = manaItemObject.GetComponent<Button> ();
|
||||
manaButton.interactable=true;
|
||||
manaButton = manaItemObject.GetComponent<ManaItem> ();
|
||||
manaButton.setEnabled();
|
||||
//GameObject.Find("ManaItem"+i).GetComponent("Button").int
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//ajoute la quantité de mana indiqué.
|
||||
public void addMana(int manaPlus){
|
||||
}
|
||||
|
||||
//soustrait la quantité de mana indiqué.
|
||||
public void subMana(int manaLess){
|
||||
}
|
||||
|
||||
//selectionne la quantité de mana indiqué
|
||||
//(quand on passe la souris sur un sort par exemple)
|
||||
public void selMana (int sel){
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user