You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
2.1 KiB
74 lines
2.1 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using System;
|
|
public class EquipmentPanel : MonoBehaviour
|
|
{
|
|
public GameObject equipment;
|
|
List<GameObject> list;
|
|
public int spacing;
|
|
public Transform startpos;
|
|
|
|
private void Awake()
|
|
{
|
|
list = new List<GameObject>();
|
|
}
|
|
private void OnEnable()
|
|
{
|
|
|
|
foreach (GameObject obj in list) {
|
|
Destroy(obj);
|
|
}
|
|
list.Clear();
|
|
}
|
|
private void Start()
|
|
{
|
|
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
for (int i = 0; i < list.Count; i++)
|
|
{
|
|
list[i].transform.position = new Vector3(startpos.position.x, startpos.position.y - i * spacing, startpos.position.z);
|
|
}
|
|
}
|
|
|
|
public void addList(string[] information, int id, float[] changeInfo)
|
|
{
|
|
GameObject eq = initEQ(information, id, changeInfo);
|
|
list.Add(eq);
|
|
}
|
|
|
|
public void reduceList(int id)
|
|
{
|
|
for (int i = 0; i < list.Count; i++)
|
|
{
|
|
if (id == list[i].GetComponent<Equipment>().id)
|
|
{
|
|
GameObject flag = list[i];
|
|
list.Remove(list[i]);
|
|
Destroy(flag.gameObject);
|
|
}
|
|
}
|
|
}
|
|
|
|
GameObject initEQ(string[] information, int id, float[] changeInfo)
|
|
{
|
|
GameObject eq = Instantiate(equipment, transform);
|
|
eq.GetComponent<Equipment>().name = information[0];
|
|
eq.GetComponent<Equipment>().attribute1 = information[1];
|
|
eq.GetComponent<Equipment>().attribute2 = information[3];
|
|
eq.GetComponent<Equipment>().id = id;
|
|
eq.GetComponent<Equipment>().min1 = changeInfo[0];
|
|
eq.GetComponent<Equipment>().max1 = changeInfo[1];
|
|
eq.GetComponent<Equipment>().min2 = changeInfo[2];
|
|
eq.GetComponent<Equipment>().max2 = changeInfo[3];
|
|
eq.GetComponent<Equipment>().ChangeV1 = changeInfo[4];
|
|
eq.GetComponent<Equipment>().ChangeV2 = changeInfo[5];
|
|
eq.GetComponent<Equipment>().dm1 = information[5];
|
|
eq.GetComponent<Equipment>().dm2 = information[6];
|
|
return eq;
|
|
}
|
|
}
|