131 lines
3.2 KiB
C#
131 lines
3.2 KiB
C#
|
//**********************************************//
|
|||
|
//作者:#李云峰#
|
|||
|
//日期:#2-15.06.12#
|
|||
|
//简述:#用于管理物品和装备所用的altas#
|
|||
|
//*********************************************//
|
|||
|
using UnityEngine;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using Thousandto.Core.Base;
|
|||
|
|
|||
|
namespace Thousandto.Plugins.Common
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 类ItemAndEquipAltas说明
|
|||
|
/// </summary>
|
|||
|
public class UIIconAltas
|
|||
|
{
|
|||
|
#region //私有变量
|
|||
|
private UIAtlas _altas; //altas 引用
|
|||
|
private int _retainCount; //引用计数,用于管理载入和删除altas
|
|||
|
private string _altasName; //altas 名字
|
|||
|
private int _index; //altas的索引
|
|||
|
private List<MyAction<UIAtlas>> _callBackList = new List<MyAction<UIAtlas>>();
|
|||
|
#endregion
|
|||
|
|
|||
|
#region //属性
|
|||
|
public UIAtlas Altas
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _altas;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
_altas = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public int RetainCount
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _retainCount;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
_retainCount = value;
|
|||
|
if (_retainCount < 0)
|
|||
|
{
|
|||
|
_retainCount = 0;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public string AltasName
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _altasName;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
_altasName = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public int Index
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _index;
|
|||
|
}
|
|||
|
|
|||
|
set
|
|||
|
{
|
|||
|
_index = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region //构造函数
|
|||
|
public UIIconAltas()
|
|||
|
{
|
|||
|
_altas = null;
|
|||
|
_retainCount = 0;
|
|||
|
_altasName = "";
|
|||
|
_index = -1;
|
|||
|
}
|
|||
|
|
|||
|
public void AddCallBack(MyAction<UIAtlas> callBack)
|
|||
|
{
|
|||
|
//FLogger.LogError("1UIIconAltas:AddCallBack", _altasName,_retainCount);
|
|||
|
if (callBack != null)
|
|||
|
{
|
|||
|
//FLogger.LogError("2UIIconAltas:AddCallBack", _altasName, _retainCount);
|
|||
|
if (_altas != null)
|
|||
|
{
|
|||
|
callBack(_altas);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
//FLogger.LogError("3UIIconAltas:AddCallBack", _altasName, _retainCount);
|
|||
|
_callBackList.Add(callBack);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void RemoveCallBack(MyAction<UIAtlas> callBack)
|
|||
|
{
|
|||
|
//FLogger.LogError("UIIconAltas:RemoveCallBack", _altasName, _retainCount);
|
|||
|
if (callBack != null && _callBackList.Count > 0)
|
|||
|
{
|
|||
|
_callBackList.Remove(callBack);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void DoCallBack()
|
|||
|
{
|
|||
|
//FLogger.LogError("UIIconAltas:DoCallBack", _altasName, _retainCount, _callBackList.Count);
|
|||
|
for (int i = 0; i < _callBackList.Count; i++)
|
|||
|
{
|
|||
|
_callBackList[i](_altas);
|
|||
|
}
|
|||
|
_callBackList.Clear();
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|