示例#1
0
        public override bool TakeAction()
        {
            PlayerCosmosCrackLogic pcc = new PlayerCosmosCrackLogic().SetUser(m_UserId);

            if (!pcc.EnterInstance(m_RequestPacket.InstanceType))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "You have not enough RoundCount";
                return(false);
            }
            m_ResponsePacket.InstanceType = m_RequestPacket.InstanceType;
            PlayerLogic p = new PlayerLogic();

            p.SetUser(m_UserId);
            m_ResponsePacket.NpcLevel = Math.Max(p.MyPlayer.Level + pcc.GetNPCAndPlayerDeltaLevel(m_RequestPacket.InstanceType), 1);
            PlayerInstanceLogic pi = new PlayerInstanceLogic();

            pi.SetUser(m_UserId);
            var dropInfo = pi.EnterInstance(m_RequestPacket.InstanceType);

            if (dropInfo == null)
            {
                ErrorCode = (int)ErrorType.PackageSlotFull;
                ErrorInfo = "Package slot full";
                return(false);
            }
            return(true);
        }
示例#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);
        }