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类相同

  • 相关阅读:
    查看虚拟机里的Centos7的IP
    display:none visibility:hidden opacity:0区别
    UVA
    Gym
    Gym
    UVALive
    面试题1
    vuex的5个属性值
    vue中的.sync语法糖
    绝对定位实现垂直居中的优缺点
  • 原文地址:https://www.cnblogs.com/lunoctis/p/12021442.html
Copyright © 2011-2022 走看看