惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
L
LINUX DO - 最新话题
PCI Perspectives
PCI Perspectives
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
Cybersecurity and Infrastructure Security Agency CISA
Webroot Blog
Webroot Blog
V2EX - 技术
V2EX - 技术
S
Security @ Cisco Blogs
T
The Exploit Database - CXSecurity.com
S
Schneier on Security
Latest news
Latest news
C
CXSECURITY Database RSS Feed - CXSecurity.com
C
CERT Recently Published Vulnerability Notes
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
T
Tor Project blog
Know Your Adversary
Know Your Adversary
S
Secure Thoughts
Project Zero
Project Zero
Hacker News: Ask HN
Hacker News: Ask HN
C
Cisco Blogs
K
Kaspersky official blog
Google DeepMind News
Google DeepMind News
N
News | PayPal Newsroom
V
Vulnerabilities – Threatpost
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
H
Heimdal Security Blog
Blog — PlanetScale
Blog — PlanetScale
GbyAI
GbyAI
C
Cyber Attacks, Cyber Crime and Cyber Security
L
Lohrmann on Cybersecurity
N
News and Events Feed by Topic
The Last Watchdog
The Last Watchdog
D
DataBreaches.Net
W
WeLiveSecurity
M
MIT News - Artificial intelligence
WordPress大学
WordPress大学
Y
Y Combinator Blog
TaoSecurity Blog
TaoSecurity Blog
AWS News Blog
AWS News Blog
T
Threat Research - Cisco Blogs
大猫的无限游戏
大猫的无限游戏
I
InfoQ
Cloudbric
Cloudbric
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Forbes - Security
Forbes - Security
Attack and Defense Labs
Attack and Defense Labs
The Cloudflare Blog
Recent Announcements
Recent Announcements
Scott Helme
Scott Helme
Cyberwarzone
Cyberwarzone

博客园 - 数迹

1.winform中App.config配置mssql连接字符串 where关键字 1.params 关键字 1.创建实体类UserInfo 1. UserInfo表的创建 3.SqlCommand组件 2.在DbHelper.cs 中使用连接字符串 事件委托1 委托总结:委托提供了 A类的对象 调用 B类对象的同一类方法 的能力。 委托3--委托声明比较 委托2 文心快码 委托1 sql提示注册表中无 \100\ConfigurationState的解决方法 - 数迹 - 博客园 安装SQL server 提示重新启动计算机失败怎么解决 DataGridView插入指定类型的列 菜单制作过程笔记1 ${pagecontext.request.contextpath}绝对路径理解 eclipse中修改JSP模板中的默认编码 hibernate的ddl-auto属性
多播委托
数迹 · 2026-02-11 · via 博客园 - 数迹

多播委托

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestConsoleFramwork
{
    class Player {

        public delegate void OnAttackDelegate(int JianShaoBloodNumber);
        public  OnAttackDelegate OnAttack=null;
        //点击按钮释放AOE攻击后,调用敌人的被伤害方法
        //AOE是一种攻击
        public void  DoAOE(int JianShaoBloodNumber) { 
            if (OnAttack!=null)
            {
                //攻击参数为10滴血
                OnAttack(JianShaoBloodNumber);
            }
        }
    }
    class Enemy {
        private int bloodNumber = 100;
        //减少血量的方法(减少的血量)
        public void JianShaoBlood(int JianShaoBloodNumber) { 

            bloodNumber-=JianShaoBloodNumber;
            Console.WriteLine("中招了,Enemy减血"+ JianShaoBloodNumber);
           Console.ReadLine();
        }
    }
    internal class DuoBoWeiTuo
    {
        static void Main(string[] args)
        {
            Enemy enemy0 = new Enemy();
            Enemy enemy1 = new Enemy();
            Enemy enemy2 = new Enemy();
            Player player = new Player();
            player.OnAttack += enemy0.JianShaoBlood;
            player.OnAttack += enemy1.JianShaoBlood;
            player.OnAttack += enemy2.JianShaoBlood;
            //DoAOE()执行对敌人减血10滴
            player.DoAOE(10);
        }
    }
}
//调用过程记录:
//1.玩家点击释放大招AOE攻击,后调用对应的玩家的DoAOE(减血数量)方法
//2.DoAOE()方法执行委托方法
//3.在此之前委托指针OnAttack()已经配置为敌人的减血方法
//4.这个例子中的回调就是敌人减血方法
//5.而委托方法本身起什么名字都可以

posted on 2026-02-11 17:14  数迹  阅读(8)  评论()    收藏  举报