Beispiel #1
0
 public static GateTrack Add(ShipInfo ship, GateInfo gate, bool isInner = false, string msgType = "")
 {
     return(new GateTrack()
     {
         objName = gate.Name,
         turnStileCode = gate.ID,
         shipMMSI = ship.MMSI.ToString(),
         shipName = ship.Name,
         shipGeoLon = Math.Round(ship.Longitude * 10000000).ToString(),
         shipGeoLat = Math.Round(ship.Latitude * 10000000).ToString(),
         shipSpeed = Math.Round(ship.SOG, 1).ToString(),
         shipCourse = Math.Round(ship.COG).ToString(),
         shipState = "",
         shipIMO = ship.IMO_Number.ToString(),
         shipCallSign = ship.CallSign,
         shipType = ShieldData.GetShipType(ship.ShipCargoType),
         msgType = msgType,
         shipLength = ship.Length.ToString(),
         shipWidth = ship.Width.ToString(),
         shipDraftDepth = "0",
         reportTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"),
         shipDistance = Math.Round(getDis(ship.Longitude, ship.Latitude, gate.Longitude, gate.Latitude)).ToString(),
         objInner = (isInner?"1":"0"),
     });
 }
Beispiel #2
0
    // public void onLoginNodeInfo(int result, string data, string[] servers, Dictionary<string, object> param)
    //{
    //    mCoApp.OnGetNodeInfo(data);
    //}

    //-------------------------------------------------------------------------
    void _onOfflineNode(int result, string data, string[] servers, Dictionary <string, object> param)
    {
        if (result != 0 || data == null)
        {
            return;
        }
        GateInfo gt   = param["gateInfo"] as GateInfo;
        string   path = param["path"] as string;
        LoginNode <ComponentDef> info = param["LoginNode"] as LoginNode <ComponentDef>;

        if (gt.bofflineLock == false)
        {
            EbLog.Error("Error get unlock data: " + path);
        }
        string[] resul;
        char[]   charSeparators = new char[] { ',', ':' };
        resul = data.Split(charSeparators);
        int index = 0;

        while (index < resul.Length)
        {
            string account = resul[index++];
            info.onPlayerOffline(account);
        }
        // 通知gate已经处理了数据.
        mCoApp.getZk().sdelete(gt.offlineLock);
    }
Beispiel #3
0
    public bool IsGateToStartOrEnd(GateInfo gate)
    {
        List <RoomInfo> connectedRooms = new List <RoomInfo> {
            gate.RoomFrom
        };

        GetConnectedRoomsRecursive(rooms[gate.RoomTo.x, gate.RoomTo.y], ref connectedRooms);
        return(connectedRooms.Contains(startRoom) || connectedRooms.Contains(endRoom));
    }
