Ejemplo n.º 1
0
        public List <PBDropInfo> EnterInstance(int instanceId)
        {
            if (m_InstanceDrop != null)
            {
                CacheSet.InstanceDropCache.Delete(m_InstanceDrop);
            }
            List <PBDropInfo> dropInfo;

            m_InstanceDrop            = new PlayerInstanceDrop();
            m_InstanceDrop.UserId     = m_UserId;
            m_InstanceDrop.InstanceId = instanceId;
            DTInstance instanceData = CacheSet.InstanceTable.GetData(instanceId);

            m_InstanceDrop.ChestList.AddRange(instanceData.InInstanceChests);
            m_InstanceDrop.DropList = GenerateDropList(instanceId, false, out dropInfo);
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            if (!pp.CheckPackageSlot(m_InstanceDrop.DropList))
            {
                return(null);
            }
            CacheSet.InstanceDropCache.Add(m_InstanceDrop);
            return(dropInfo);
            //RedisConnectionPool.Process(c => c.Expire("$Genesis.GameServer.LobbyServer.PlayerInstanceDrop", 3600));
        }
Ejemplo n.º 2
0
        private void GetInstanceReward(PlayerInstanceLogic instance)
        {
            int         instanceId = instance.MyInstance.InstanceId;
            PlayerLogic player     = new PlayerLogic();

            player.SetUser(m_UserId);
            long nextRecoverTime;

            if (!m_RequestPacket.Win)
            {
                int feedbackEnergy = PlayerInstanceLogic.GetFeedBackEnergy(instanceId);
                player.AddEnergy(feedbackEnergy, out nextRecoverTime);
                m_ResponsePacket.PlayerInfo        = new PBPlayerInfo();
                m_ResponsePacket.PlayerInfo.Energy = player.MyPlayer.Energy;
                m_ResponsePacket.PlayerInfo.NextEnergyRecoveryTime = nextRecoverTime;
                return;
            }
            DTInstance instanceData = PlayerInstanceLogic.GetInstanceData(instanceId);

            player.MyPlayer.Coin += instanceData.Coin;
            player.AddExp(instanceData.PlayerExp);
            m_ResponsePacket.PlayerInfo       = new PBPlayerInfo();
            m_ResponsePacket.PlayerInfo.Id    = player.MyPlayer.Id;
            m_ResponsePacket.PlayerInfo.Coin  = player.MyPlayer.Coin;
            m_ResponsePacket.PlayerInfo.Exp   = player.MyPlayer.Exp;
            m_ResponsePacket.PlayerInfo.Level = player.MyPlayer.Level;
            HeroTeamLogic heroTeam = new HeroTeamLogic();

            heroTeam.SetUser(m_UserId);
            PlayerHeroLogic playerHero = new PlayerHeroLogic();

            playerHero.SetUser(m_UserId);
            foreach (int heroId in heroTeam.MyHeroTeam.Team)
            {
                if (heroId == 0)
                {
                    continue;
                }
                playerHero.SetHero(heroId).AddExp(instanceData.HeroExp);
                m_ResponsePacket.LobbyHeroInfo.Add(new PBLobbyHeroInfo()
                {
                    Type  = heroId,
                    Exp   = playerHero.MyHeros.Heros[heroId].HeroExp,
                    Level = playerHero.MyHeros.Heros[heroId].HeroLv,
                    Might = playerHero.MyHeros.Heros[heroId].Might,
                });
            }
            m_ResponsePacket.InstanceType = instance.MyInstance.InstanceId;
            CacheDictionary <int, int> dropDict = instance.GetDropList();
            PlayerPackageLogic         package  = new PlayerPackageLogic();

            package.SetUser(m_UserId);
            PBReceivedItems receivedItems;

            package.GetItems(dropDict, ReceiveItemMethodType.CompleteInstance, out receivedItems);
            m_ResponsePacket.ReceivedItems = receivedItems;
        }
