mirror of
https://github.com/zoriya/Magical-Garden.git
synced 2025-12-06 07:16:15 +00:00
Solving bugs.
This commit is contained in:
@@ -63,9 +63,17 @@ public class InventoryManager : MonoBehaviour
|
||||
if (Input.GetKeyDown(KeyCode.R))
|
||||
{
|
||||
ClearBoard();
|
||||
//GetComponent<Mission>().GenerateMission();
|
||||
GetComponent<Mission>().WinUI.SetActive(false);
|
||||
GetComponent<Pokedex>().UpdateMissionText();
|
||||
turnCount.text = "Turn: 01";
|
||||
}
|
||||
if (Input.GetKeyDown(KeyCode.N))
|
||||
{
|
||||
ClearBoard();
|
||||
GetComponent<Mission>().GenerateMission();
|
||||
GetComponent<Mission>().WinUI.SetActive(false);
|
||||
GetComponent<Pokedex>().UpdateMissionText();
|
||||
turnCount.text = "Turn: 01";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,6 +143,18 @@ public class InventoryManager : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public void PlaceRandomTrees(int number)
|
||||
{
|
||||
for (int i = 0; i < number; i++)
|
||||
{
|
||||
int index = Random.Range(0, plots.Length);
|
||||
if(plots[index].treePlaced == TreeType.Nothing)
|
||||
index = Random.Range(0, plots.Length);
|
||||
|
||||
PlaceTree(items[Random.Range(0, items.Length)], index);
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteTreeAt(int index)
|
||||
{
|
||||
Vector2Int plotPos = GetPlotPositionByIndex(index);
|
||||
@@ -371,7 +391,8 @@ public class InventoryManager : MonoBehaviour
|
||||
{
|
||||
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(slots[i].GetComponentInChildren<TextMeshProUGUI>() != null)
|
||||
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
|
||||
|
||||
@@ -4,11 +4,20 @@ using UnityEngine;
|
||||
|
||||
public class Mission : MonoBehaviour {
|
||||
|
||||
TreeItem[] items;
|
||||
public float difficulte;
|
||||
|
||||
public int easy;
|
||||
public int hard;
|
||||
|
||||
[Space]
|
||||
public int minDrop;
|
||||
public int itemDrop;
|
||||
public int maxDrop;
|
||||
|
||||
[Space]
|
||||
public int fewTree;
|
||||
public int manyTree;
|
||||
|
||||
public Dictionary<TreeType, int> Objectifs = new Dictionary<TreeType, int>();
|
||||
TreeItem[] items;
|
||||
public GameObject WinUI;
|
||||
public GameObject LooseUI;
|
||||
private void Start()
|
||||
@@ -19,7 +28,7 @@ public class Mission : MonoBehaviour {
|
||||
Debug.Log("eroor");
|
||||
}
|
||||
|
||||
if (difficulte> items.Length)
|
||||
if (hard > items.Length)
|
||||
{
|
||||
Debug.LogError("difficulté trop grande");
|
||||
}
|
||||
@@ -33,7 +42,8 @@ public class Mission : MonoBehaviour {
|
||||
public void GenerateMission()
|
||||
{
|
||||
Objectifs = new Dictionary<TreeType, int>();
|
||||
for (int i = 0; i < difficulte; i++)
|
||||
int loop = Random.Range(easy, hard);
|
||||
for (int i = 0; i < loop; i++)
|
||||
{
|
||||
AddTree();
|
||||
}
|
||||
@@ -43,7 +53,9 @@ public class Mission : MonoBehaviour {
|
||||
mission = mission + "Place: " + i.Value + " " + i.Key.ToString() +"\n";
|
||||
}
|
||||
|
||||
GetComponent<InventoryManager>().PlaceRandomTrees(Random.Range(fewTree, manyTree));
|
||||
GiveTrees();
|
||||
GetComponent<Pokedex>().UpdateMissionText();
|
||||
}
|
||||
|
||||
private void GiveTrees()
|
||||
@@ -54,7 +66,7 @@ public class Mission : MonoBehaviour {
|
||||
if (manager.items[i].type == TreeType.Nothing)
|
||||
continue;
|
||||
|
||||
manager.items[i].count = Random.Range(minDrop, itemDrop);
|
||||
manager.items[i].count = Random.Range(minDrop, maxDrop);
|
||||
|
||||
if (Objectifs.ContainsKey(manager.items[i].type))
|
||||
{
|
||||
@@ -85,7 +97,7 @@ public class Mission : MonoBehaviour {
|
||||
{
|
||||
int i = Random.Range(0, trees.Length);
|
||||
TreeType type = trees[i].type;
|
||||
int number = Random.Range(items[i].maxInstanceForWin / 2, items[i].maxInstanceForWin);
|
||||
int number = Random.Range(items[i].maxInstanceForWin / 2 + 1, items[i].maxInstanceForWin);
|
||||
Objectifs.Add(type, number);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,11 +113,11 @@ PlayerSettings:
|
||||
vulkanEnableSetSRGBWrite: 0
|
||||
vulkanUseSWCommandBuffers: 0
|
||||
m_SupportedAspectRatios:
|
||||
4:3: 1
|
||||
5:4: 1
|
||||
16:10: 1
|
||||
4:3: 0
|
||||
5:4: 0
|
||||
16:10: 0
|
||||
16:9: 1
|
||||
Others: 1
|
||||
Others: 0
|
||||
bundleVersion: 0.1
|
||||
preloadedAssets: []
|
||||
metroInputSource: 0
|
||||
|
||||
Reference in New Issue
Block a user