Skip to content

Commit aac9bba

Browse files
committed
commit 4 new patterns
commit 4 new patterns
1 parent c612d4d commit aac9bba

111 files changed

Lines changed: 1282 additions & 16 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
87.5 KB
Binary file not shown.
141 KB
Binary file not shown.

Assets/Command Pattern.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Command Pattern/example1.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//-------------------------------------------------------------------------------------
2+
// DeviceButton.cs
3+
//-------------------------------------------------------------------------------------
4+
5+
using UnityEngine;
6+
using System.Collections;
7+
8+
public class DeviceButton
9+
{
10+
ICommand cmd;
11+
12+
public DeviceButton(ICommand cmd)
13+
{
14+
this.cmd = cmd;
15+
}
16+
17+
public void Press()
18+
{
19+
this.cmd.Execute(); // actually the invoker (device button) has no idea what it does
20+
}
21+
22+
public void PressUndo()
23+
{
24+
this.cmd.Undo();
25+
}
26+
}
27+

Assets/Command Pattern/example1/DeviceButton.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//-------------------------------------------------------------------------------------
2+
// ICommand.cs
3+
//-------------------------------------------------------------------------------------
4+
5+
using UnityEngine;
6+
using System.Collections;
7+
8+
9+
// commands:
10+
// command interface:
11+
public interface ICommand
12+
{
13+
void Execute();
14+
void Undo();
15+
}

Assets/Command Pattern/example1/ICommand.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//-------------------------------------------------------------------------------------
2+
// IElectronicDevice.cs
3+
//-------------------------------------------------------------------------------------
4+
5+
using UnityEngine;
6+
using System.Collections;
7+
8+
// interface for electronic devices (or receivers)
9+
public interface IElectronicDevice
10+
{
11+
void On();
12+
void Off();
13+
void VolumeUp();
14+
void VolumeDown();
15+
}

Assets/Command Pattern/example1/IElectronicDevice.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)