Ejemplo n.º 3
0
        public CacheDictionary <int, int> GenerateDropList(int instanceId, bool isCleanOut, out List <PBDropInfo> dropInfoList)
        {
            DTInstance instanceData             = CacheSet.InstanceTable.GetData(instanceId);
            CacheDictionary <int, int> dropDict = new CacheDictionary <int, int>();
            int totalCount = 0;

            dropInfoList = new List <PBDropInfo>();
            var dropIds = isCleanOut ? instanceData.CleanOutDropIds : instanceData.DropIds;

            foreach (DropGroup dropGroup in dropIds)
            {
                Random random      = new Random();
                int    randomValue = random.Next(1, 1000);
                int    id          = 0;
                foreach (var dropInfo in dropGroup.Drops)
                {
                    if (randomValue - dropInfo.Value <= 0)
                    {
                        id = dropInfo.Key;
                        break;
                    }
                }
                if (id == 0)
                {
                    continue;
                }
                DTDrop drop = CacheSet.DropTable.GetData(id);
                m_RandomDrop.GetDropDict(drop, dropDict);
                int tmpTotalCount = 0;
                foreach (var item in dropDict)
                {
                    tmpTotalCount += item.Value;
                }
                totalCount = tmpTotalCount;
            }
            return(dropDict);
        }
Ejemplo n.º 4
0
        public override bool TakeAction()
        {
            InstanceProgressLogic ip = new InstanceProgressLogic();

            ip.SetUser(m_UserId);
            if (!(ip.GetInstanceProgress()).ContainsKey(m_RequestPacket.InstanceId))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "You have not passed this instance";
                return(false);
            }
            PlayerInstanceLogic pi = new PlayerInstanceLogic();

            pi.SetUser(m_UserId);
            CacheDictionary <int, int> dropItems = new CacheDictionary <int, int>();

            for (int i = 0; i < m_RequestPacket.Count; i++)
            {
                PBInstanceDrop    instanceDrop = new PBInstanceDrop();
                List <PBDropInfo> dropList     = new List <PBDropInfo>();
                List <PBDropInfo> dropPack;
                var dropDict = pi.GenerateDropList(m_RequestPacket.InstanceId, true, out dropPack);
                GameUtils.MergeItemDict(dropItems, dropDict);
                foreach (var dropItem in dropDict)
                {
                    PBDropInfo item = new PBDropInfo()
                    {
                        DropId    = dropItem.Key,
                        DropCount = dropItem.Value
                    };
                    instanceDrop.Items.Add(item);
                }
                m_ResponsePacket.Drops.Add(instanceDrop);
            }
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            if (!pp.CheckPackageSlot(dropItems))
            {
                ErrorCode = (int)ErrorType.PackageSlotFull;
                ErrorInfo = "Package full";
                return(false);
            }
            PlayerLogic p = new PlayerLogic();

            p.SetUser(m_UserId);
            int  energy = PlayerInstanceLogic.GetInstanceEnergy(m_RequestPacket.InstanceId);
            long nextRecoverTime;

            if (!p.DeductEnergy(energy * m_RequestPacket.Count, out nextRecoverTime))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "You have not enough energy";
                return(false);
            }
            PBReceivedItems receivedItems;

            pp.GetItems(dropItems, ReceiveItemMethodType.CompleteInstance, out receivedItems);
            m_ResponsePacket.ReceivedItems = receivedItems;
            DTInstance instanceData = PlayerInstanceLogic.GetInstanceData(m_RequestPacket.InstanceId);

            p.AddCoin(instanceData.Coin * m_RequestPacket.Count);
            p.AddExp(instanceData.PlayerExp * m_RequestPacket.Count);
            m_ResponsePacket.Count      = m_RequestPacket.Count;
            m_ResponsePacket.InstanceId = m_RequestPacket.InstanceId;
            m_ResponsePacket.PlayerInfo = new PBPlayerInfo()
            {
                Id     = m_UserId,
                Coin   = p.MyPlayer.Coin,
                Exp    = p.MyPlayer.Exp,
                Level  = p.MyPlayer.Level,
                Energy = p.MyPlayer.Energy,
                NextEnergyRecoveryTime = nextRecoverTime
            };
            HeroTeamLogic heroTeam = new HeroTeamLogic();

            heroTeam.SetUser(m_UserId);
            PlayerHeroLogic playerHero = new PlayerHeroLogic();

            playerHero.SetUser(m_UserId);
            foreach (int heroId in heroTeam.MyHeroTeam.Team)
            {
                if (heroId == 0)
                {
                    continue;
                }
                //playerHero.SetHero(heroId).AddExp(instanceData.HeroExp);
                m_ResponsePacket.LobbyHeroInfo.Add(new PBLobbyHeroInfo()
                {
                    Type  = heroId,
                    Exp   = playerHero.MyHeros.Heros[heroId].HeroExp,
                    Level = playerHero.MyHeros.Heros[heroId].HeroLv
                });
            }
            PlayerDailyQuestLogic.GetInstance(m_UserId).UpdateDailyQuest(DailyQuestType.CleanOutInstance, m_RequestPacket.Count);
            return(true);
        }