コード例 #1
0
ファイル: Program.cs プロジェクト: HeNuoScott/Net3DGame
        public Program()
        {
            Debug.Log("服务器启动,请选择服务器运行模式,按Enter确定");
            Debug.Log("1. lockstep mode.");
            Debug.Log("2. optimistic mode.");
            ServerConfig.MODE = Console.ReadLine() == "1" ? Mode.LockStep : Mode.Optimistic;

            Debug.Log("服务器启动,请选战斗数据传输协议,按Enter确定");
            Debug.Log("1. use udp.");
            Debug.Log("2. use kcp.");
            ServerConfig.PROTO = Console.ReadLine() == "1" ? Protocol.UDP : Protocol.KCP;

            Debug.Log("服务器启动,请输入对战一局的人数,按Enter确定");
            ServerConfig.PVP_Number = int.Parse(Console.ReadLine());

            MainService mService = new MainService(ServerConfig.MODE, ServerConfig.PROTO);

            mService.Start();
        }
コード例 #2
0
        public MainService(Mode mode, Protocol protocol)
        {
            instance  = this;
            mTcp      = new TcpService(ServerConfig.TCP_PORT);
            mMode     = mode;
            mProtocol = protocol;

            if (mProtocol == Protocol.KCP)
            {
                mKcp = new KcpService(ServerConfig.UDP_PORT);
            }
            else
            {
                mUdp = new UdpService(ServerConfig.UDP_PORT);
            }

            mUserManager   = new UserManager();
            mMatchManager  = new MatchManager();
            mBattleManager = new BattleManager();

            Debug.Log(string.Format("Server start success,mode={0} ip={1} tcp port={2} udp port={3}",
                                    mMode.ToString(), GetLocalIP(), ServerConfig.TCP_PORT, ServerConfig.UDP_PORT), ConsoleColor.Green);
        }
コード例 #3
0
 public Server()
 {
     _service           = new MainService();
     _clientsDictionary = new Dictionary <string, ServerAux>();
     _jocuriActive      = new Dictionary <string, GameSession>();
 }
コード例 #4
0
 public Server()
 {
     _service           = new MainService();
     _clientsDictionary = new Dictionary <string, ServerAux>();
     _punctaje          = new Dictionary <string, JucatorAux>();
 }