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); }
public override bool TakeAction() { PlayerInstanceLogic pi = new PlayerInstanceLogic(); pi.SetUser(m_UserId); var dropDict = pi.OpenInInstanceChest(m_RequestPacket.ChestIndex); foreach (var goods in dropDict) { m_ResponsePacket.GoodsInfo.Add(new PBItemInfo() { Type = goods.Key, Count = goods.Value }); } PlayerPackageLogic pp = new PlayerPackageLogic(); pp.SetUser(m_UserId); PBReceivedItems receivedItems; pp.GetItems(dropDict, ReceiveItemMethodType.CompleteInstance, out receivedItems); m_ResponsePacket.ReceivedItems = receivedItems; PlayerLogic p = new PlayerLogic(); p.SetUser(m_UserId); m_ResponsePacket.PlayerInfo = new PBPlayerInfo() { Id = p.MyPlayer.Id, Coin = p.MyPlayer.Coin, Money = p.MyPlayer.Money, Spirit = p.MyPlayer.Spirit, MeridianEnergy = p.MyPlayer.StarEnergy }; return(true); }
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); }
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; }
public override bool TakeAction() { PlayerInstanceLogic pi = new PlayerInstanceLogic(); pi.SetUser(m_UserId); pi.LeaveInstance(); if (!m_RequestPacket.Win) { m_ResponsePacket.Win = false; m_ResponsePacket.InstanceType = m_RequestPacket.InstanceType; return(true); } PlayerCosmosCrackLogic pcc = new PlayerCosmosCrackLogic().SetUser(m_UserId); m_ResponsePacket.RewardLevel = pcc.GetCosmosCrackInstanceInfo().ChosenInstance[m_RequestPacket.InstanceType].RewardLevel; var rewards = pcc.LeaveInstance(m_RequestPacket.InstanceType); PlayerPackageLogic pp = new PlayerPackageLogic(); pp.SetUser(m_UserId); PBReceivedItems receivedItems; pp.GetItems(rewards, ReceiveItemMethodType.None, out receivedItems); m_ResponsePacket.ReceivedItems = receivedItems; m_ResponsePacket.Win = true; m_ResponsePacket.InstanceType = m_RequestPacket.InstanceType; PlayerLogic p = new PlayerLogic(); p.SetUser(m_UserId); m_ResponsePacket.PlayerInfo = new PBPlayerInfo() { Id = m_UserId, Coin = p.MyPlayer.Coin, Money = p.MyPlayer.Money, Energy = p.MyPlayer.Energy, Spirit = p.MyPlayer.Spirit, MeridianEnergy = p.MyPlayer.StarEnergy, DragonStripeToken = p.MyPlayer.DragonStripeToken }; return(true); }
public override bool TakeAction() { PlayerInstanceLogic playerinstance = new PlayerInstanceLogic(); playerinstance.SetUser(m_UserId); if (playerinstance.MyInstance == null) { ErrorCode = (int)ErrorType.PlayerNotInInstance; ErrorInfo = "You have not enter instance"; return(false); } GetInstanceReward(playerinstance); playerinstance.LeaveInstance(); if (m_RequestPacket.Win) { InstanceProgressLogic instanceProgress = new InstanceProgressLogic(); instanceProgress.SetUser(m_UserId); instanceProgress.InstanceCompleted(playerinstance.MyInstance.InstanceId, m_RequestPacket.StarCount); } m_ResponsePacket.Win = m_RequestPacket.Win; m_ResponsePacket.StarCount = m_RequestPacket.StarCount; return(true); }
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); }