Пример #1
0
    void DeleteServer()
    {
        if (null == mServerCtrl)
        {
            return;
        }

        if (mServerCtrl.mList.mSelectedIndex == -1)
        {
            return;
        }

        int    index      = mServerCtrl.mList.mSelectedIndex;
        string serverName = mServerCtrl.mList.mItems[index].mData[0];
        int    sceneMode  = (int)MyServer.AdventureOrBuild(mServerCtrl.mList.mItems[index].mData[2]);

        try
        {
            if (LoadServer.DeleteServer(serverName, sceneMode))
            {
                mServerCtrl.mList.mItems.RemoveAt(index);
                mServerCtrl.mList.UpdateList();
            }
        }
        catch
        {
            Debug.Log("Server is running!");
            MessageBox_N.ShowOkBox(PELocalization.GetString(8000497));
        }
    }
Пример #2
0
    //[RPC]
    void RPC_S2C_CreateNewServer(uLink.BitStream stream, uLink.NetworkP2PMessageInfo info)
    {
        try
        {
            string srvName = stream.Read <string>();
            int    srvMode = stream.Read <int>();
            int    srvPort = stream.Read <int>();

            ConnectedServer cServer = connectedServers.Find(it => it.peer == info.sender);
            if (cServer == null)
            {
                ConnectedServer server = new ConnectedServer(srvName, srvMode, info.sender);
                connectedServers.Add(server);
            }

            LoadServer.AddServer(srvName, srvMode);

            if (null != OnServerRegisteredEvent)
            {
                OnServerRegisteredEvent(srvName, srvMode, srvPort);
            }
        }
        catch (Exception e)
        {
            if (LogFilter.logFatal)
            {
                Debug.LogErrorFormat("RPC_S2C_CreateNewServer error\r\n{0}\r\n{1}", e.Message, e.StackTrace);
            }
        }
    }
Пример #3
0
    void SelectServerData(int index)
    {
        if (index == -1)
        {
            return;
        }

        string serverName = mServerCtrl.mList.mItems[index].mData[0];
        int    mode       = (int)MyServer.AdventureOrBuild(mServerCtrl.mList.mItems[index].mData[2]);

        MyServer ms = LoadServer.GetServer(serverName, mode);

        if (null != ms)
        {
            mServerCtrl.UpdateServerInfo(ms);
        }
    }
Пример #4
0
    void StartServer()
    {
        if (null == mServerCtrl || null == mServerCtrl.mList)
        {
            return;
        }

        if (mServerCtrl.mList.mSelectedIndex == -1)
        {
            return;
        }

        int    index      = mServerCtrl.mList.mSelectedIndex;
        string serverName = mServerCtrl.mList.mItems[index].mData[0];
        int    sceneMode  = (int)MyServer.AdventureOrBuild(mServerCtrl.mList.mItems[index].mData[2]);

        ConnectedServer cServer = P2PManager.GetServer(serverName, sceneMode);

        if (cServer != null)
        {
            Debug.Log("Server is running!");
            MessageBox_N.ShowOkBox(PELocalization.GetString(8000497));
            return;
        }

        MyServer ms = LoadServer.GetServer(serverName, sceneMode);

        if (null == ms)
        {
            return;
        }

        mServerCtrl.GetMyServerInfo(ms);

        if (ms.gameMode == (int)Pathea.PeGameMgr.ESceneMode.Custom)
        {
            Pathea.PeGameMgr.mapUID = ms.uid;
            string dataPath = Path.Combine(GameConfig.CustomDataDir, ms.mapName);
            Pathea.CustomGameData.Mgr.Instance.GetCustomData(Pathea.PeGameMgr.mapUID, dataPath);
        }

        MyServerManager.StartMyServer(ms);
    }
Пример #5
0
    void AddServer(string serverName, int sceneMode)
    {
        if (mServerCtrl != null)
        {
            MyServer ms = LoadServer.GetServer(serverName, sceneMode);
            if (null != ms)
            {
                string mode = ms.AdventureOrBuild();

                int index = mServerCtrl.mList.mItems.FindIndex(it => it.mData[0].Equals(serverName) && it.mData[2].Equals(mode));
                if (index == -1)
                {
                    mServerCtrl.mList.AddItem(ms.ToServerDataItem());
                    mServerCtrl.mList.UpdateList();
                }
            }
        }

        SetServerOn(serverName, sceneMode);
    }