Beispiel #4
0
    public void RemoveRandomGates(System.Random random, RoomInfo[,] rooms, float procent)
    {
        Gates.RemoveAll(x => {
            bool delete = random.NextDouble() < procent;
            if (delete && rooms[x.RoomTo.x, x.RoomTo.y] != null)
            {
                RoomInfo roomTo          = rooms[x.RoomTo.x, x.RoomTo.y];
                GateInfo gateToRemoveToo = roomTo.Gates.Find(y => y.RoomTo == Position);
                roomTo.Gates.Remove(gateToRemoveToo);
            }

            return(delete);
        });
    }
            private static bool MapCalcPositionReplacement(out Vector3[] __result, ActionMap __instance, ref int mapNo, ref int gateID, ref Vector3 pos, int?prevID)
            {
                Logger.LogInfo($"@MapCalcPosition@ 1: mapNo: {mapNo}");
                List <GateInfo> gateInfoList = __instance.calcGateDic[mapNo];

                Logger.LogInfo($"@MapCalcPosition@ 2: {prevID}");
                GateInfo gateInfo1 = prevID.HasValue ? gateInfoList.Find(gate => gate.ID == prevID.Value) : null;

                Logger.LogInfo($"@MapCalcPosition@ 3: gateInfo1: {gateInfo1}");
                if (gateInfo1 != null && gateInfo1.calc.TryGetValue(gateID, out var route1))
                {
                    Logger.LogInfo($"@MapCalcPosition@ 4: route1: {route1}");
                    int count = Utils.Math.MinDistanceRouteIndex(route1, pos);
                    Logger.LogInfo($"@MapCalcPosition@ 5: count: {count}");
                    if (count != -1)
                    {
                        Logger.LogInfo("@MapCalcPosition@ 6");
                        __result = route1.Skip(count).ToArray();
                        Logger.LogInfo($"@MapCalcPosition@ 7: __result: {__result}");
                        return(false); // Skip the original method.
                    }
                    Logger.LogInfo("@MapCalcPosition@ 8");
                }

                Logger.LogInfo($"@MapCalcPosition@ 9: gateInfoList: {gateInfoList}");
                foreach (GateInfo gateInfo2 in gateInfoList)
                {
                    Logger.LogInfo($"@MapCalcPosition@ 10: gateID: {gateID}");
                    if (gateInfo2.calc.TryGetValue(gateID, out var route2))
                    {
                        Logger.LogInfo($"@MapCalcPosition@ 11: route2: {route2}");
                        int count = Utils.Math.MinDistanceRouteIndex(route2, pos);
                        Logger.LogInfo($"@MapCalcPosition@ 12: count: {count}");
                        if (count != -1)
                        {
                            Logger.LogInfo("@MapCalcPosition@ 13");
                            __result = route2.Skip(count).ToArray();
                            Logger.LogInfo($"@MapCalcPosition@ 14: __result: {__result}");
                            return(false); // Skip the original method.
                        }
                        Logger.LogInfo("@MapCalcPosition@ 15");
                    }
                    Logger.LogInfo("@MapCalcPosition@ 16");
                }

                Logger.LogInfo("@MapCalcPosition@ 17");
                __result = null;
                Logger.LogInfo($"@MapCalcPosition@ 18: __result: {__result}");
                return(false); // Skip the original method.
            }
Beispiel #6
0
    void _loginComNode(int result, string data, string[] servers, Dictionary <string, object> param)
    {
        _tLoginResponseInfo lgRepInfo = EbJsonHelper.deserialize <_tLoginResponseInfo>(data);

        GateInfo gt   = param["gateInfo"] as GateInfo;
        string   path = param["path"] as string;

        if (gt.bloginComLock == false)
        {
            EbLog.Error("Error get unlock data: " + path);
            return;
        }
        mCoApp.onGateBack(lgRepInfo.server_group, lgRepInfo.acc, lgRepInfo.result, lgRepInfo.map_userdata);
        // 通知gate已经处理了数据.
        mCoApp.getZk().adelete(gt.loginLockComNode, null);
    }
Beispiel #7
0
    public bool IsGateToReserved(GateInfo gate)
    {
        List <RoomInfo> connectedRooms = new List <RoomInfo> {
            gate.RoomFrom
        };

        GetConnectedRoomsRecursive(rooms[gate.RoomTo.x, gate.RoomTo.y], ref connectedRooms);
        foreach (RoomInfo reservedRoom in reservedRooms)
        {
            if (connectedRooms.Contains(reservedRoom))
            {
                return(true);
            }
        }
        return(false);
    }
            public static bool Prefix(UITeamScreenTeamInfoWidget __instance, Vehicle inVehicleBehind, Vehicle inVehicleAhead, ref bool __result)
            {
                float minTimeAhead = 1f;

                if (inVehicleBehind.pathController.IsOnComparablePath(inVehicleAhead))
                {
                    float          pathDistanceToVehicle = inVehicleBehind.pathController.GetPathDistanceToVehicle(inVehicleAhead);
                    SessionManager sessionManager        = Game.instance.sessionManager;
                    if (pathDistanceToVehicle > 0 && !sessionManager.hasSessionEnded)
                    {
                        if (sessionManager.sessionType == SessionDetails.SessionType.Race)
                        {
                            GateInfo gateTimer = sessionManager.GetGateTimer(inVehicleBehind.pathController.GetPreviousGate().id);
                            float    timeGapBetweenVehicles = gateTimer.GetTimeGapBetweenVehicles(inVehicleAhead, inVehicleBehind);
                            if (timeGapBetweenVehicles < minTimeAhead || inVehicleAhead.performance.IsExperiencingCriticalIssue())
                            {
                                __result = true;
                                return(false);
                            }
                        }
                        else
                        {
                            if (inVehicleAhead.pathController.IsOnStraight() && inVehicleAhead.speed < inVehicleBehind.speed)
                            {
                                float num  = inVehicleBehind.speed - inVehicleAhead.speed;
                                float num2 = (pathDistanceToVehicle - VehicleConstants.vehicleLength) / num;
                                if (num2 < 4f)
                                {
                                    __result = true;
                                    return(false);
                                }
                            }
                            bool flag = pathDistanceToVehicle - VehicleConstants.vehicleLength * 6f < 0f;
                            if (flag)
                            {
                                __result = true;
                                return(false);
                            }
                        }
                    }
                }
                __result = false;
                return(false);
            }
