Пример #1
0
        internal void HandleBuyLife(ulong guid)
        {
            DataProcessScheduler scheduler = LobbyServer.Instance.DataProcessScheduler;

            if (null == scheduler)
            {
                return;
            }
            // 响应玩家要求复活
            UserInfo user   = scheduler.GetUserInfo(guid);
            bool     result = false;

            if (null != user)
            {
                int reliveStoneId = ItemConfigProvider.Instance.GetReliveStoneId();
                if (user.ItemBag.GetItemCount(reliveStoneId, 0) >= 1)
                {
                    scheduler.ConsumeItem(guid, user.ItemBag.GetItemData(reliveStoneId, 0), 1, GainItemType.Props, ConsumeItemWay.BuyLife, false, "BuyLife");
                    result = true;
                }
                else if (user.Gold >= 50)
                {
                    int consume = 50;
                    scheduler.ConsumeAsset(guid, consume, ConsumeAssetType.BuyLife, AssetType.Glod, "BuyLife");
                    result = true;
                }
                if (result)
                {
                    user.CurrentBattleInfo.DeadCount += 1;
                    if (null != user.Room)
                    {
                        Msg_LR_UserReLive.Builder resultBuilder = Msg_LR_UserReLive.CreateBuilder();
                        RoomInfo room = m_LobbyInfo.GetRoomByID(user.CurrentRoomID);
                        resultBuilder.SetUserGuid(guid);
                        resultBuilder.SetRoomID(user.CurrentRoomID);
                        LobbyServer.Instance.RoomSvrChannel.Send(room.RoomServerName, resultBuilder.Build());
                    }
                    JsonMessageWithGuid blrMsg = new JsonMessageWithGuid(JsonMessageID.BuyLifeResult);
                    blrMsg.m_Guid = guid;
                    ArkCrossEngineMessage.Msg_LC_BuyLifeResult protoData = new ArkCrossEngineMessage.Msg_LC_BuyLifeResult();
                    protoData.m_Succeed    = result;
                    protoData.m_CurDiamond = (int)user.Gold;
                    blrMsg.m_ProtoData     = protoData;
                    JsonMessageDispatcher.SendDcoreMessage(user.NodeName, blrMsg);
                }
                else
                {
                    JsonMessageWithGuid blrMsg = new JsonMessageWithGuid(JsonMessageID.BuyLifeResult);
                    blrMsg.m_Guid = guid;
                    ArkCrossEngineMessage.Msg_LC_BuyLifeResult protoData = new ArkCrossEngineMessage.Msg_LC_BuyLifeResult();
                    protoData.m_Succeed    = result;
                    protoData.m_CurDiamond = (int)user.Gold;
                    blrMsg.m_ProtoData     = protoData;
                    JsonMessageDispatcher.SendDcoreMessage(user.NodeName, blrMsg);
                }
            }
            //JsonMessageDispatcher.SendDcoreMessage(user.NodeName, );
        }