Пример #6
0
    void CreateCustomServer()
    {
        Pathea.CustomGameData.Mgr.Instance.curGameData = Pathea.CustomGameData.Mgr.Instance.GetCustomData(UID);
        if (null == Pathea.CustomGameData.Mgr.Instance.curGameData)
        {
            return;
        }

        string serverName = mServerName.text;

        if (LoadServer.Exist(serverName))
        {
            return;
        }

        Pathea.PeGameMgr.gameName    = Pathea.CustomGameData.Mgr.Instance.curGameData.name;
        Pathea.PeGameMgr.monsterYes  = mMonsterYes;
        Pathea.PeGameMgr.loadArchive = Pathea.ArchiveMgr.ESave.New;

        MyServer ms = new MyServer();

        ms.gameName       = serverName;
        ms.gamePassword   = mPassword.text;
        ms.gameMode       = (int)Pathea.PeGameMgr.sceneMode;
        ms.masterRoleName = GameClientLobby.role.name;
        ms.mapName        = Pathea.PeGameMgr.gameName;
        ms.seedStr        = mSeed.text;
        ms.uid            = UID;

        ms.unlimitedRes     = mInfiniteResoureces.isChecked;
        ms.proxyServer      = mProxyServer.isChecked;
        ms.isPrivate        = mPrivateServer.isChecked;
        ms.useSkillTree     = RandomMapConfig.useSkillTree = mSkillTreeSystem.isChecked;
        ms.scriptsAvailable = mAllScriptsAvailable.isChecked;

        MyServerManager.StartCustomServer(ms);
    }
Пример #7
0
    void SetServerOff(string serverName, int sceneMode)
    {
        if (mServerCtrl == null)
        {
            return;
        }

        MyServer ms = LoadServer.GetServer(serverName, sceneMode);

        if (null == ms)
        {
            return;
        }

        string mode = ms.AdventureOrBuild();

        int index = mServerCtrl.mList.mItems.FindIndex(it => it.mData[0].Equals(serverName) && it.mData[2].Equals(mode));

        if (index >= 0)
        {
            mServerCtrl.mList.SetColor(index, Color.white);
            mServerCtrl.mList.UpdateList();
        }
    }
Пример #8
0
 void Refresh()
 {
     LoadServer.LoadServers();
     StartUIServerCtrl();
 }
Пример #9
0
    void Start()
    {
        MyServerController.OnServerCloseEvent += CloseServer;

        LoadServer.Start();
    }
