public override void Execute(Level level) { List <DataSlot> units = level.GetPlayerAvatar().GetUnits(); List <DataSlot> spells = level.GetPlayerAvatar().GetSpells(); foreach (UnitToRemove unitToRemove in UnitsToRemove) { if (unitToRemove.Data.ToString().StartsWith("400")) { CombatItemData _Troop = (CombatItemData)CSVManager.DataTables.GetDataById(unitToRemove.Data); DataSlot dataSlot = units.Find((Predicate <DataSlot>)(t => t.Data.GetGlobalID() == _Troop.GetGlobalID())); if (dataSlot != null) { dataSlot.Value = dataSlot.Value - 1; } } else if (unitToRemove.Data.ToString().StartsWith("260")) { SpellData _Spell = (SpellData)CSVManager.DataTables.GetDataById(unitToRemove.Data); DataSlot dataSlot = spells.Find((Predicate <DataSlot>)(t => t.Data.GetGlobalID() == _Spell.GetGlobalID())); if (dataSlot != null) { dataSlot.Value = dataSlot.Value - 1; } } } }
internal override void Process() { List <DataSlot> _PlayerUnits = this.Device.Player.Avatar.GetUnits(); List <DataSlot> _PlayerSpells = this.Device.Player.Avatar.GetSpells(); foreach (UnitToRemove _Unit in UnitsToRemove) { if (_Unit.Data.ToString().StartsWith("400")) { CombatItemData _Troop = (CombatItemData)CSVManager.DataTables.GetDataById(_Unit.Data);; DataSlot _DataSlot = _PlayerUnits.Find(t => t.Data.GetGlobalID() == _Troop.GetGlobalID()); if (_DataSlot != null) { _DataSlot.Value = _DataSlot.Value - _Unit.Count; } } else if (_Unit.Data.ToString().StartsWith("260")) { SpellData _Spell = (SpellData)CSVManager.DataTables.GetDataById(_Unit.Data);; DataSlot _DataSlot = _PlayerSpells.Find(t => t.Data.GetGlobalID() == _Spell.GetGlobalID()); if (_DataSlot != null) { _DataSlot.Value = _DataSlot.Value - _Unit.Count; } } } }
internal override void Process() { ClientAvatar _Player = this.Device.Player.Avatar; if (UnitType.ToString().StartsWith("400")) { CombatItemData _TroopData = (CombatItemData)CSVManager.DataTables.GetDataById(UnitType); List <DataSlot> _PlayerUnits = this.Device.Player.Avatar.GetUnits(); ResourceData _TrainingResource = _TroopData.GetTrainingResource(); if (_TroopData != null) { DataSlot _DataSlot = _PlayerUnits.Find(t => t.Data.GetGlobalID() == _TroopData.GetGlobalID()); if (_DataSlot != null) { _DataSlot.Value = _DataSlot.Value + this.Count; } else { DataSlot ds = new DataSlot(_TroopData, this.Count); _PlayerUnits.Add(ds); } _Player.SetResourceCount(_TrainingResource, _Player.GetResourceCount(_TrainingResource) - _TroopData.GetTrainingCost(_Player.GetUnitUpgradeLevel(_TroopData))); } } else if (UnitType.ToString().StartsWith("260")) { SpellData _SpellData = (SpellData)CSVManager.DataTables.GetDataById(UnitType); List <DataSlot> _PlayerSpells = this.Device.Player.Avatar.GetSpells(); ResourceData _CastResource = _SpellData.GetTrainingResource(); if (_SpellData != null) { DataSlot _DataSlot = _PlayerSpells.Find(t => t.Data.GetGlobalID() == _SpellData.GetGlobalID()); if (_DataSlot != null) { _DataSlot.Value = _DataSlot.Value + this.Count; } else { DataSlot ds = new DataSlot(_SpellData, this.Count); _PlayerSpells.Add(ds); } _Player.SetResourceCount(_CastResource, _Player.GetResourceCount(_CastResource) - _SpellData.GetTrainingCost(_Player.GetUnitUpgradeLevel(_SpellData))); } } }
public override void Execute(Level level) { ClientAvatar avatar = level.GetPlayerAvatar(); if (UnitType.ToString().StartsWith("400")) { CombatItemData _TroopData = (CombatItemData)CSVManager.DataTables.GetDataById(UnitType); List <DataSlot> units = level.GetPlayerAvatar().GetUnits(); ResourceData trainingResource = _TroopData.GetTrainingResource(); if (_TroopData == null) { return; } DataSlot dataSlot1 = units.Find((Predicate <DataSlot>)(t => t.Data.GetGlobalID() == _TroopData.GetGlobalID())); if (dataSlot1 != null) { dataSlot1.Value = dataSlot1.Value + Count; } else { DataSlot dataSlot2 = new DataSlot((Data)_TroopData, Count); units.Add(dataSlot2); } avatar.SetResourceCount(trainingResource, avatar.GetResourceCount(trainingResource) - _TroopData.GetTrainingCost(avatar.GetUnitUpgradeLevel(_TroopData))); } else { if (!this.UnitType.ToString().StartsWith("260")) { return; } SpellData _SpellData = (SpellData)CSVManager.DataTables.GetDataById(UnitType); List <DataSlot> spells = level.GetPlayerAvatar().GetSpells(); ResourceData trainingResource = _SpellData.GetTrainingResource(); if (_SpellData == null) { return; } DataSlot dataSlot1 = spells.Find((Predicate <DataSlot>)(t => t.Data.GetGlobalID() == _SpellData.GetGlobalID())); if (dataSlot1 != null) { dataSlot1.Value = dataSlot1.Value + Count; } else { DataSlot dataSlot2 = new DataSlot((Data)_SpellData, Count); spells.Add(dataSlot2); } avatar.SetResourceCount(trainingResource, avatar.GetResourceCount(trainingResource) - _SpellData.GetTrainingCost(avatar.GetUnitUpgradeLevel((CombatItemData)_SpellData))); } }
public override void Execute(Level level) { List <DataSlot> _PlayerUnits = level.GetPlayerAvatar().GetUnits(); List <DataSlot> _PlayerSpells = level.GetPlayerAvatar().GetSpells(); foreach (UnitToRemove _Unit in UnitsToRemove) { if (_Unit.Data.ToString().StartsWith("400")) { CombatItemData _Troop = (CombatItemData)CSVManager.DataTables.GetDataById(_Unit.Data);; DataSlot _DataSlot = _PlayerUnits.Find(t => t.Data.GetGlobalID() == _Troop.GetGlobalID()); if (_DataSlot != null) { _DataSlot.Value = _DataSlot.Value - 1; } } else if (_Unit.Data.ToString().StartsWith("260")) { SpellData _Spell = (SpellData)CSVManager.DataTables.GetDataById(_Unit.Data);; DataSlot _DataSlot = _PlayerSpells.Find(t => t.Data.GetGlobalID() == _Spell.GetGlobalID()); if (_DataSlot != null) { _DataSlot.Value = _DataSlot.Value - 1; } } } }