Exemplo n.º 1
0
 public HandlerCenter()
 {
     login      = new loginHandler();
     mainRoom   = new mainRoomHandler();
     jjcmatch   = new JJCMatchHandler();
     battleRoom = new BattleRoomHandler();
 }
Exemplo n.º 2
0
 /// <summary>
 /// 模块的初始化
 /// </summary>
 public HandlerCenter()
 {
     login  = new LoginHandler();
     user   = new userhandler();
     match  = new MatchHandler();
     select = new SelectHandler();
     fight  = new FightHandler();
 }
Exemplo n.º 3
0
 public HandlerCenter()
 {
     Accaount  = new AccountHandler();
     User      = new UserHandler();
     Map       = new MapHandler();
     Pos       = new PosHandler();
     Skill     = new skillHandler();
     Inventory = new InventoryHandler();
 }
Exemplo n.º 4
0
            public HandlerInterface SetNext(HandlerInterface handler)
            {
                this._nextHandler = handler;

                // Returning a handler from here will let us link handlers in a
                // convenient way like this:
                // monkey.SetNext(squirrel).SetNext(dog);
                return(handler);
            }
 public HandlerCenter()
 {
     login   = new LoginHandler();
     user    = new UserHandler();
     match   = new MatchHandler();
     select  = new SelectHandler();
     fight   = new FightHandler();
     explore = new ExploreHandler();
 }
Exemplo n.º 6
0
    public static void SetActiveAndUpdate(Component handlerComponent, List <object> values)
    {
        HandlerInterface handlerInterface = (HandlerInterface)handlerComponent;

        values = values.Select(val => IsFieldNull(val)? null : val).ToList();
        bool shouldBeActive = values.Any(val => val != null);

        handlerComponent.gameObject.SetActive(shouldBeActive);
        if (shouldBeActive)
        {
            handlerInterface.UpdateValue(values);
        }
    }
Exemplo n.º 7
0
 public void Awake()
 {
     Singleton = this;
     foreach (GameObject gameObject in GlobalViewListenerObjects)
     {
         HandlerInterface objectHandlerInterface = gameObject.GetComponent <HandlerInterface>();
         if (objectHandlerInterface == null || objectHandlerInterface.Scope != TypeEnums.HandlerScope.View)
         {
             throw new System.Exception("All Global Handlers Must Be View Scopes");
         }
         else
         {
             GlobalViewHandlerInterfaces.Add((Component)objectHandlerInterface);
         }
     }
 }
Exemplo n.º 8
0
        public ServerInit()
        {
            CommandProcessor.Processor.Init();

            config = AppConfig.Load();
            if (config == null)
            {
                AppConfig.Creator();
                config = AppConfig.Load();
            }

            #region 注册事件
            Type[] type = Assembly.GetExecutingAssembly().GetTypes();
            foreach (Type t in type)
            {
                Attribute attribute = t.GetCustomAttribute(typeof(PacketHead), true);
                if (attribute != null)
                {
                    if (((PacketHead)attribute).Type.Equals(typeof(Channel.Opcode.RecvOpcode)))
                    {
                        HandlerInterface @interface = (HandlerInterface)Assembly.GetExecutingAssembly().CreateInstance(t.FullName);
                        CommonGlobal.mHandler.Add(((PacketHead)attribute).Head, @interface);
                        Console.WriteLine("注册事件:[{0}] - [{1}] - [进度:{2}%]", System.Enum.GetName(typeof(Channel.Opcode.RecvOpcode), ((PacketHead)attribute).Head), t.Name, ((PacketHead)attribute).Progress);
                    }
                }
            }
            #endregion

            Console.WriteLine("事件注册数量:{0}", CommonGlobal.mHandler.Count);

            channelServices = new Services.ChannelServices(config);

            GameConstants._QuitServer += channelServices.QuitServer;

            //初始化地图数据
            MapleMapFactory.Init();
            Console.WriteLine("加载完毕!");
        }
Exemplo n.º 9
0
 public HandlerCenter()
 {
     login = new LoginHandler();
 }
Exemplo n.º 10
0
 public MessageHandler()
 {
     User  = new UserHandler();
     Match = new MatchHandler();
     Fight = new FightHandler();
 }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            Console.Clear();

            #region 设置控制台事件
            SetConsoleCtrlHandler(new ConsoleCtrlDelegate((a) =>
            {
                switch (a)
                {
                case CtrlCloseEvent:
                    {
                        Console.WriteLine("正在保存数据中....");
                        if (GameConstants._QuitServer != null)
                        {
                            GameConstants._QuitServer();    //.Invoke();
                        }
                        break;
                    }
                }
                return(true);
            }
                                                          ), true);
            #endregion