Beispiel #9
0
    // Не используй, если данные проход ведет к выходу или входу!!! Чека это методом IsGateToStartOrEnd
    // Так же избегай удаление зарезервированных комнат, ибо их уже после второй резервации не вернуть!
    public void RemoveFromGateRecursive(GateInfo gate)
    {
        List <RoomInfo> connectedRooms = new List <RoomInfo> {
            gate.RoomFrom
        };

        GetConnectedRoomsRecursive(rooms[gate.RoomTo.x, gate.RoomTo.y], ref connectedRooms);
        connectedRooms.Remove(gate.RoomFrom);
        for (int x = 0; x < size.x; x++)
        {
            for (int y = 0; y < size.y; y++)
            {
                if (connectedRooms.Contains(rooms[x, y]))
                {
                    rooms[x, y] = null;
                }
            }
        }
    }
            public static float GetDistanceBetweenGates(GateInfo gate1, GateInfo gate2)
            {
                float distance = 0;

                if (!gate1.calc.ContainsKey(gate2.ID))
                {
                    Logger.LogWarning($"Failed determining the distance between {PrintGate(gate1)} and {PrintGate(gate2)}.");
                    return(0);
                }

                for (var i = 0; i < gate1.calc[gate2.ID].Length - 1; i++)
                {
                    var p1 = gate1.calc[gate2.ID][i];
                    var p2 = gate1.calc[gate2.ID][i + 1];

                    distance += Vector3.Distance(p1, p2);
                }

                return(distance);
            }
Beispiel #11
0
    public static void OnGateEnter(GameObject player, GameObject gateObject, bool fromMessage)
    {
        if (!fromMessage && !NetworkManagerCustom.IsServer)
        {
            return;
        }

        Vector2Int localPosition = GateInfo.RoomObjectToLocalPosition(gateObject.transform.localPosition);
        Vector2Int nextCoord     = GateInfo.LocalPositionToVector(localPosition) + currentRoomCoords +
                                   (localPosition.x == 1 ? new Vector2Int(0, currentRoom.GetComponent <Room>().Size.y - 1) :
                                    localPosition.x == 3 ? new Vector2Int(currentRoom.GetComponent <Room>().Size.x - 1, 0) :
                                    Vector2Int.zero);
        bool buffer = spawnedRooms != null && nextCoord.x >= 0 && nextCoord.x < spawnedRooms.GetLength(0) &&
                      nextCoord.y >= 0 && nextCoord.y < spawnedRooms.GetLength(1);

        if (buffer)
        {
            Vector3 toPlayerCoords =
                localPosition.x == 0 ? new Vector3(0, -85f) :
                localPosition.x == 1 ? new Vector3(0, 85f) :
                localPosition.x == 2 ? new Vector3(-45f, 0) :
                new Vector3(45f, 0);
            player.transform.position += toPlayerCoords;
            if (localPosition.x == 1)
            {
                player.GetComponent <Rigidbody2D>().AddForce(new Vector2(0, 15000f));
            }
        }

        ApplyActiveRooms();

        if (buffer && player.GetComponent <NetworkIdentity>().isLocalPlayer)
        {
            SetCurrentRoom(nextCoord);
        }
        if (!fromMessage && (!NetworkManagerCustom.IsServer || !player.GetComponent <NetworkIdentity>().isLocalPlayer))
        {
            MessageManager.GateEnterClientMessage.SendToClient(player.GetComponent <NetworkIdentity>().connectionToClient, new StringMessage(localPosition.x + ";" + localPosition.y));
        }
    }
