public override void Destruct() { base.Destruct(); this.m_x = 0; this.m_y = 0; this.m_decoData = null; }
public override void Decode(ByteStream stream) { this.m_x = stream.ReadInt(); this.m_y = stream.ReadInt(); this.m_decoData = (LogicDecoData)ByteStreamHelper.ReadDataReference(stream, LogicDataType.DECO); base.Decode(stream); }
public override int Execute(LogicLevel level) { LogicGameObject gameObject = level.GetGameObjectManager().GetGameObjectByID(this.m_gameObjectId); if (gameObject != null) { LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); if (gameObject.GetGameObjectType() == LogicGameObjectType.BUILDING) { LogicBuilding building = (LogicBuilding)gameObject; if (building.CanSell()) { playerAvatar.CommodityCountChangeHelper(0, building.GetSellResource(), building.GetSellPrice()); building.OnSell(); level.GetGameObjectManager().RemoveGameObject(building); return(0); } } else if (gameObject.GetGameObjectType() == LogicGameObjectType.DECO) { LogicDeco deco = (LogicDeco)gameObject; LogicDecoData data = deco.GetDecoData(); LogicResourceData buildResourceData = data.GetBuildResource(); int sellPrice = data.GetSellPrice(); if (buildResourceData.IsPremiumCurrency()) { playerAvatar.SetDiamonds(playerAvatar.GetDiamonds() + sellPrice); playerAvatar.SetFreeDiamonds(playerAvatar.GetFreeDiamonds() + sellPrice); playerAvatar.GetChangeListener().FreeDiamondsAdded(sellPrice, 6); } else { playerAvatar.CommodityCountChangeHelper(0, buildResourceData, sellPrice); } level.GetGameObjectManager().RemoveGameObject(deco); return(0); } } return(-1); }
public void SetDecorationData(LogicDecoData data) { this.m_decoData = data; }
public override void ReadFromJSON(LogicJSONObject jsonObject) { base.ReadFromJSON(jsonObject); this.m_decoData = (LogicDecoData)LogicJSONHelper.GetLogicData(jsonObject, "decoration"); }
public virtual void DecoCapReached(LogicDecoData data) { }
/// <summary> /// Creates the data for the specified row. /// </summary> internal LogicData Create(Row row) { LogicData data; switch (this.Index) { case 1: { data = new LogicLocaleData(row, this); break; } case 2: { data = new LogicResourceData(row, this); break; } case 3: { data = new LogicEffectData(row, this); break; } case 4: { data = new LogicParticleEmitterData(row, this); break; } case 5: { data = new LogicGlobalData(row, this); break; } case 6: { data = new LogicQuestData(row, this); break; } case 8: { data = new LogicAchievementData(row, this); break; } case 10: { data = new LogicWorldData(row, this); break; } case 11: { data = new LogicHeroData(row, this); break; } case 12: { data = new LogicExperienceLevelData(row, this); break; } case 13: { data = new LogicLeagueData(row, this); break; } case 21: { data = new LogicAllianceBadgeData(row, this); break; } case 24: { data = new LogicTauntData(row, this); break; } case 25: { data = new LogicDecoData(row, this); break; } case 26: { data = new LogicVariableData(row, this); break; } case 28: { data = new LogicBoosterData(row, this); break; } case 32: { data = new LogicEnergyPackageData(row, this); break; } case 35: { data = new LogicSpellData(row, this); break; } case 36: { data = new LogicObstacleData(row, this); break; } case 37: { data = new LogicItemsData(row, this); break; } default: { data = new LogicData(row, this); break; } } return(data); }
internal override void Execute() { if (this.Data != null) { if (this.DataType == 0) { LogicTauntData taunt = (LogicTauntData)this.Data; if (!this.Connection.Avatar.Extras.ContainsKey(taunt.GlobalID)) { if (!string.IsNullOrEmpty(taunt.CharacterUnlock)) { LogicHeroData hero = (LogicHeroData)CSV.Tables.Get(Gamefile.Heroes).GetDataByName(taunt.CharacterUnlock); if (!this.Connection.Avatar.HeroLevels.ContainsKey(hero.GlobalID)) { Debugger.Error($"Unable to buy the taunt. {this.Connection.Avatar.Name} ({this.Connection.Avatar}) doesn't have the hero {taunt.CharacterUnlock}."); return; } } if (taunt.Cost > 0) { LogicResourceData resource = (LogicResourceData)CSV.Tables.Get(Gamefile.Resources).GetDataByName(taunt.Resource); if (this.Connection.Avatar.Resources.GetCount(resource.GlobalID) < taunt.Cost) { Debugger.Error($"Unable to buy the taunt. {this.Connection.Avatar.Name} does not have enough {taunt.Resource}. {taunt.Resource} : {this.Connection.Avatar.Resources.GetCount(resource.GlobalID)}, Require : {taunt.Cost}."); return; } this.Connection.Avatar.Resources.Remove(resource.GlobalID, taunt.Cost); } this.Connection.Avatar.Extras.Set(taunt.GlobalID, 1); } } else { LogicDecoData deco = (LogicDecoData)this.Data; if (!this.Connection.Avatar.Extras.ContainsKey(deco.GlobalID)) { if (deco.UnlockLevel > this.Connection.Avatar.ExpLevel) { Debugger.Error($"Unable to buy the deco. {this.Connection.Avatar.Name} ({this.Connection.Avatar}) is not at the required level."); return; } if (deco.Cost > 0) { LogicResourceData resource = (LogicResourceData)CSV.Tables.Get(Gamefile.Resources).GetDataByName(deco.Resource); if (this.Connection.Avatar.Resources.GetCount(resource.GlobalID) < deco.Cost) { Debugger.Error($"Unable to buy the deco. {this.Connection.Avatar.Name} ({this.Connection.Avatar}) does not have enough {deco.Resource}. ({deco.Resource} : {this.Connection.Avatar.Resources.GetCount(resource.GlobalID)}, Require : {deco.Cost}."); return; } this.Connection.Avatar.Resources.Remove(resource.GlobalID, deco.Cost); } this.Connection.Avatar.Extras.Set(deco.GlobalID, 2); if (this.Connection.Avatar.Extras.Count > 1) { foreach (Item item in this.Connection.Avatar.Extras.Values) { if (item.Id / 1000000 == deco.GetDataType()) { if (item.Count != 1 && item.Id != deco.GlobalID) { item.Count = 1; } } } } } else { if (this.Connection.Avatar.Extras.GetCount(deco.GlobalID) == 1) { this.Connection.Avatar.Extras.Set(deco.GlobalID, 2); foreach (Item item in this.Connection.Avatar.Extras.Values) { if (item.Id / 1000000 == deco.GetDataType()) { if (item.Count != 1 && item.Id != deco.GlobalID) { item.Count = 1; } } } } else { this.Connection.Avatar.Extras.Set(deco.GlobalID, 1); } } } } else { Debugger.Error("Unable to buy the extra. Data is null."); } }
public override int Execute(LogicLevel level) { if (this.m_gameObjectData != null && level.GetUnplacedObjectCount(this.m_gameObjectData) > 0) { if (level.GetVillageType() == this.m_gameObjectData.GetVillageType()) { LogicDataType dataType = this.m_gameObjectData.GetDataType(); if (dataType == LogicDataType.BUILDING) { LogicBuildingData buildingData = (LogicBuildingData)this.m_gameObjectData; if (level.IsValidPlaceForBuilding(this.m_x, this.m_y, buildingData.GetWidth(), buildingData.GetHeight(), null)) { if (!level.RemoveUnplacedObject(this.m_gameObjectData, this.m_upgradeLevel)) { return(-63); } LogicBuilding building = (LogicBuilding)LogicGameObjectFactory.CreateGameObject(this.m_gameObjectData, level, level.GetVillageType()); building.SetPositionXY(this.m_x << 9, this.m_y << 9); level.GetGameObjectManager().AddGameObject(building, -1); building.FinishConstruction(false, true); building.SetUpgradeLevel(this.m_upgradeLevel); } return(0); } if (dataType == LogicDataType.TRAP) { LogicTrapData trapData = (LogicTrapData)this.m_gameObjectData; if (level.IsValidPlaceForBuilding(this.m_x, this.m_y, trapData.GetWidth(), trapData.GetHeight(), null)) { if (!level.RemoveUnplacedObject(this.m_gameObjectData, this.m_upgradeLevel)) { return(-64); } LogicTrap trap = (LogicTrap)LogicGameObjectFactory.CreateGameObject(this.m_gameObjectData, level, level.GetVillageType()); trap.SetPositionXY(this.m_x << 9, this.m_y << 9); trap.FinishConstruction(false); trap.SetUpgradeLevel(this.m_upgradeLevel); level.GetGameObjectManager().AddGameObject(trap, -1); } return(0); } if (dataType == LogicDataType.DECO) { LogicDecoData decoData = (LogicDecoData)this.m_gameObjectData; if (level.IsValidPlaceForBuilding(this.m_x, this.m_y, decoData.GetWidth(), decoData.GetHeight(), null)) { if (!level.RemoveUnplacedObject(this.m_gameObjectData, this.m_upgradeLevel)) { return(-65); } LogicDeco deco = (LogicDeco)LogicGameObjectFactory.CreateGameObject(this.m_gameObjectData, level, level.GetVillageType()); deco.SetPositionXY(this.m_x << 9, this.m_y << 9); level.RemoveUnplacedObject(this.m_gameObjectData, this.m_upgradeLevel); level.GetGameObjectManager().AddGameObject(deco, -1); } return(0); } return(-3); } return(-35); } return(0); }
public LogicBuyDecoCommand(int x, int y, LogicDecoData decoData) { this.m_x = x; this.m_y = y; this.m_decoData = decoData; }