12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using GameFramework.Event;
- public class FaultChoicesSceneCtrl : MonoBehaviour
- {
- public int ObjCount = 8;
- private GameObject[] _Objects;
- private void Awake()
- {
- _Objects = new GameObject[ObjCount];
- for (int i = 0; i < ObjCount; i++)
- {
- _Objects[i] = this.transform.GetChild(i).gameObject;
- _Objects[i].SetActive(false);
- }
- }
- void Start()
- {
- GameMain.Event.Subscribe(FaultChoicesChangeEvent.EventId, OnFaultChoicesChange);
- }
- private void OnDestroy()
- {
- if (GameMain.Event.Check(FaultChoicesChangeEvent.EventId, OnFaultChoicesChange))
- {
- GameMain.Event.Unsubscribe(FaultChoicesChangeEvent.EventId, OnFaultChoicesChange);
- }
- }
- private void OnFaultChoicesChange(object sender, GameEventArgs e)
- {
- FaultChoicesChangeEvent args = (FaultChoicesChangeEvent)e;
-
- foreach (var obj in _Objects)
- {
- obj.SetActive(false);
- }
- if (args.changeIndex == -1)
- {
- return;
- }
- _Objects[args.changeIndex].SetActive(true);
- }
- }
|