mirror of
https://github.com/zoriya/Magical-Garden.git
synced 2026-06-05 01:49:21 +00:00
Adding item count.
This commit is contained in:
@@ -13483,56 +13483,56 @@ MonoBehaviour:
|
||||
count: 0
|
||||
- type: 0
|
||||
description:
|
||||
icon: {fileID: 0}
|
||||
iconGris: {fileID: 0}
|
||||
icon: {fileID: 21300000, guid: 52d3d999fa1532f49a760c8bf33124ab, type: 3}
|
||||
iconGris: {fileID: 21300000, guid: 52d3d999fa1532f49a760c8bf33124ab, type: 3}
|
||||
tiles: []
|
||||
canOverrideTree: 0
|
||||
canBePlacedOn: 0
|
||||
count: 0
|
||||
- type: 0
|
||||
description:
|
||||
icon: {fileID: 0}
|
||||
iconGris: {fileID: 0}
|
||||
icon: {fileID: 21300000, guid: 52d3d999fa1532f49a760c8bf33124ab, type: 3}
|
||||
iconGris: {fileID: 21300000, guid: 52d3d999fa1532f49a760c8bf33124ab, type: 3}
|
||||
tiles: []
|
||||
canOverrideTree: 0
|
||||
canBePlacedOn: 0
|
||||
count: 0
|
||||
- type: 0
|
||||
description:
|
||||
icon: {fileID: 0}
|
||||
iconGris: {fileID: 0}
|
||||
icon: {fileID: 21300000, guid: 52d3d999fa1532f49a760c8bf33124ab, type: 3}
|
||||
iconGris: {fileID: 21300000, guid: 52d3d999fa1532f49a760c8bf33124ab, type: 3}
|
||||
tiles: []
|
||||
canOverrideTree: 0
|
||||
canBePlacedOn: 0
|
||||
count: 0
|
||||
- type: 0
|
||||
description:
|
||||
icon: {fileID: 0}
|
||||
iconGris: {fileID: 0}
|
||||
icon: {fileID: 21300000, guid: 52d3d999fa1532f49a760c8bf33124ab, type: 3}
|
||||
iconGris: {fileID: 21300000, guid: 52d3d999fa1532f49a760c8bf33124ab, type: 3}
|
||||
tiles: []
|
||||
canOverrideTree: 0
|
||||
canBePlacedOn: 0
|
||||
count: 0
|
||||
- type: 0
|
||||
description:
|
||||
icon: {fileID: 0}
|
||||
iconGris: {fileID: 0}
|
||||
icon: {fileID: 21300000, guid: 52d3d999fa1532f49a760c8bf33124ab, type: 3}
|
||||
iconGris: {fileID: 21300000, guid: 52d3d999fa1532f49a760c8bf33124ab, type: 3}
|
||||
tiles: []
|
||||
canOverrideTree: 0
|
||||
canBePlacedOn: 0
|
||||
count: 0
|
||||
- type: 0
|
||||
description:
|
||||
icon: {fileID: 0}
|
||||
iconGris: {fileID: 0}
|
||||
icon: {fileID: 21300000, guid: 52d3d999fa1532f49a760c8bf33124ab, type: 3}
|
||||
iconGris: {fileID: 21300000, guid: 52d3d999fa1532f49a760c8bf33124ab, type: 3}
|
||||
tiles: []
|
||||
canOverrideTree: 0
|
||||
canBePlacedOn: 0
|
||||
count: 0
|
||||
- type: 0
|
||||
description:
|
||||
icon: {fileID: 0}
|
||||
iconGris: {fileID: 0}
|
||||
icon: {fileID: 21300000, guid: 52d3d999fa1532f49a760c8bf33124ab, type: 3}
|
||||
iconGris: {fileID: 21300000, guid: 52d3d999fa1532f49a760c8bf33124ab, type: 3}
|
||||
tiles: []
|
||||
canOverrideTree: 0
|
||||
canBePlacedOn: 0
|
||||
@@ -13612,6 +13612,7 @@ MonoBehaviour:
|
||||
treePlaced: 0
|
||||
- type: 1
|
||||
treePlaced: 0
|
||||
draggedPosition: -1
|
||||
--- !u!4 &1724986184
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -13638,7 +13639,6 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
PokeText: {fileID: 1169353273}
|
||||
PokeTemps: 2
|
||||
"ArretD\xE9filement": 0
|
||||
--- !u!114 &1724986186
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -13650,7 +13650,9 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: b4b4a071451fb1c47af7fedbbf6a4179, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
difficulte: 3
|
||||
difficulte: 10
|
||||
minDrop: 1
|
||||
itemDrop: 5
|
||||
MinArbre: 1
|
||||
MaxArbre: 4
|
||||
--- !u!1 &1774186325 stripped
|
||||
|
||||
@@ -47,7 +47,7 @@ public class InventoryManager : MonoBehaviour
|
||||
items[draggedPosition].count -= 1;
|
||||
slots[draggedPosition].transform.GetChild(1).position = defaultPos;
|
||||
TextMeshProUGUI CompteurItem = slots[draggedPosition].GetComponentInChildren<TextMeshProUGUI>();
|
||||
CompteurItem.text = items[draggedPosition].count.ToString();
|
||||
CompteurItem.text = items[draggedPosition].count.ToString().Length < 10 ? "0" + items[draggedPosition].count.ToString() : items[draggedPosition].count.ToString();
|
||||
if (items[draggedPosition].count < 1)
|
||||
{
|
||||
slots[draggedPosition].transform.GetChild(1).GetComponent<Image>().sprite = items[draggedPosition].iconGris;
|
||||
@@ -299,12 +299,24 @@ public class InventoryManager : MonoBehaviour
|
||||
|
||||
public void StartDraggin(int index)
|
||||
{
|
||||
//if(items[index].count > 0)
|
||||
//{
|
||||
if (items[index].count > 0)
|
||||
{
|
||||
slots[index].transform.SetAsLastSibling();
|
||||
draggedPosition = index;
|
||||
defaultPos = slots[draggedPosition].transform.position;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateUI()
|
||||
{
|
||||
for (int i = 0; i < slots.Length; i++)
|
||||
{
|
||||
slots[i].GetComponentInChildren<TextMeshProUGUI>().text = items[i].count.ToString().Length < 10 ? "0" + items[i].count.ToString(): items[i].count.ToString();
|
||||
if(items[i].count == 0)
|
||||
slots[i].transform.GetChild(1).GetComponent<Image>().sprite = items[i].iconGris;
|
||||
else
|
||||
slots[i].transform.GetChild(1).GetComponent<Image>().sprite = items[i].icon;
|
||||
}
|
||||
}
|
||||
|
||||
//public void AddItem(TreeItem item)
|
||||
|
||||
@@ -9,6 +9,8 @@ public class Mission : MonoBehaviour {
|
||||
string Missiontext = null;
|
||||
TreeItem[] items;
|
||||
public float difficulte;
|
||||
public int minDrop;
|
||||
public int itemDrop;
|
||||
public Dictionary<TreeType, int> Objectifs = new Dictionary<TreeType, int>();
|
||||
public int MinArbre = 1;
|
||||
public int MaxArbre = 10;
|
||||
@@ -30,9 +32,8 @@ public class Mission : MonoBehaviour {
|
||||
}
|
||||
|
||||
}
|
||||
public void GenerateMission()
|
||||
private void GenerateMission()
|
||||
{
|
||||
|
||||
for (int i = 0; i < difficulte; i++)
|
||||
{
|
||||
Objectifs.Add(ChoisirUnTypeDarbre(), Random.Range(MinArbre, MaxArbre));
|
||||
@@ -41,6 +42,30 @@ public class Mission : MonoBehaviour {
|
||||
{
|
||||
Missiontext = Missiontext + "Place: " + i.Value + " " + i.Key.ToString() +"\n";
|
||||
}
|
||||
|
||||
GiveTrees();
|
||||
}
|
||||
|
||||
private void GiveTrees()
|
||||
{
|
||||
InventoryManager manager = GetComponent<InventoryManager>();
|
||||
for (int i = 0; i < manager.items.Length; i++)
|
||||
{
|
||||
if (manager.items[i].type == TreeType.Nothing)
|
||||
continue;
|
||||
|
||||
manager.items[i].count = Random.Range(minDrop, itemDrop);
|
||||
|
||||
if (Objectifs.ContainsKey(manager.items[i].type))
|
||||
{
|
||||
int minCount;
|
||||
Objectifs.TryGetValue(manager.items[i].type, out minCount);
|
||||
if(manager.items[i].count < minCount)
|
||||
manager.items[i].count += minCount;
|
||||
|
||||
}
|
||||
}
|
||||
manager.UpdateUI();
|
||||
}
|
||||
|
||||
public string GetMissionText()
|
||||
@@ -48,7 +73,7 @@ public class Mission : MonoBehaviour {
|
||||
return Missiontext;
|
||||
}
|
||||
|
||||
public TreeType ChoisirUnTypeDarbre()
|
||||
private TreeType ChoisirUnTypeDarbre()
|
||||
{
|
||||
TreeType arbre = items.Where(x => !Objectifs.ContainsKey(x.type) && x.type != TreeType.Nothing).ToArray()[Random.Range(0, items.Where(x => !Objectifs.ContainsKey(x.type) && x.type != TreeType.Nothing).ToArray().Length)].type;
|
||||
return arbre;
|
||||
|
||||
Reference in New Issue
Block a user