-
Notifications
You must be signed in to change notification settings - Fork 18
/
StoreManager.cs
35 lines (31 loc) · 1.04 KB
/
StoreManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class StoreManager : MonoBehaviour
{
public GameObject plantItem;
List<PlantObject> plantObjects = new List<PlantObject>();
private void Awake()
{
//Assets/Resources/Plants
var loadPlants = Resources.LoadAll("Plants", typeof(PlantObject));
foreach (var plant in loadPlants)
{
plantObjects.Add((PlantObject)plant);
}
plantObjects.Sort(SortByPrice);
foreach (var plant in plantObjects)
{
PlantItem newPlant = Instantiate(plantItem, transform).GetComponent<PlantItem>();
newPlant.plant = plant;
}
}
int SortByPrice(PlantObject plantObject1, PlantObject plantObject2)
{
return plantObject1.buyPrice.CompareTo(plantObject2.buyPrice);
}
int SortByTime(PlantObject plantObject1, PlantObject plantObject2)
{
return plantObject1.timeBtwStages.CompareTo(plantObject2.timeBtwStages);
}
}