枚举类型作为key,函数作为value的delegate调用方案

本文探讨了一种使用枚举类型作为键,函数作为值的委托调用方案。通过这种方式,可以实现根据枚举状态执行不同的操作,提高了代码的可读性和组织性。这种设计模式在处理多态行为或条件分支时非常有用。
摘要由CSDN通过智能技术生成
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, 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值