标签:分享 nbsp hid bsp prot ext rac protect else
1 /// <summary> 2 /// 处理信息的接口 3 /// </summary> 4 public abstract class Handler { 5 6 /// <summary> 7 /// 下一个请求接收者 8 /// </summary> 9 protected Handler m_NextHandler = null; 10 11 public Handler(Handler theNextHandler) { 12 m_NextHandler = theNextHandler; 13 } 14 15 public virtual void HandleRequest(int Cost) { 16 if(m_NextHandler != null) { 17 m_NextHandler.HandleRequest(Cost); 18 } 19 } 20 }
1 /// <summary> 2 /// 处理所负责的信息1 3 /// </summary> 4 public class ConcreteHandler1:Handler { 5 6 private int m_CostCheck = 10; 7 8 public ConcreteHandler1(Handler theNextHandler) : base(theNextHandler) { 9 10 } 11 12 public override void HandleRequest(int Cost) { 13 if(Cost <= m_CostCheck) { 14 Debug.Log("ConcreteHandler1.HandleRequest核准"); 15 } else { 16 base.HandleRequest(Cost); 17 } 18 } 19 }
1 /// <summary> 2 /// 处理所负责的信息2 3 /// </summary> 4 public class ConcreteHandler2:Handler { 5 6 private int m_CostCheck = 20; 7 8 public ConcreteHandler2(Handler theNextHandler) : base(theNextHandler) { 9 10 } 11 12 public override void HandleRequest(int Cost) { 13 if(Cost <= m_CostCheck) { 14 Debug.Log("ConcreteHandler2.HandleRequest核准"); 15 } else { 16 base.HandleRequest(Cost); 17 } 18 } 19 }
1 /// <summary> 2 /// 处理所负责的信息3 3 /// </summary> 4 public class ConcreteHandler3:Handler { 5 6 public ConcreteHandler3(Handler theNextHandler) : base(theNextHandler) { 7 8 } 9 10 public override void HandleRequest(int Cost) { 11 Debug.Log("ConcreteHandler3.HandleRequest核准"); 12 } 13 }
20 关卡设计-责任链(Chain of Responsibility)
标签:分享 nbsp hid bsp prot ext rac protect else
原文地址:http://www.cnblogs.com/revoid/p/6498154.html