#if 测试版本
            #region 测试反射例子
            string path3 = System.IO.Directory.GetCurrentDirectory();

            assembly = Assembly.Load(System.IO.File.ReadAllBytes(@"" + path3 + "\\LoginServer.dll"));

            while (true)
            {
                MapleBuffer mapleBuffer = new MapleBuffer();
                mapleBuffer.add <int>(50);
                mapleBuffer.add <int>(50);


                HandlerInterface game = (HandlerInterface)assembly.CreateInstance("LoginServer.Handler.TestGame");
                game.Handle(mapleBuffer);
                string cmd = Console.ReadLine();
                switch (cmd)
                {
                case "0":
                {
                    assembly = Assembly.Load(System.IO.File.ReadAllBytes(@"" + path3 + "\\LoginServer.dll"));
                    break;
                }
                }
            }
            #endregion
#endif
#if !正式版测试
            Console.Title = "启动:" + args[0];
            #region  务端命令
            switch (args[0])
            {
            case "Common":
            case "LoginServer":
            {
                LoadConfig(args[0]).ConfigureAwait(true);
                break;
            }

            case "ChannelServer":
                LoadConfig(args[0], true).Wait();
                break;

            case "WorldServer":
                LoadConfig(args[0], true, true).ConfigureAwait(true);
                break;

            case "GameServer":
            case "DBServer":
            {
                LoadConfig(args[0], true).ConfigureAwait(true);
                break;
            }

            default:
                Console.WriteLine("启动错误!");
                break;
            }

            while (Run)
            {
                string linet = System.Console.ReadLine();
                switch (linet)
                {
                case "Exit":
                    Environment.Exit(0);
                    break;

                case "Test":
                    assembly = Assembly.Load(System.IO.File.ReadAllBytes(@"" + AppPath + "\\" + args[0] + ".dll"));
                    assembly.CreateInstance(args[0] + ".App.ServerInit");
                    break;
                }
            }

            #endregion
#endif
        }
Exemplo n.º 12
0
 public HandlerCenter()
 {
     login = new LoginHandler();
     user  = new UserHandler();
 }
Exemplo n.º 13
0
 public HandlerCenter()
 {
     login    = new LoginHandler();
     gameHall = new GameHallHandler();
     duel     = new DuelHandler();
 }
Exemplo n.º 14
0
        private void CallHandlers()
        {
            foreach (Component handlerComponent in Handlers)
            {
                HandlerInterface handlerInterface = (HandlerInterface)handlerComponent;
                if (handlerInterface.Scope != HandlerScope.UnityObject)
                {
                    continue;
                }
                List <object> values = new List <object>();
                foreach (HandlerId handlerId in handlerInterface.HandlerIds)
                {
                    switch (handlerId.HandlerType)
                    {
                    case HandlerType.IdList:
                        switch (handlerId.SubType)
                        {
                        case IdType.Object_UsersWhoVotedFor: values.Add(UnityObject.UsersWhoVotedFor); break;

                        case IdType.Object_OwnerIds: values.Add(new List <Guid>()
                            {
                                UnityObject.OwnerUserId.GetValueOrDefault(UnityObject.UnityObjectId)
                            }); break;

                        default:
                            throw new ArgumentException($"Unknown subtype id: '{HandlerType.IdList}-{handlerId.SubType}'");
                        }
                        break;

                    case HandlerType.Strings:
                        switch (handlerId.SubType)
                        {
                        case StringType.Object_Title: values.Add(UnityObject.Title); break;

                        case StringType.Object_Header: values.Add(UnityObject.Header); break;

                        case StringType.Object_Footer: values.Add(UnityObject.Footer); break;

                        case StringType.Object_ImageIdentifier: values.Add(UnityObject.ImageIdentifier); break;

                        default:
                            throw new ArgumentException($"Unknown subtype id: '{HandlerType.Strings}-{handlerId.SubType}'");
                        }
                        break;

                    case HandlerType.Ints:
                        switch (handlerId.SubType)
                        {
                        case IntType.Object_VoteCount: values.Add(UnityObject.VoteCount); break;

                        default:
                            throw new ArgumentException($"Unknown subtype id: '{HandlerType.Ints}-{handlerId.SubType}'");
                        }
                        break;

                    case HandlerType.ObjectOptions:
                        values.Add(UnityObject.Options);
                        break;

                    default:
                        switch (UnityObject.Type)
                        {
                        case UnityObjectType.Image:
                            values.Add(UnityImageSubHandler(handlerId));
                            break;

                        case UnityObjectType.Text:
                            // No extra data in Text for it to be listening for, dont know what they were looking for
                            throw new ArgumentException($"Unknown handler id: '{handlerId.SubType}'");

                        case UnityObjectType.Slider:
                            values.Add(UnitySliderSubHandler(handlerId));
                            break;

                        default:
                            throw new ArgumentException($"Unknown Object Type: : '{UnityObject.Type}'");
                        }
                        break;
                    }
                }
                Helpers.SetActiveAndUpdate(handlerComponent, values);
            }

            foreach (ScopeLoadedListener loadedListener in gameObject.GetComponentsInChildren <ScopeLoadedListener>())
            {
                if (loadedListener.Scope == HandlerScope.UnityObject)
                {
                    loadedListener.OnCompleteLoad();
                }
            }
        }
