using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using DG.Tweening;
using UnityEngine.U2D;
using ActionForm = System.Action<string, int>;
//using UnityEditor;
public enum RedStateType
{
HERO_RED,//英灵红点
HERO_UPGRADE,//进阶红点
HERO_DESTINY,//宿命红点
HERO_TREE,//树枝红点
HERO_STORY,//故事红点
HERO_SKILL_SLOT,//空技能槽红点
HERO_SKILL_SLOT_ID,//指定空技能槽红点
};
public delegate bool RedFunctionDelegate(params object[] paramNames);
public class RedPoint : MonoBehaviour
{
public List<RedStateType> _keys;
private Dictionary<RedStateType, RedFunctionDelegate> _dic = new Dictionary<RedStateType, RedFunctionDelegate>();
void Awake()
{
if (this._dic.Count > 0)
return;
_dic.Add(RedStateType.HERO_RED, RedController.Ins.isHeroRed);
_dic.Add(RedStateType.HERO_UPGRADE, RedController.Ins.isHeroUpgradeRed);
_dic.Add(RedStateType.HERO_DESTINY, RedController.Ins.isHeroDestinyRed);
_dic.Add(RedStateType.HERO_TREE, RedController.Ins.isHeroTreeRed);
_dic.Add(RedStateType.HERO_STORY, RedController.Ins.isHeroStoryRed);
_dic.Add(RedStateType.HERO_SKILL_SLOT, RedController.Ins.isHeroHasEmptySkillSlot);
_dic.Add(RedStateType.HERO_SKILL_SLOT_ID, RedController.Ins.isHeroRed);
_dic.Add(RedStateType.HERO_RED, RedController.Ins.isHeroHasEmptySkillSlotBySlotID);
}
public void judgeRed(params object[] paramNames)
{
bool hasRed = false;
int count = this._keys.Count;
for (int i = 0; i < count; ++i)
{
RedStateType key = this._keys[i];
RedFunctionDelegate fun = null;
if (this._dic.TryGetValue(key, out fun) == false)
continue;
hasRed = fun.Invoke(paramNames);
if (hasRed)
break;
}
this.gameObject.SetActive(hasRed);
}//end
}
枚举类型作为key,函数作为value的delegate调用方案
最新推荐文章于 2024-11-19 17:10:24 发布