Beispiel #12
0
    private static GameObject SpawnRoom(RoomLoader.Room room, RoomInfo position, Transform parent, bool onServer)
    {
        GameObject spawnedRoom = RoomLoader.SpawnRoom(room, new Vector3(position.Position.x * 495, position.Position.y * 277, 0), onServer);

        spawnedRoom.GetComponent <Room>().Position = position.Position;
        if (NetworkManagerCustom.IsServer && SerializationManager.World != null &&
            SerializationManager.World.Objects[position.Position.x, position.Position.y] != null)
        {
            spawnedRoom.GetComponent <Room>().Initialized = true;
        }
        spawnedRoom.transform.parent = parent;
        List <GameObject> gates = Utils.GetComponentsRecursive <GateObject>(spawnedRoom).ConvertAll(x => x.gameObject);

        gates.ForEach(x =>
                      x.transform.Find("trigger").GetComponent <GateTrigger>().GetEventSystem <GateTrigger.EnterGateEvent>()
                      .SubcribeEvent(y => OnGateEnter(y.Player, y.Sender, false)));

        foreach (GameObject gateObject in gates)
        {
            Vector2Int localPosition = GateInfo.RoomObjectToLocalPosition(gateObject.transform.localPosition);
            if (gateObject.GetComponent <GateObject>().gateType == 0)
            {
                gateObject.GetComponent <GateObject>().Enable =
                    position.Gates.Exists(x => x.LocalPosition == localPosition);
            }
        }

        for (int x = 0; x < position.Size.x; x++)
        {
            for (int y = 0; y < position.Size.y; y++)
            {
                spawnedRooms[x + position.Position.x, y + position.Position.y] = spawnedRoom;
            }
        }
        spawnedRoom.SetActive(false);
        return(spawnedRoom);
    }
Beispiel #13
0
    public static bool IsRoomValid(RoomLoader.Room room, RoomInfo position)
    {
        if (room != null && room.size == position.Size)
        {
            List <RoomObject> gatesObject = room.objects.Where(x => x.prefabName.Contains("Gate")).ToList();
            foreach (RoomObject gateObject in gatesObject)
            {
                Vector2Int localPosition = GateInfo.RoomObjectToLocalPosition(gateObject.coords);
                int        type          = int.Parse(gateObject.data[0]);
                if (type == 1 && !position.Gates.Exists(x => x.LocalPosition == localPosition))
                {
                    return(false);
                }
                if (type == 2 && position.Gates.Exists(x => x.LocalPosition == localPosition))
                {
                    return(false);
                }
            }

            return(true);
        }

        return(false);
    }