Exemplo n.º 15
0
        public ServerInit()
        {
            services = new Services.LoginServices();
            //运行脚本
            //Script.RunFile("Script\\Text.lua");
            //在C#中定义Lua全局脚本
#if Lua
            UserData.RegisterType <TestClass>();
            UserData.RegisterType <GGG>();

            Script script = new Script();
            script.Globals["ShowGame"] = (Func <TestClass>)ShowGame;
            //加载脚本.
            try
            {
                DynValue obj = UserData.Create(new TestClass());
                script.Globals.Set("startxx", obj);
                //script.Globals["ShowGame"] = new TestClass();
                //script.Globals.Set("obj", obj);
                DynValue value = script.DoFile("Script\\Text.lua");
                //运行
                script.Call(script.Globals["start"], 10);
            }
            catch (Exception e)
            {
                Console.WriteLine("运行错误:" + e);
            }
#endif
            config = AppConfig.Load();
            if (config == null)
            {
                AppConfig.Creator();
                config = AppConfig.Load();
            }

            #region 自动获取处理

            Type[] type = Assembly.GetExecutingAssembly().GetTypes();
            foreach (Type t in type)
            {
                Attribute attribute = t.GetCustomAttribute(typeof(PacketHead), true);
                if (attribute != null)
                {
                    if (((PacketHead)attribute).Type.Equals(typeof(Opcode.RecvOpcode)))
                    {
                        HandlerInterface @interface = (HandlerInterface)Assembly.GetExecutingAssembly().CreateInstance(t.FullName);
                        CommonGlobal.mHandler.Add(((PacketHead)attribute).Head, @interface);
                        Console.WriteLine("注册事件:[{0}] - [{1}] - [进度:{2}%]", System.Enum.GetName(typeof(Opcode.RecvOpcode), ((PacketHead)attribute).Head), t.Name, ((PacketHead)attribute).Progress);
                    }
                }
            }


            #endregion

            Console.WriteLine("事件注册数量:{0}", CommonGlobal.mHandler.Count);



            //以下是定时器例子
            //Text().Wait();
        }
Exemplo n.º 16
0
 public HandlerCenter()
 {
     Accaount      = new AccountHandler();
     PackageHandle = new PackageHandle();
 }
Exemplo n.º 17
0
        private void CallHandlers()
        {
            foreach (Component handlerComponent in Handlers)
            {
                HandlerInterface handlerInterface = (HandlerInterface)handlerComponent;
                if (handlerInterface.Scope != HandlerScope.View)
                {
                    continue;
                }
                List <object> values = new List <object>();
                foreach (HandlerId handlerId in handlerInterface.HandlerIds)
                {
                    switch (handlerId.HandlerType)
                    {
                    case HandlerType.ViewOptions:
                        values.Add(UnityView.Options);
                        break;

                    case HandlerType.UnityObjectList:
                        values.Add(UnityView.UnityObjects);
                        break;

                    case HandlerType.Strings:
                        switch (handlerId.SubType)
                        {
                        case StringType.View_Title:
                            values.Add(UnityView.Title);
                            break;

                        case StringType.View_Instructions:
                            values.Add(UnityView.Instructions);
                            break;

                        default:
                            throw new ArgumentException($"Unknown subtype id: '{HandlerType.Strings}-{handlerId.SubType}'");
                        }
                        break;

                    case HandlerType.Timer:
                        values.Add(
                            new TimerHolder()
                        {
                            ServerTime   = UnityView.ServerTime,
                            StateEndTime = UnityView.StateEndTime,
                        });
                        break;

                    case HandlerType.UsersList:
                        values.Add(
                            new UsersListHolder
                        {
                            Users       = UnityView.Users,
                            IsRevealing = UnityView.IsRevealing
                        });
                        break;

                    default:
                        throw new ArgumentException($"Unknown handler id: '{handlerId.HandlerType}'");
                    }
                }
                if (values.Count > 0)
                {
                    Helpers.SetActiveAndUpdate(handlerComponent, values);
                }
            }

            foreach (ScopeLoadedListener loadedListener in gameObject.GetComponentsInChildren <ScopeLoadedListener>())
            {
                if (loadedListener.Scope == HandlerScope.View)
                {
                    loadedListener.OnCompleteLoad();
                }
            }
        }