Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using UnityEngine;
- #region BaseList
- [System.Serializable]
- public class BaseList
- {
- public Transform transform { get; private set; }
- public LocalBase localBase { get; private set; }
- public RemoteBase remoteBase { get; private set; }
- public void SetBase(Transform _transform, LocalBase _localbase) {
- transform = _transform; localBase = _localbase; }
- public void SetBase(Transform _transform, RemoteBase _remoteBase) {
- transform = _transform; remoteBase = _remoteBase; }
- }
- #endregion
- public class BaseManager : MonoBehaviour {
- public static BaseManager current;
- private List<BaseList> baseList = new List<BaseList>();
- private void Awake() { current = this; }
- public void SetBase(Transform transform, LocalBase localBase)
- {
- BaseList newBase = new BaseList();
- newBase.SetBase(transform, localBase);
- baseList.Add(newBase);
- }
- public void SetBase(Transform transform, RemoteBase remoteBase)
- {
- BaseList newBase = new BaseList();
- baseList.Add(newBase);
- newBase.SetBase(transform, remoteBase);
- }
- public LocalBase GetLocalBase(Transform transform)
- {
- for (int i = baseList.Count; i > 0; i--)
- {
- if (baseList[i].transform == transform)
- return baseList[i].localBase;
- }
- return null;
- }
- public RemoteBase GetRemoteBase(Transform transform)
- {
- for (int i = baseList.Count; i > 0; i--)
- {
- if (baseList[i].transform == transform)
- return baseList[i].remoteBase;
- }
- return null;
- }
- public void RemoveBase(Transform transform)
- {
- for (int i = baseList.Count; i > 0; i--)
- {
- if (baseList[i].transform == transform)
- baseList.RemoveAt(i);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement