public override void Execute(Level level) { ClientAvatar avatar = level.GetPlayerAvatar(); TrapData dataById = (TrapData)CSVManager.DataTables.GetDataById(TrapId); Trap trap = new Trap((Data)dataById, level); if (!avatar.HasEnoughResources(dataById.GetBuildResource(0), dataById.GetBuildCost(0)) || level.HasFreeWorkers()) { return; } ResourceData buildResource = dataById.GetBuildResource(0); avatar.CommodityCountChangeHelper(0, (Data)buildResource, -dataById.GetBuildCost(0)); trap.StartConstructing(X, Y); level.GameObjectManager.AddGameObject((GameObject)trap); }
public override void Execute(Level level) { ClientAvatar ca = level.GetPlayerAvatar(); TrapData td = (TrapData)ObjectManager.DataTables.GetDataById(TrapId); Trap t = new Trap(td, level); if (ca.HasEnoughResources(td.GetBuildResource(0), td.GetBuildCost(0))) { if (level.HasFreeWorkers()) { ResourceData rd = td.GetBuildResource(0); ca.CommodityCountChangeHelper(0, rd, -td.GetBuildCost(0)); t.StartConstructing(X, Y); level.GameObjectManager.AddGameObject(t); } } }