Example #1
0
        private void SetPlayerInfo()
        {
            long         nextRecoverTime;
            PBPlayerInfo playerInfo = new PBPlayerInfo();

            playerInfo.Id = m_UserId;
            PlayerLogic player = new PlayerLogic();

            player.SetUser(m_UserId);
            playerInfo.IsFemale               = player.MyPlayer.IsFemale;
            playerInfo.Level                  = player.MyPlayer.Level;
            playerInfo.Money                  = player.MyPlayer.Money;
            playerInfo.Name                   = player.MyPlayer.Name;
            playerInfo.PortraitType           = player.MyPlayer.PortraitType;
            playerInfo.Exp                    = player.MyPlayer.Exp;
            playerInfo.Energy                 = player.GetNewEnergy(out nextRecoverTime);
            playerInfo.NextEnergyRecoveryTime = nextRecoverTime;
            playerInfo.Coin                   = player.MyPlayer.Coin;
            playerInfo.MeridianEnergy         = player.MyPlayer.StarEnergy;
            playerInfo.ArenaToken             = player.MyPlayer.ArenaToken;
            playerInfo.Spirit                 = player.MyPlayer.Spirit;
            playerInfo.DisplayId              = player.MyPlayer.UUID;
            playerInfo.PvpToken               = player.MyPlayer.PvpToken;
            NearbyPlayerLogic np = new NearbyPlayerLogic();

            np.SetUser(m_UserId);
            playerInfo.PositionX        = np.NearbyPlayers.MyPositionX;
            playerInfo.PositionY        = np.NearbyPlayers.MyPositionY;
            m_ResponsePacket.PlayerInfo = playerInfo;
        }
Example #2
0
        public override bool TakeAction()
        {
            int deductEnergy = PlayerInstanceLogic.GetInstanceEnergy(m_RequestPacket.InstanceType);
            PlayerInstanceLogic playerInstance = new PlayerInstanceLogic();

            playerInstance.SetUser(m_UserId);
            InstanceProgressLogic instanceProgress = new InstanceProgressLogic();

            instanceProgress.SetUser(m_UserId);
            PlayerLogic player = new PlayerLogic();

            player.SetUser(m_UserId);
            long nextRecoverTime;

            if (playerInstance.MyInstance != null)
            {
                playerInstance.LeaveInstance();
            }
            if (!player.DeductEnergy(deductEnergy, out nextRecoverTime))
            {
                ErrorCode = (int)ErrorType.EnergyNotEnough;
                ErrorInfo = "Energy not Enough";
                return(false);
            }
            var instanceData = CacheSet.InstanceTable.GetData(m_RequestPacket.InstanceType);

            if (GameConfigs.GetInt("Need_Check_Instance_Prerequisite", 1) > 0 && (instanceData.PrerequisitePlayerLevel > player.MyPlayer.Level || (instanceData.PrerequisiteInstanceId > 0 && !instanceProgress.IsInstanceCompleted(instanceData.PrerequisiteInstanceId))))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "Pre-instance is not completed";
                return(false);
            }
            m_ResponsePacket.InstanceType = m_RequestPacket.InstanceType;
            PBPlayerInfo playerInfo = new PBPlayerInfo();

            playerInfo.Id     = player.MyPlayer.Id;
            playerInfo.Energy = player.MyPlayer.Energy;
            playerInfo.NextEnergyRecoveryTime = nextRecoverTime;
            m_ResponsePacket.PlayerInfo       = playerInfo;
            var dropInfo = playerInstance.EnterInstance(m_RequestPacket.InstanceType);

            if (dropInfo == null)
            {
                ErrorCode = (int)ErrorType.PackageSlotFull;
                ErrorInfo = "Package slot full";
                return(false);
            }
            m_ResponsePacket.DropInfo.AddRange(dropInfo);

            foreach (var item in playerInstance.MyInstance.DropList)
            {
                m_ResponsePacket.ItemInfo.Add(new PBItemInfo()
                {
                    Type  = item.Key,
                    Count = item.Value
                });
            }
            return(true);
        }
Example #3
0
        public override bool TakeAction()
        {
            PlayerFriendsLogic pf = new PlayerFriendsLogic();
            PlayerLogic        p  = new PlayerLogic();

            p.SetUser(m_UserId);
            PBPlayerInfo myInfo = new PBPlayerInfo()
            {
                Id               = m_UserId,
                Name             = p.MyPlayer.Name,
                Level            = p.MyPlayer.Level,
                VipLevel         = p.MyPlayer.VIPLevel,
                LastLoginInTicks = p.MyPlayer.LastLoginTime
            };

            p.SetUser(m_RequestPacket.PlayerId);
            PBPlayerInfo friendInfo = new PBPlayerInfo()
            {
                Id               = m_RequestPacket.PlayerId,
                Name             = p.MyPlayer.Name,
                Level            = p.MyPlayer.Level,
                VipLevel         = p.MyPlayer.VIPLevel,
                LastLoginInTicks = p.MyPlayer.LastLoginTime
            };
            LCReceiveRespondToFriendRequest SendPackage = new LCReceiveRespondToFriendRequest()
            {
                Accept = m_RequestPacket.Accept,
                Player = myInfo,
            };

            if (m_RequestPacket.Accept == true)
            {
                if (!pf.AddFriend(m_UserId, m_RequestPacket.PlayerId))
                {
                    ErrorCode = (int)ErrorType.RequireNotMet;
                    ErrorInfo = "Can't add this friend";
                    return(false);
                }
                pf.SetUser(m_UserId);
                m_ResponsePacket.CanGiveEnergy    = pf.MyFriends.Friends[m_RequestPacket.PlayerId].CanSendEnergy;
                m_ResponsePacket.CanReceiveEnergy = pf.MyFriends.Friends[m_RequestPacket.PlayerId].CanReceiveEnergy;
                pf.SetUser(m_RequestPacket.PlayerId);
                SendPackage.CanGiveEnergy    = pf.MyFriends.Friends[m_UserId].CanSendEnergy;
                SendPackage.CanReceiveEnergy = pf.MyFriends.Friends[m_UserId].CanReceiveEnergy;
                pf.RemoveInvitation(m_UserId);
            }
            var target = GameSession.Get(m_RequestPacket.PlayerId);

            if (target != null)
            {
                byte[] buffer = CustomActionDispatcher.GeneratePackageStream(3111, ProtoBufUtils.Serialize(SendPackage));
                target.SendAsync(buffer, 0, buffer.Length);
            }
            pf.SetUser(m_UserId);
            pf.RemoveInvitation(m_RequestPacket.PlayerId);
            m_ResponsePacket.Accept = m_RequestPacket.Accept;
            m_ResponsePacket.Player = friendInfo;
            return(true);
        }