Beispiel #14
0
    //-------------------------------------------------------------------------
    //  暂时放这里,应该放入独立线程(防止阻塞用户登陆).
    public override void update(float elapsed_tm)
    {
        List <string> del = new List <string>();

        foreach (var player in mLoginPlayerQueue)
        {
            ClientLoginInfo info = player.Value;
            if (null == info)
            {
                continue;
            }

            // 先做断线检测.
            if (info.state != eLogingState.loginError)
            {
                // todo,添加session是否处于连接状态的查询接口
                if (info.session == null)// || !info.session. .Connected)
                {
                    info.state  = eLogingState.loginError;
                    info.result = eLoginResult.disconnected;
                }
            }

            if (info.state == eLogingState.connect)
            {
                eLoginResult rtCode = eLoginResult.accountNotExists;
                string       sql    = string.Format("SELECT AccountName, Password , LoginStatus , AccountId FROM Account WHERE AccountName='{0}';", info.account);

                EbLog.Note("Login SQL STR :" + sql);

                MySqlCommand    cmd = new MySqlCommand(sql, connection);
                MySqlDataReader rdr = null;
                try
                {
                    rdr = cmd.ExecuteReader();
                    if (rdr.Read())
                    {
                        if ((string)rdr["Password"] != info.password)
                        {
                            rtCode = eLoginResult.wrongPassword;
                        }
                        else if ((string)rdr["LoginStatus"] != eLoginStatus.offline.ToString())
                        {
                            rtCode = eLoginResult.loginstatus;
                        }
                        else
                        {
                            // 登录成功.
                            rtCode         = eLoginResult.success;
                            info.tokenId   = generateId().ToString();
                            info.accountId = (long)rdr["AccountId"];
                        }
                        info.result = rtCode;
                    }

                    if (rdr != null)
                    {
                        rdr.Close();
                        rdr.Dispose();
                        rdr = null;
                    }

                    if (rtCode == eLoginResult.success)
                    {
                        // update status
                        sql = string.Format("UPDATE Account SET LoginStatus = '{0}' WHERE AccountName='{1}';", eLoginStatus.loging.ToString(), info.account);

                        EbLog.Note("Login SQL STR :" + sql);

                        MySqlCommand updateCmd = new MySqlCommand(sql, connection);
                        cmd.ExecuteNonQuery();
                    }
                }
                catch (Exception ex)
                {
                    EbLog.Error(ex.ToString());
                }
                finally
                {
                    cmd.Dispose();
                    cmd = null;

                    if (rdr != null)
                    {
                        if (rdr.IsClosed == false)
                        {
                            rdr.Close();
                        }
                        rdr.Dispose();
                        rdr = null;
                    }
                }

                if (rtCode == ((byte)eLoginResult.success))
                {
                    info.state = eLogingState.updateLoging2Db;
                }
            }

            if (info.state == eLogingState.updateLoging2Db)
            {
                foreach (var gate in mGateInfo)
                {
                    GateInfo ser = gate.Value;
                    if (!ser.bloginLock)
                    {
                        // 目前只有账号信息和当前longin id放入ZooKeeper.
                        string dt = info.account + "," + mCoApp.NodeIdStr + "," + info.tokenId.ToString() + "," + info.accountId.ToString();
                        info.gateId = ser.id;
                        mCoApp.getZk().awriteData(ser.loginNode, dt, null);
                        EbLog.Note("send to gate node :" + ser.loginNode + ",account:" + dt);
                        mCoApp.getZk().acreate(ser.loginLockNode, "", ZK_CONST.ZOO_EPHEMERAL, null);
                        EbLog.Note("set remote lock :" + ser.loginLockNode + ",account:" + dt);

                        ser.bloginLock = true;
                        info.state     = eLogingState.updateZk2Gate;
                        break;
                    }
                }
            }

            if (info.state == eLogingState.gateBackSuccess ||
                info.state == eLogingState.gateBackFailed ||
                info.state == eLogingState.loginError)
            {
                eLoginStatus curState = (info.state == eLogingState.gateBackSuccess) ? eLoginStatus.online : eLoginStatus.offline;
                string       sql      = string.Format("UPDATE Account SET LoginStatus = '{0}' WHERE AccountName='{1}';", curState, info.account);

                EbLog.Note("Login SQL STR :" + sql);

                MySqlCommand cmd = new MySqlCommand(sql, connection);
                try
                {
                    MySqlCommand updateCmd = new MySqlCommand(sql, connection);
                    cmd.ExecuteNonQuery();
                    info.state = eLogingState.updateOnline2Db;
                }
                catch (Exception ex)
                {
                    //mLog.ErrorFormat("accoundName:{0}, password:{1} ", info.account, info.password);
                    EbLog.Error(ex.ToString());
                }
                finally
                {
                    cmd.Dispose();
                    cmd = null;
                }

                if (info.state == eLogingState.updateOnline2Db)
                {
                    //反馈消息给client.
                    //if (info.peer.Connected)// todo,判定session是否处于连接状态
                    {
                        //Dictionary<byte, object> p = new Dictionary<byte, object>();
                        //p[0] = curState.ToString();
                        //if (curState == eLoginStatus.online)
                        //{
                        //    var list = mGateInfo.Where(gt => gt.Value.id.Equals(info.gateId));
                        //    p[1] = list.First().Value.ipport;
                        //    p[2] = info.tokenId;
                        //}
                        //else
                        //{
                        //    p[1] = info.result.ToString();
                        //}

                        // todo,添加session发送任意数据的方法
                        LoginUCenterSession <DefUCenterSession> se = info.session as LoginUCenterSession <DefUCenterSession>;
                        se.login2ClientLogin(curState.ToString(), info.tokenId, info.param);

                        //OperationResponse operation_response = new OperationResponse(1, p);
                        //SendResult r = info.peer.SendOperationResponse(operation_response, new SendParameters { ChannelId = 0 });
                        ////info.session.getRpcPeer().sendEntityRpcData()
                        //if (r != SendResult.Ok)
                        //{
                        //    // Error
                        //}

                        //if (info.peer.Connected)
                        {
                            // 应该断开与客户端的连接.
                            //info.peer.Disconnect();
                        }
                    }

                    info.state = eLogingState.backToClient;
                }

                if (info.state == eLogingState.backToClient)
                {
                    del.Add(info.account);
                }
            }
        }

        foreach (string account in del)
        {
            ClientLoginInfo delPlayer = null;
            mLoginPlayerQueue.TryRemove(account, out delPlayer);
            //delPlayer.peer.Dispose();// todo 连接断开管理
        }

        string offlineaccount = null;

        if (mofflineQueue.TryDequeue(out offlineaccount))
        {
            eLoginStatus curState = eLoginStatus.offline;
            string       sql      = string.Format("UPDATE Account SET LoginStatus = '{0}' WHERE AccountName='{1}';", curState, offlineaccount);

            EbLog.Error("player offline Login SQL STR :" + sql);
            MySqlCommand cmd = new MySqlCommand(sql, connection);
            try
            {
                MySqlCommand updateCmd = new MySqlCommand(sql, connection);
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                //mLog.ErrorFormat("accoundName:{0} offline failed ", offlineaccount);
                EbLog.Error(ex.ToString());
            }
            finally
            {
                cmd.Dispose();
                cmd = null;
            }
        }
    }
