zoukankan      html  css  js  c++  java
  • GameFramework摘录

    访问器模式
    Version、Logger等基础模块,功能相对固定但拥有几套不同的行为(如开发版本和正式版本不同),采用访问器模式,便于调整功能或复用

    public static class Version
    {
    	public interface IVersionHelper
    	{
    		string GameVersion { get; }
    	}
    	
    	private static IVersionHelper s_VersionHelper = null;
    	
    	public static string GameVersion {
    		get
    		{
    			if (s_VersionHelper == null)
    			{
    				return string.Empty;
    			}
    			
    			return s_VersionHelper.GameVersion;
    		}
    	}
    	
    	public static void SetVersionHelper(IVersionHelper versionHelper)
    	{
    		s_VersionHelper = versionHelper;
    	}
    }
    

    Version类的公共属性都通过访问器进行访问,访问器可自定义

    class MyVersionHelper : Version.IVersionHelper
    {
    	public string GameVersion
    	{
    		get
    		{
    			return "test gameversion!";
    		}
    	}
    }
    
    static void Test()
    {
    	Version.SetVersionHelper(new MyVersionHelper());
    	Console.WriteLine(Version.GameVersion);	// test gameversion!
    }
    
    

    GameFrameworkLog类相同

  • 相关阅读:
    UVa-10317
    UVa-1595
    UVa-10391
    UVa-10763
    UVa-10935
    UVa-1594
    UVa-1593
    从CSDN搬过来了
    memset会显著增加时间和空间的消耗吗
    memset对数组的初始化
  • 原文地址:https://www.cnblogs.com/lunoctis/p/12021442.html
Copyright © 2011-2022 走看看