Пример #10
0
    void OnCreateHostBtn()
    {
        if (string.IsNullOrEmpty(mServerName.text))
        {
            MessageBox_N.ShowOkBox(PELocalization.GetString(8000059));
            return;
        }

        if (Pathea.PeGameMgr.sceneMode == Pathea.PeGameMgr.ESceneMode.Custom)
        {
            if (!mMultiCustomCtrl.HasSelectMap())//没选中地图
            {
                return;
            }

            if (LoadServer.Exist(mServerName.text))
            {
                MessageBox_N.ShowOkBox(PELocalization.GetString(8000485));
                return;
            }
            mMultiCustomCtrl.OnWndStartClick();//检测地图完整性
            StartCoroutine(WhetherMapCheckHasFinished());
            return;
        }

        if (Input.GetMouseButtonUp(0) && mMapList.Count > 0)
        {
            string serverName = mServerName.text;
            //int serverport = uLink.NetworkUtility.FindAvailablePort(9900, 9915);
            string password     = mPassword.text;
            string mapName      = mMapName.text;
            bool   publicServer = !mPrivateServer.isChecked;

            switch (mBiomePop.selection)
            {
            case "Grassland":
                RandomMapConfig.RandomMapID  = RandomMapType.GrassLand;
                RandomMapConfig.vegetationId = RandomMapType.GrassLand;
                break;

            case "Forest":
                RandomMapConfig.RandomMapID  = RandomMapType.Forest;
                RandomMapConfig.vegetationId = RandomMapType.Forest;
                break;

            case "Desert":
                RandomMapConfig.RandomMapID  = RandomMapType.Desert;
                RandomMapConfig.vegetationId = RandomMapType.Desert;
                break;

            case "Redstone":
                RandomMapConfig.RandomMapID  = RandomMapType.Redstone;
                RandomMapConfig.vegetationId = RandomMapType.Redstone;
                break;

            case "Rainforest":
                RandomMapConfig.RandomMapID  = RandomMapType.Rainforest;
                RandomMapConfig.vegetationId = RandomMapType.Rainforest;
                break;

            case "Mountain":
                RandomMapConfig.RandomMapID  = RandomMapType.Mountain;
                RandomMapConfig.vegetationId = RandomMapType.Mountain;
                break;

            case "Swamp":
                RandomMapConfig.RandomMapID  = RandomMapType.Swamp;
                RandomMapConfig.vegetationId = RandomMapType.Swamp;
                break;

            case "Crater":
                RandomMapConfig.RandomMapID  = RandomMapType.Crater;
                RandomMapConfig.vegetationId = RandomMapType.Crater;
                break;

            default:
                RandomMapConfig.RandomMapID  = RandomMapType.GrassLand;
                RandomMapConfig.vegetationId = RandomMapType.GrassLand;
                break;
            }

            switch (mWeatherPop.selection)
            {
            case "Dry":
                RandomMapConfig.ScenceClimate = ClimateType.CT_Dry;
                break;

            case "Temperate":
                RandomMapConfig.ScenceClimate = ClimateType.CT_Temperate;
                break;

            case "Wet":
                RandomMapConfig.ScenceClimate = ClimateType.CT_Wet;
                break;

            case "Random":
                RandomMapConfig.ScenceClimate = ClimateType.CT_Random;
                break;
            }

            Pathea.PeGameMgr.monsterYes = mMonsterYes;

            string seedStr = mSeed.text;

            serverName = serverName.Trim();
            if (string.IsNullOrEmpty(serverName))
            {
                MessageBox_N.ShowOkBox(PELocalization.GetString(8000060));
                return;
            }
            if (serverName.Length < 4 || serverName.Length > 19)
            {
                MessageBox_N.ShowOkBox(PELocalization.GetString(8000486));
                return;
            }

            if (LoadServer.Exist(serverName))
            {
                MessageBox_N.ShowOkBox(PELocalization.GetString(8000485));
                return;
            }

            bool IsInfiniteResoureces = mInfiniteResoureces.isChecked;
            bool useProxy             = mProxyServer.isChecked;
            bool useSkillTree         = mSkillTreeSystem.isChecked;
            bool scriptsAvailable     = mAllScriptsAvailable.isChecked;

            RandomMapConfig.useSkillTree = useSkillTree;

            MyServer ms = new MyServer();
            ms.gameName        = serverName;
            ms.gamePassword    = password;
            ms.mapName         = mapName;
            ms.gameMode        = (int)Pathea.PeGameMgr.sceneMode;
            ms.gameType        = (int)Pathea.PeGameMgr.gameType;
            ms.seedStr         = seedStr;
            ms.teamNum         = teamNum;
            ms.numPerTeam      = playerNum;
            ms.dropDeadPercent = Convert.ToInt32(mDropRateSelections[mDropRateIndex]);
            ms.terrainType     = (int)RandomMapConfig.RandomMapID;
            ms.vegetationId    = (int)RandomMapConfig.vegetationId;
            ms.sceneClimate    = (int)RandomMapConfig.ScenceClimate;
            ms.monsterYes      = Pathea.PeGameMgr.monsterYes;
            ms.unlimitedRes    = IsInfiniteResoureces;
            ms.terrainHeight   = mTerrainHeight;
            ms.mapSize         = mMapSize;
            ms.riverDensity    = mRiverDensity;
            ms.riverWidth      = mRiverWidth;
            //a0.95
            ms.plainHeight     = plainHeight;
            ms.flatness        = flatness;
            ms.bridgeMaxHeight = bridgeMaxHeight;
            //b0.72
            ms.allyCount = mAllyCount;

            ms.scriptsAvailable = scriptsAvailable;
            ms.proxyServer      = useProxy;
            ms.isPrivate        = !publicServer;
            ms.masterRoleName   = GameClientLobby.role.name;
            ms.useSkillTree     = useSkillTree;
            ms.uid = "";
            //ms.dropDeadPercent = drop
            MyServerManager.CreateNewServer(ms);
        }
    }