using System;
namespace DPExample
{
class GameRole
{
// 生命力
private int vit;
public int Vitality {
get { return vit; }
set { vit = value; }
}
// 攻擊力
private int atk;
public int Attack {
get { return atk; }
set { atk = value; }
}
// 防禦力
private int def;
public int Defense {
get { return def; }
set { def = value; }
}
// 狀態顯示
public void StateDisplay()
{
Console.WriteLine ("角色當前狀態:");
Console.WriteLine ("體力:{0}", this.vit);
Console.WriteLine ("攻擊力:{0}", this.atk);
Console.WriteLine ("防禦力:{0}", this.def);
Console.WriteLine ("");
}
// 獲得初始狀態
public void GetInitState()
{
this.vit = 100;
this.atk = 100;
this.def = 100;
}
// 戰鬥
public void Fight()
{
if (this.vit > 0) this.vit -= 20;
if (this.atk > 0) this.atk -= 20;
if (this.def > 0) this.def -= 20;
}
// 保存角色狀態
public RoleStateMemento SaveState()
{
return (new RoleStateMemento(vit, atk, def));
}
// 恢復角色狀態
public void RecoveryState(RoleStateMemento memento)
{
this.vit = memento.Vitality;
this.atk = memento.Attack;
this.def = memento.Defense;
}
}
// 角色狀態儲存箱
class RoleStateMemento
{
private int vit;
public int Vitality {
get { return vit; }
set { vit = value; }
}
private int atk;
public int Attack {
get { return atk; }
set { atk = value; }
}
private int def;
public int Defense {
get { return def; }
set { def = value; }
}
public RoleStateMemento (int vit, int atk, int def)
{
this.vit = vit;
this.atk = atk;
this.def = def;
}
}
// 角色狀態管理者
class RoleStateCaretaker
{
private RoleStateMemento memento;
public RoleStateMemento Memento {
get { return memento; }
set { memento = value; }
}
}
}
原文網址: http://www.cnblogs.com/haibindev/archive/2011/12/21/2296173.html 原文作者: haibindev 原文標題:c#万能视频播放器 本文的重點在於修正 class VlcPlayer,使其能順利在 VC# Express 2010 .Net Framework 4 下順利編譯。 修正重點在於 CallingConvention = CallingConvention. StdCall 改成 CallingConvention = CallingConvention. Cdecl using System; using System.Runtime.InteropServices; using System.Security; using System.Text; namespace VlcDotNet { class VlcPlayer { private IntPtr libvlc_instance_; private IntPtr libvlc_media_player_; private double duration_; public VlcPlayer(string pluginPath) { string plugin_arg = "--plugin-path=" + pluginPath; string[] arguments = { "-I", "dummy", "--ignore-config", "--no-video-title", plugin_arg }; libvlc_instance_ = LibVlcAPI.libvlc_new(arguments); libvlc_media_player_ = LibVlcAPI.libvlc_media_player_new(libvlc_instance_); } public ...

留言
張貼留言