Beispiel #15
0
    public void _onServerNodeChange(int result, string data, string[] chdn, Dictionary <string, object> param)
    {
        if (result != 0)
        {
            return;
        }

        if (null == chdn)
        {
            chdn = new string[0];
        }

        LoginNode <ComponentDef> info = param["LoginNode"] as LoginNode <ComponentDef>;
        string path = param["path"] as string;

        List <string>        remoteServer = chdn.ToList();
        List <string>        localServer  = info.mGateInfo.Keys.ToList <string>();
        IEnumerable <string> add          = remoteServer.Except(localServer);
        IEnumerable <string> del          = localServer.Except(remoteServer);

        foreach (var sv in del)
        {
            // gate server 要取消监听.
            GateInfo gtInfo;
            info.mGateInfo.TryGetValue(sv, out gtInfo);
            mCoApp.getZk().unsubscribeExists(gtInfo.loginLockNode);
            mCoApp.getZk().unsubscribeExists(gtInfo.loginLockComNode);
            mCoApp.getZk().unsubscribeExists(gtInfo.offlineLock);
            info.mGateInfo.Remove(sv);
        }

        foreach (var sv in add)
        {
            string[] resul;
            char[]   charSeparators = new char[] { ',', ':' };
            resul = sv.Split(charSeparators);
            if (resul.Length != 3)
            {
                EbLog.Error("PsUCenter.UCenterZkWatcher._onServerNodeChange path:" + path + "child:" + sv);
                EbLog.Error("Error format , the correct format should be 192.168.1.4:4689,000000005 , (ip:port,id) ");
                continue;
            }

            string Ip   = resul[0];
            string Port = resul[1];
            string Id   = resul[2];

            string nodeIdString = mCoApp.NodeIdStr;

            GateInfo gtInfo = new GateInfo();
            gtInfo.id = Id;
            // 生成登陆监听节点.
            gtInfo.loginNode        = info.LoginQueue + nodeIdString + "," + gtInfo.id;
            gtInfo.loginComNode     = info.LoginCompleteQueue + nodeIdString + "," + gtInfo.id;
            gtInfo.loginLockNode    = info.LoginQueueLock + nodeIdString + "," + gtInfo.id;
            gtInfo.loginLockComNode = info.LoginCompleteQueueLock + nodeIdString + "," + gtInfo.id;
            gtInfo.offlineNode      = info.LoginOfflineQueue + nodeIdString + "," + gtInfo.id;
            gtInfo.offlineLock      = info.LoginOfflineQueueLock + nodeIdString + "," + gtInfo.id;
            gtInfo.ipport           = Ip + ":" + Port;

            // 创建节点.
            mCoApp.getZk().acreate(gtInfo.loginNode, "", ZK_CONST.ZOO_EPHEMERAL, null);
            mCoApp.getZk().acreate(gtInfo.loginComNode, "", ZK_CONST.ZOO_EPHEMERAL, null);
            mCoApp.getZk().acreate(gtInfo.offlineNode, "", ZK_CONST.ZOO_EPHEMERAL, null);

            // 监听节点的变化.
            mCoApp.getZk().subscribeExists(gtInfo.loginLockNode, null);
            mCoApp.getZk().subscribeExists(gtInfo.loginLockComNode, null);
            mCoApp.getZk().subscribeExists(gtInfo.offlineLock, null);

            info.mGateInfo.Add(sv, gtInfo);
        }
    }
