Exemplo n.º 1
0
        public override bool TakeAction()
        {
            PlayerFriendsLogic pf = new PlayerFriendsLogic();

            pf.SetUser(m_UserId);
            if (!pf.ReceiveEnergy(m_RequestPacket.FriendPlayerId))
            {
                ErrorCode = (int)ErrorType.CannotOpenChance;
                ErrorInfo = "you can not receive energy from this player";
                return(false);
            }
            m_ResponsePacket.FriendPlayerId = m_RequestPacket.FriendPlayerId;
            PlayerLogic player = new PlayerLogic();

            player.SetUser(m_UserId);
            long nextRecoverTime;

            player.AddEnergy(1, out nextRecoverTime);
            m_ResponsePacket.Me = new PBPlayerInfo()
            {
                Id     = player.MyPlayer.Id,
                Energy = player.MyPlayer.Energy,
                NextEnergyRecoveryTime = nextRecoverTime
            };
            m_ResponsePacket.RemainCount = GameConsts.Social.MaxReceiveCount - pf.MyFriends.ReceiveCount;
            return(true);
        }
Exemplo n.º 2
0
        public override bool TakeAction()
        {
            PlayerFriendsLogic pf = new PlayerFriendsLogic();

            if (!pf.DeleteFriend(m_UserId, m_RequestPacket.PlayerId))
            {
                ErrorCode = (int)ErrorType.CannotOpenChance;
                ErrorInfo = "You don't have this friend";
                return(false);
            }
            var target = GameSession.Get(m_RequestPacket.PlayerId);

            if (target != null)
            {
                LCDeleteFriend sendPost = new LCDeleteFriend()
                {
                    DeletedPlayerId = m_UserId,
                    IsActive        = false
                };
                byte[] buffer = CustomActionDispatcher.GeneratePackageStream(3104, ProtoBufUtils.Serialize(sendPost));
                target.SendAsync(buffer, 0, buffer.Length);
            }


            m_ResponsePacket.DeletedPlayerId = m_RequestPacket.PlayerId;
            m_ResponsePacket.IsActive        = true;
            return(true);
        }
Exemplo n.º 3
0
        public override bool TakeAction()
        {
            m_ResponsePacket.PlayerId = m_RequestPacket.FriendCandidatePlayerId;
            PlayerFriendsLogic pf = new PlayerFriendsLogic();

            pf.SetUser(m_RequestPacket.FriendCandidatePlayerId);
            if (!pf.Invited(m_UserId))
            {
                ErrorCode = (int)ErrorType.CannotMakeFriendRequest;
                ErrorInfo = "You can not invite this player";
                return(false);
            }
            var target = GameSession.Get(m_RequestPacket.FriendCandidatePlayerId);

            if (target == null)
            {
                return(true);
            }
            LCReceiveFriendRequest request = new LCReceiveFriendRequest();
            PlayerLogic            p       = new PlayerLogic();

            p.SetUser(m_UserId);
            request.Player = new PBPlayerInfo()
            {
                Id       = m_UserId,
                Name     = p.MyPlayer.Name,
                Level    = p.MyPlayer.Level,
                VipLevel = p.MyPlayer.VIPLevel
            };
            byte[] buffer = CustomActionDispatcher.GeneratePackageStream(3107, ProtoBufUtils.Serialize(request));
            target.SendAsync(buffer, 0, buffer.Length);
            return(true);
        }
