1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using XRTool.Util;
- public class ConfigModel : UnitySingleton<ConfigModel>
- {
- /// <summary>
- /// 存储菜单项数据(链表结构)
- /// </summary>
- CircleList<RoomConfig> _itemLinklist = new CircleList<RoomConfig>();
- /// <summary>
- /// 获取头节点(第一个数据)
- /// </summary>
- /// <returns></returns>
- public DoubleLinkNode<RoomConfig> GetFirstMenuItem()
- {
- return _itemLinklist.First;
- }
- /// <summary>
- /// 获取尾节点(最后一个数据)
- /// </summary>
- /// <returns></returns>
- public DoubleLinkNode<RoomConfig> GetLastMenuItem()
- {
- return _itemLinklist.Last;
- }
- /// <summary>
- /// 添加数据
- /// </summary>
- public void AddElement(RoomConfig itemConfig)
- {
- if (itemConfig.Id == "")
- {
- _itemLinklist.AddNode(itemConfig);
- }
- else
- {
- DoubleLinkNode<RoomConfig> _node = _itemLinklist.First;
- while (_node.PreNode != _itemLinklist.First)
- {
- if (_node.Value.Id == "")
- {
- _node.Value = itemConfig;
- break;
- }
- }
- }
- }
- /// <summary>
- /// 读取数据
- /// </summary>
- /// <param name="itemConfig"></param>
- public void InitElement(RoomConfig itemConfig)
- {
- _itemLinklist.AddNode(itemConfig);
- }
- /// <summary>
- /// 删除指定的节点
- /// </summary>
- /// <param name="ic"></param>
- public void RemoveElement(DoubleLinkNode<RoomConfig> ic)
- {
- _itemLinklist.RemoveNode(ic);
- }
- /// <summary>
- /// 数据的数量
- /// </summary>
- /// <returns></returns>
- public int Count
- {
- get
- {
- return _itemLinklist.Count;
- }
- }
- /// <summary>
- /// 清除所有数据
- /// </summary>
- public void Clear()
- {
- _itemLinklist.Clear();
- }
- }
|