Files
MI-38/Heli_with_panels/Assets/Scripts/Panel2D/Cover.cs
2022-07-04 13:15:35 +03:00

39 lines
1.3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Cover : MonoBehaviour
{
List<string> coverStatesListNames = new List<string>();
//Dictionary<string, GameObject> switcheStatesList = new Dictionary<string, GameObject>();
public Dictionary<string, CoverState> coverStatesList = new Dictionary<string, CoverState>();
// int posCount;
// int currentPos;
void Start()
{
// Debug.Log(go.name);
Transform[] coverStates = this.GetComponentsInChildren<Transform>();
// Debug.Log(btnList.Length);
for (int i = 0; i < coverStates.Length; i++)
{
if (i == 0) continue;
// Debug.Log(btnList[i].gameObject.name);
coverStates[i].gameObject.AddComponent<CoverState>();
coverStatesListNames.Add(coverStates[i].gameObject.name);
coverStatesList.Add(coverStates[i].gameObject.name, coverStates[i].gameObject.GetComponent<CoverState>());
}
//coverStatesListNames.Sort();
//setState(0);
setState(0);
}
public void setState(int state)
{
coverStatesList[coverStatesListNames[state]].switchOn();
}
public void setState(string swName)
{
coverStatesList[swName].switchOn();
}
}