Exemplo n.º 4
0
        public override bool TakeAction()
        {
            PlayerFriendsLogic pf = new PlayerFriendsLogic();

            pf.SetUser(m_UserId);
            PlayerLogic p = new PlayerLogic();

            foreach (var player in pf.GetFriends())
            {
                p.SetUser(player.Key);
                m_ResponsePacket.Players.Add(new PBPlayerInfo()
                {
                    Id               = player.Key,
                    Name             = p.MyPlayer.Name,
                    Level            = p.MyPlayer.Level,
                    VipLevel         = p.MyPlayer.VIPLevel,
                    LastLoginInTicks = p.MyPlayer.LastLoginTime,
                    IsOnline         = p.MyPlayer.Status == PlayerStatus.Online
                });

                m_ResponsePacket.CanGiveEnergy.Add(player.Value.CanSendEnergy);
                m_ResponsePacket.CanReceiveEnergy.Add(player.Value.CanReceiveEnergy);
            }
            return(true);
        }
        private void InitFriendCountAchievementProgress(TrackingAchievement achievement)
        {
            PlayerFriendsLogic pf = new PlayerFriendsLogic();

            pf.SetUser(m_UserId);
            achievement.Progress = pf.GetFriends().Count;
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
        public override bool TakeAction()
        {
            PlayerFriendsLogic pf = new PlayerFriendsLogic();

            pf.SetUser(m_UserId);
            var               nearbyPlayers = pf.GetOnlinePlayers();
            var               friends       = pf.GetFriends();
            HeroTeamLogic     ht            = new HeroTeamLogic();
            PlayerHeroLogic   ph            = new PlayerHeroLogic();
            NearbyPlayerLogic np            = new NearbyPlayerLogic();

            foreach (var player in nearbyPlayers)
            {
                ht.SetUser(player.Id);
                ph.SetUser(player.Id).SetHero(ht.GetTeam()[0]);
                Hero hero = ph.GetHeroInfo();
                if (hero == null)
                {
                    continue;
                }
                m_ResponsePacket.Heroes.Add(new PBLobbyHeroInfo()
                {
                    Type               = hero.HeroType,
                    Level              = hero.HeroLv,
                    StarLevel          = hero.HeroStarLevel,
                    ConsciousnessLevel = hero.ConsciousnessLevel,
                    ElevationLevel     = hero.ElevationLevel
                });
                np.SetUser(player.Id);
                m_ResponsePacket.Players.Add(new PBPlayerInfo()
                {
                    Id               = player.Id,
                    Name             = player.Name,
                    Level            = player.Level,
                    VipLevel         = player.VIPLevel,
                    PortraitType     = player.PortraitType,
                    LastLoginInTicks = player.LastLoginTime,
                    PositionX        = np.NearbyPlayers.MyPositionX,
                    PositionY        = np.NearbyPlayers.MyPositionY,
                    DisplayId        = player.UUID
                });
                if (friends.ContainsKey(player.Id))
                {
                    m_ResponsePacket.IsMyFriend.Add(true);
                }
                else
                {
                    m_ResponsePacket.IsMyFriend.Add(false);
                }
            }
            return(true);
        }
Exemplo n.º 8
0
        public override bool TakeAction()
        {
            List <Player> resPlayers;

            if (m_RequestPacket.HasDisplayId)
            {
                resPlayers = PlayerLogic.FindUserByUUID(m_RequestPacket.DisplayId);
            }
            else
            {
                resPlayers = PlayerLogic.FindUsersByName(m_RequestPacket.Input);
            }

            PlayerFriendsLogic pf = new PlayerFriendsLogic();

            pf.SetUser(m_UserId);
            var friends = pf.GetFriends();

            foreach (var player in resPlayers)
            {
                if (player == null)
                {
                    continue;
                }
                m_ResponsePacket.Players.Add(new PBPlayerInfo()
                {
                    Id               = player.Id,
                    Name             = player.Name,
                    Level            = player.Level,
                    VipLevel         = player.VIPLevel,
                    LastLoginInTicks = player.LastLoginTime
                });
                if (friends.ContainsKey(player.Id))
                {
                    m_ResponsePacket.IsMyFriend.Add(true);
                }
                else
                {
                    m_ResponsePacket.IsMyFriend.Add(false);
                }
            }
            return(true);
        }
Exemplo n.º 9
0
        public override bool TakeAction()
        {
            PlayerFriendsLogic pf = new PlayerFriendsLogic();

            pf.SetUser(m_UserId);
            foreach (var player in pf.GetRecommendedPlayers())
            {
                m_ResponsePacket.Players.Add(new PBPlayerInfo()
                {
                    Id               = player.Id,
                    Name             = player.Name,
                    Level            = player.Level,
                    VipLevel         = player.VIPLevel,
                    LastLoginInTicks = player.LastLoginTime,
                    IsOnline         = player.Status == PlayerStatus.Online
                });
            }
            return(true);
        }
Exemplo n.º 10
0
        public override bool TakeAction()
        {
            PlayerFriendsLogic pf = new PlayerFriendsLogic();

            pf.SetUser(m_UserId);
            var         invitations = pf.GetInvitations();
            PlayerLogic p           = new PlayerLogic();

            foreach (int id in invitations)
            {
                p.SetUser(id);
                m_ResponsePacket.Players.Add(new PBPlayerInfo()
                {
                    Id       = p.MyPlayer.Id,
                    Name     = p.MyPlayer.Name,
                    VipLevel = p.MyPlayer.VIPLevel,
                    Level    = p.MyPlayer.Level
                });
            }
            return(true);
        }
Exemplo n.º 11
0
        public override bool TakeAction()
        {
            PlayerFriendsLogic pf = new PlayerFriendsLogic();

            pf.SetUser(m_UserId);
            if (!pf.SendEnergy(m_RequestPacket.FriendPlayerId))
            {
                ErrorCode = (int)ErrorType.CannotOpenChance;
                ErrorInfo = "you can not send energy to this player";
                return(false);
            }
            GameSession target = GameSession.Get(m_RequestPacket.FriendPlayerId);

            if (target != null)
            {
                LCGivenEnergyByFriend package = new LCGivenEnergyByFriend();
                package.FriendPlayerId = m_UserId;
                byte[] buffer = CustomActionDispatcher.GeneratePackageStream(3112, ProtoBufUtils.Serialize(package));
                target.SendAsync(buffer, 0, buffer.Length);
            }
            m_ResponsePacket.FriendPlayerId = m_RequestPacket.FriendPlayerId;
            m_ResponsePacket.RemainCount    = GameConsts.Social.MaxSendCount - pf.MyFriends.SendCount;
            return(true);
        }
Exemplo n.º 12
0
        public override bool TakeAction()
        {
            PlayerLogic player = new PlayerLogic();

            player.SetUser(m_RequestPacket.PlayerId);
            PlayerHeroLogic ph = new PlayerHeroLogic();

            ph.SetUser(m_RequestPacket.PlayerId);
            m_ResponsePacket.Player = new PBPlayerInfo()
            {
                Id              = player.MyPlayer.Id,
                Name            = player.MyPlayer.Name,
                VipLevel        = player.MyPlayer.VIPLevel,
                Level           = player.MyPlayer.Level,
                PlayerHeroCount = ph.MyHeros.Heros.Count,
                Might           = player.MyPlayer.Might,
                DisplayId       = player.MyPlayer.UUID
            };
            PlayerFriendsLogic pf = new PlayerFriendsLogic();

            pf.SetUser(m_RequestPacket.PlayerId);
            var friends = pf.GetFriends();

            if (friends.ContainsKey(m_UserId))
            {
                m_ResponsePacket.IsMyFriend = true;
            }
            else
            {
                m_ResponsePacket.IsMyFriend = false;
            }

            HeroTeamLogic ht = new HeroTeamLogic();

            ht.SetUser(m_RequestPacket.PlayerId);
            GearLogic g = new GearLogic();
            SoulLogic s = new SoulLogic();

            foreach (int heroType in ht.MyHeroTeam.Team)
            {
                if (heroType == 0)
                {
                    continue;
                }
                var hero     = ph.SetHero(heroType).GetHeroInfo();
                var heroInfo = new PBLobbyHeroInfo()
                {
                    Type  = hero.HeroType,
                    Level = hero.HeroLv,
                    ConsciousnessLevel = hero.ConsciousnessLevel,
                    ElevationLevel     = hero.ElevationLevel,
                    StarLevel          = hero.HeroStarLevel,
                    Might = hero.Might,
                };
                heroInfo.SkillLevels.AddRange(hero.SkillLevels);
                foreach (var gear in hero.Gears)
                {
                    g.SetGear(gear.Value);
                    heroInfo.GearInfo.Add(new PBGearInfo()
                    {
                        Id              = g.MyGear.Id,
                        Type            = g.MyGear.TypeId,
                        Level           = g.MyGear.Level,
                        StrengthenLevel = g.MyGear.StrengthenLevel
                    });
                }
                foreach (var soul in hero.Souls)
                {
                    s.SetSoul(soul.Value);
                    heroInfo.SoulInfo.Add(new PBSoulInfo()
                    {
                        Id   = s.MySoul.Id,
                        Type = s.MySoul.TypeId,
                    });
                }
                m_ResponsePacket.HeroTeam.Add(heroInfo);
            }
            return(true);
        }