
Behavioral Patterns
lvcoc
吃到老,玩到老,原来,我已经这么老了
展开
-
command命令模式(三)_C#
http://gameprogrammingpatterns.com/本篇命令模式基于《Game Programming Patterns》加入了点个人理解,代码有点多首先依然是一个Command基类public abstract class Command { protected float _TheTime; public float TheTime ...原创 2019-02-21 13:41:50 · 276 阅读 · 0 评论 -
command命令模式_C#
using System;using UnityEngine;using System.Collections;using System.Collections.Generic;namespace CommandExample1{ public class CommandExample1 : MonoBehaviour { void Start ( ) ...原创 2019-02-21 09:30:38 · 211 阅读 · 0 评论 -
c# 职责链
来不及解释了,直接开车public class ChainOfResponsibilityExample1 : MonoBehaviour { private GameObject prefab; void Start ( ) { //设置职责链 Approver larry = new Dir...原创 2019-02-20 17:04:20 · 189 阅读 · 0 评论 -
Visitor访问模式_C#
using UnityEngine;using System.Collections;using System.Collections.Generic;using System;namespace VisitorPatternExample1{ public class VisitorPatternExample1 : MonoBehaviour { ...原创 2019-02-22 15:58:37 · 163 阅读 · 0 评论 -
Template模板模式_C#
using UnityEngine;using System.Collections;namespace TemplateMethodPatternExample1{ public class TemplateMethodPatternExample1 : MonoBehaviour { void Start() { ...原创 2019-02-22 14:41:30 · 221 阅读 · 0 评论 -
Strategy策略模式_C#
一个类的行为或其算法可以在运行时更改using UnityEngine;using System.Collections;namespace StrategyPatternExample2{ public class StrategyPatternExample2 : MonoBehaviour { Animal sparky = new Dog()...原创 2019-02-22 14:23:41 · 161 阅读 · 0 评论 -
state状态模式_C#
using UnityEngine;using System.Collections;namespace StateStructure{ public class StateStructure : MonoBehaviour { void Start ( ) { // 设置初始状态 Contex...原创 2019-02-22 11:02:11 · 195 阅读 · 0 评论 -
Observer观察者模式(二)_C#
在unity里实现观察者,其实就是事件监听,最简单的用委托就可以实现了,代码就不写了,实现过程其实有很多,怎么舒服怎么来原创 2019-02-22 10:39:16 · 215 阅读 · 0 评论 -
Observer观察者模式_C#
比如说steam发售了新游戏。。。。using UnityEngine;using System.Collections;using System.Collections.Generic;public class ObserverStructure : MonoBehaviour{ void Start() { // Configure Ob...原创 2019-02-22 10:18:56 · 179 阅读 · 0 评论 -
Memento备忘录模式_C#
顾名思义,可以用来储存数据using UnityEngine;using System.Collections.Generic;namespace MementoExample2{ public class MementoExample2 : MonoBehaviour { //存储器 Caretaker caretaker =...原创 2019-02-22 09:59:54 · 142 阅读 · 0 评论 -
Mediator中介者(二)_C#
既然了解了中介者的原理和结构,很自然就能想到游戏里的一些东西,比如说拍卖行,玩家不需要知道对方信息,就能进行买卖using UnityEngine;using System.Collections;using System.Collections.Generic;namespace MediatorExample2{ public class MediatorExamp...原创 2019-02-22 09:34:53 · 242 阅读 · 0 评论 -
Mediator中介者模式_C#
用一个中介对象封装一系列的对象交互,中介者使各对象不需要显示地相互作用,从而使其耦合松散,而且可以独立地改变它们之间的交互。using UnityEngine;using System.Collections;public class MediatorStructure : MonoBehaviour{ void Start() { Concrete...原创 2019-02-21 16:22:10 · 168 阅读 · 0 评论 -
Iterator迭代器模式(二)_C#
直接使用IEnumerator//-------------------------------------------------------------------------------------// IteratorExample2.cs//---------------------------------------------------------------------...原创 2019-02-21 16:01:29 · 174 阅读 · 0 评论 -
Iterator迭代器_C#
先上代码using UnityEngine;using System.Collections;namespace IteratorExample1{ public class IteratorExample1 : MonoBehaviour { void Start() { //IEnumerable第一次...原创 2019-02-21 15:29:34 · 149 阅读 · 0 评论 -
Interpreter解释器_C#
-------------------------------------------------------------------------using UnityEngine;using System.Collections;using System.Collections.Generic;//I、V、X、L、C、D、M//相应的阿拉伯数字表示为://1、5、10、50、1...原创 2019-02-21 14:28:03 · 220 阅读 · 0 评论 -
command命令模式(二)_C#
接口public interface Command{ void Execute(); void UnExecute();}命令的具体实现using UnityEngine; // 命令类型的枚举 public enum MoveDirection { up, down, left, right };/// <sum...原创 2019-02-21 10:13:35 · 264 阅读 · 0 评论