Example #4
0
        private static PBPlayerInfo GetPlayerInfo(int playerId)
        {
            PlayerLogic p = new PlayerLogic();

            p.SetUser(playerId);
            var ret = new PBPlayerInfo()
            {
                Id       = playerId,
                Name     = p.MyPlayer.Name,
                VipLevel = p.MyPlayer.VIPLevel,
                Level    = p.MyPlayer.Level,
            };

            return(ret);
        }
Example #5
0
 public abstract List <PBKeyValuePair> Process(List <PBKeyValuePair> Params, out PBReceivedItems ri, out PBPlayerInfo p, out List <PBLobbyHeroInfo> h);
        private List <PBKeyValuePair> ProcessGetData(List <PBKeyValuePair> Params, out PBReceivedItems receivedItems, out PBPlayerInfo playerInfo, out List <PBLobbyHeroInfo> heroInfos)
        {
            receivedItems = null;
            playerInfo    = null;
            heroInfos     = null;
            List <PBKeyValuePair> retval = new List <PBKeyValuePair>();

            retval.AddRange(Params);
            int dayCnt = CacheSet.OperationActivitySevenDayTable.Count;

            retval.Add(new PBKeyValuePair()
            {
                Key = "DayCnt", Value = dayCnt.ToString()
            });
            retval.Add(new PBKeyValuePair()
            {
                Key = "ClaimedCnt", Value = m_SevenDayCheckIn.ClaimedCount.ToString()
            });
            string hasClaimed = (new DateTime(m_SevenDayCheckIn.LastClaimedTime).Date == DateTime.UtcNow.Date).ToString();

            retval.Add(new PBKeyValuePair()
            {
                Key = "HasClaimed", Value = hasClaimed
            });
            for (int i = 0; i < dayCnt; i++)
            {
                var data = CacheSet.OperationActivitySevenDayTable.GetData(i + 1);
                retval.Add(new PBKeyValuePair()
                {
                    Key = "Reward." + i.ToString() + ".ItemId", Value = data.RewardId.ToString()
                });
                retval.Add(new PBKeyValuePair()
                {
                    Key = "Reward." + i.ToString() + ".ItemCnt", Value = data.RewardCount.ToString()
                });
            }
            return(retval);
        }
        private List <PBKeyValuePair> ProcessClaimReward(List <PBKeyValuePair> Params, out PBReceivedItems receivedItems, out PBPlayerInfo playerInfo, out List <PBLobbyHeroInfo> heroInfos)
        {
            receivedItems = null;
            playerInfo    = null;
            heroInfos     = null;
            int dayCnt = CacheSet.OperationActivitySevenDayTable.Count;

            if (DateTime.UtcNow.Date == new DateTime(m_SevenDayCheckIn.LastClaimedTime).Date || m_SevenDayCheckIn.ClaimedCount >= dayCnt)
            {
                return(null);
            }
            List <PBKeyValuePair> retval = new List <PBKeyValuePair>();

            retval.AddRange(Params);
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_SevenDayCheckIn.UserId);
            var reward = CacheSet.OperationActivitySevenDayTable.GetData(m_SevenDayCheckIn.ClaimedCount + 1);

            pp.GetItems(new Dictionary <int, int>()
            {
                { reward.RewardId, reward.RewardCount }
            }, ReceiveItemMethodType.None, out receivedItems);
            m_SevenDayCheckIn.ClaimedCount   += 1;
            m_SevenDayCheckIn.LastClaimedTime = DateTime.UtcNow.Ticks;
            retval.Add(new PBKeyValuePair()
            {
                Key = "ClaimedCnt", Value = m_SevenDayCheckIn.ClaimedCount.ToString()
            });
            retval.Add(new PBKeyValuePair()
            {
                Key = "HasClaimed", Value = "true"
            });
            return(retval);
        }
        public override List <PBKeyValuePair> Process(List <PBKeyValuePair> Params, out PBReceivedItems receivedItems, out PBPlayerInfo playerInfo, out List <PBLobbyHeroInfo> heroInfos)
        {
            receivedItems = null;
            playerInfo    = null;
            heroInfos     = null;
            if (m_SevenDayCheckIn == null)
            {
                return(null);
            }
            string op = Params.Find(p => p.Key == "Op").Value;
            List <PBKeyValuePair> retval = null;

            switch (op)
            {
            case "GetData":
                retval = ProcessGetData(Params, out receivedItems, out playerInfo, out heroInfos);
                break;

            case "ClaimReward":
                retval = ProcessClaimReward(Params, out receivedItems, out playerInfo, out heroInfos);
                break;

            default:
                return(null);
            }
            return(retval);
        }