1. 程式人生 > >C#設計模式-外觀模式

C#設計模式-外觀模式

using System;
using System.Collections.Generic;

namespace TestCS
{
    class Program
    {
        static void Main(string[] args)
        {
            Facade facade = new Facade();
            facade.EnterMap(); 
            Console.ReadKey();
        }

        class Facade
        {
            MapManager m_MapManager = new MapManager();
            PlayerManager m_PlayerManager = new PlayerManager();
            UIManager m_UIManager = new UIManager();

            public void EnterMap()
            {
                m_MapManager.CreateMap();
                m_PlayerManager.CreatePlayers();
                m_UIManager.ShowUI(); 
                Console.WriteLine("Enter Map");
            }
        }

        class UIManager
        {
            public void ShowUI()
            {
                Console.WriteLine("Show UI");
            }
        }

        class PlayerManager
        {
            public void CreatePlayers()
            {
                Console.WriteLine("Create Players");
            }
        }

        class MapManager
        {
            public void CreateMap()
            {
                Console.WriteLine("Create Map");
            }
        }
    }
}