Beispiel #16
0
    public void CheckReservedRooms()
    {
        for (int i = 0; i < reservedRooms.Count; i++)
        {
            RoomLoader.Room roomObject = RoomLoader.loadedRooms.Find(x => x.fileName.Equals(reservedRooms[i].ReservedRoomName));
            if (roomObject == null)
            {
                Debug.LogWarning("Reserved room names: " + reservedRooms[i].ReservedRoomName + " not found");
                continue;
            }

            List <RoomObject> gateObjects = roomObject.objects.FindAll(x => x.prefabName.Contains("Gate"));
            if (gateObjects.Count % 2 == 1)
            {
                Debug.LogWarning("Gate count in room names: " + reservedRooms[i].ReservedRoomName + " is not even");
                continue;
            }

            reservedRooms[i].GenerateGates(rooms);
            Dictionary <GateInfo, int> gateTypes = new Dictionary <GateInfo, int>();
            foreach (RoomObject gateObject in gateObjects)
            {
                Vector3 coords = gateObject.coords;
                int     side   =
                    coords.y == 0 ? 0 :
                    (coords.y + 23) % 277 == 0 ? 1 :
                    coords.x == 0 ? 2 : 3;
                int        index = side == 0 || side == 1 ? ((int)coords.x - 214) / 495 : ((int)coords.y - 105) / 277;
                Vector2Int gateObjectLocation = new Vector2Int(side, index);
                GateInfo   currentGate        = reservedRooms[i].Gates.Find(x => x.LocalPosition == gateObjectLocation);
                gateTypes.Add(currentGate, int.Parse(gateObject.data[0]));
            }

            List <GateInfo> gates = gateTypes.Keys.ToList();
            List <GateInfo> toRemoveWithStartEnd    = new List <GateInfo>();
            List <GateInfo> toRemoveWithoutStartEnd = new List <GateInfo>();
            foreach (GateInfo gate in gates)
            {
                if (rooms[gate.RoomTo.x, gate.RoomTo.y] == null && gateTypes[gate] == 1)
                {
                    Vector2Int vec    = gate.GetScaledVector(reservedRooms[i].Size);
                    Vector2Int newVec = reservedRooms[i].Position + vec;
                    Rooms[newVec.x, newVec.y] = new RoomInfo(newVec);
                }
                else if (rooms[gate.RoomTo.x, gate.RoomTo.y] != null && gateTypes[gate] == 2)
                {
                    bool toStartOrEnd = IsGateToStartOrEnd(gate);
                    bool reserved     = IsGateToReserved(gate);
                    if (toStartOrEnd)
                    {
                        toRemoveWithStartEnd.Add(gate);
                    }
                    else if (!reserved)
                    {
                        toRemoveWithoutStartEnd.Add(gate);
                    }
                    else
                    {
                        reservedRooms[i].IsReserved       = false;
                        reservedRooms[i].ReservedRoomName = null;
                        reservedRooms.RemoveAt(i);
                        continue;
                    }
                }
            }

            if (toRemoveWithStartEnd.Count == 1)
            {
                reservedRooms[i].IsReserved       = false;
                reservedRooms[i].ReservedRoomName = null;
                reservedRooms.RemoveAt(i);
                continue;
            }
            if (toRemoveWithStartEnd.Count != 0)
            {
                toRemoveWithStartEnd.RemoveAt(0);
            }

            reservedRooms[i].Gates.RemoveAll(x => {
                bool removeWithoutStartEnd = toRemoveWithoutStartEnd.Contains(x);
                if (removeWithoutStartEnd)
                {
                    RemoveFromGateRecursive(x);
                }
                return(removeWithoutStartEnd || toRemoveWithStartEnd.Contains(x));
            });
        }
    }
 private static string PrintGate(GateInfo gate)
 {
     return($"{gate.ID} ({gate.Name})");
 }
Beispiel #18
0
 public GateTrackInfo(GateInfo gate, ShipTrackConfig ship)
 {
     Gate = gate;
     Update(ship);
 }
Beispiel #19
0
 // Start is called before the first frame update
 void Awake()
 {
     gateInfo = targetGate.GetComponent <GateInfo>();
     on       = false;
 }