User prompt
Resmime Tıkla yazısı da önceki gibi kazanç oranı da görünsün.
User prompt
Çalışan 4 resmine birden fazla tıklayınca, Resmime Tıkla yazısı değişiyor. Değişmesin. Sürekli Resmime Tıkla olarak kalsın.
User prompt
Birkaç defa resime tıklayınca yine tıkla diye çıkıyor. Onu değiştirmek istiyorum.
User prompt
"Yeni Sayfa" yazısının tamamını "Çalışanlar" olarak değiştir.
User prompt
"Çalışan 4" İsimli çalışanın altında bulunan "Tıkla" Yazısını "Resmime Tıkla" olarak yeniden yaz.
User prompt
Çalışanların yükselt butonlarını ve ücretinin boyutunu biraz daha büyüt.
User prompt
Çalışanların isminin altında bulunan yazıları alt alta yeniden düzenli hizala.
User prompt
Çalışanların yazılarını resime göre yeniden hizala.
User prompt
Çalışanların alt yazı aralığını düzelt.
User prompt
Çalışanlar panelinde ki yazı boyutlarını, panelin içindeki diğer yazı fontlarına çalışan isimlerinde olan yazı fontunu göre eşitle. Yani içinde ki yazı fontları çalışan isimlerinde ki font ile aynı olsun.
User prompt
Çalışanların yazı fontunu biraz büyüt ve satır aralarına biraz boşluk ekle.
User prompt
Please fix the bug: 'workerGapX is not defined' in or related to this line: 'if (mines && mines.length >= 3) {' Line Number: 2232
User prompt
Çalışanlar 3lü sıra halinde alt alta sıralansın. Panel içinde ki çalışanlar yazısının altında olsunlar.
User prompt
Çalışanları panel içerisinde yeniden ortalı görünecek şekilde yerlerini yeniden sıralandır.
User prompt
Çalışanların boyutunu %70 oranında küçült ve panel içerisine sığacak şekilde yeniden yerleştir.
User prompt
Panel içerisinde ki çalışanların yerlerini düzenli olacak şekilde yeniden boyutlandır. Çalışan ile ilgili bütün yazı boyutunu sıfırla ve okunacak şekilde olsun.
User prompt
Yeni sayfa panelinin büyüklüğünü %80 oranında küçült.
User prompt
Yeni sayfa panelini ekranı tamamen kaplasın ve çalışanların yerlerini yeniden düzenle. Panel içerisine sığacak şekilde olsun.
User prompt
Bütün çalışanların tamamını yeni sayfa panelinde görünecek şekilde taşı.
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'slice')' in or related to this line: 'if (changed) {' Line Number: 391
User prompt
Tüm çalışanları yeni sayfa panelinde göster.
User prompt
Çalışanları panel içerisine taşı.
User prompt
Bütün çalışanların tamamını yeni açılan panel içerisine ekle.
User prompt
Yeni sayfa butonuna basınca bir panel açılsın.
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading '0')' in or related to this line: 'if (changed && Array.isArray(bakiyeDetayTimers) && Array.isArray(bakiyeDetayList) && bakiyeDetayTimers.length > 0 && bakiyeDetayList.length > 0 && bakiyeDetayTimers.length === bakiyeDetayList.length &&' Line Number: 408
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Factory class: base for all part factories var BaseFactory = Container.expand(function () { var self = Container.call(this); self.level = 1; self.production = 1; // per click self.upgradeCost = 100; self.partType = null; // Production time in frames (default 30, halves every 5 levels, min 5) self.getProductionTime = function () { // Each 5 levels halves the time, min 5 frames var base = 30; var speedup = Math.floor((self.level - 1) / 5); var prodTime = Math.floor(base / Math.pow(2, speedup)); if (prodTime < 5) { prodTime = 5; } return prodTime; }; self.attachAsset('factory', { anchorX: 0.5, anchorY: 0.5 }); // Part icon var partIcon = null; if (self.partType) { partIcon = self.attachAsset('part_' + self.partType, { anchorX: 0.5, anchorY: 0.5, y: -60, scaleX: 0.7, scaleY: 0.7 }); } // Level text var levelTxt = new Text2('Lv.' + self.level, { size: 40, fill: '#fff' }); levelTxt.anchor.set(0.5, 0); levelTxt.y = 90; self.addChild(levelTxt); self.upgrade = function () { if (money >= self.upgradeCost) { money -= self.upgradeCost; self.level += 1; self.production += 1; self.upgradeCost = Math.floor(self.upgradeCost * 3.5); levelTxt.setText('Lv.' + self.level); updateMoneyText(); // Reset autoTick so production interval is not skipped after upgrade self.autoTick = 0; // --- Reduce production time by 10% after each upgrade, if customProductionTime is present --- if (typeof self.customProductionTime === "number") { self.customProductionTime = Math.max(Math.floor(self.customProductionTime * 0.9), 60); // min 1s (60 frames) } // Update production time text if present if (self._prodTimeTxt) { var prodTime = self.getProductionTime ? self.getProductionTime() : 30; var prodTimeSec = (prodTime / 60).toFixed(2); self._prodTimeTxt.setText("Üretim: " + prodTimeSec + " sn"); } } }; self.setPartType = function (type) { self.partType = type; if (partIcon) { partIcon.destroy(); } partIcon = self.attachAsset('part_' + type, { anchorX: 0.5, anchorY: 0.5, y: -60, scaleX: 0.7, scaleY: 0.7 }); }; return self; }); // Create a factory class for each part type // Customer class: comes to store and buys a part var Customer = Container.expand(function () { var self = Container.call(this); self.partType = null; self.attachAsset('customer', { anchorX: 0.5, anchorY: 0.5 }); var partIcon = null; self.setPart = function (type) { self.partType = type; if (partIcon) { partIcon.destroy(); } partIcon = self.attachAsset('part_' + type, { anchorX: 0.5, anchorY: 0.5, y: 60, scaleX: 0.5, scaleY: 0.5 }); }; return self; }); // Mine class: produces raw materials over time var Mine = Container.expand(function () { var self = Container.call(this); self.level = 1; self.type = 'copper'; // 'copper', 'silicon', 'iron' self.production = 1; // per tick self.timer = 0; self.upgradeCost = 50; self.attachAsset('mine', { anchorX: 0.5, anchorY: 0.5 }); // Ore icon var oreIcon = self.attachAsset('ore_' + self.type, { anchorX: 0.5, anchorY: 0.5, y: 60, scaleX: 0.7, scaleY: 0.7 }); // Level text var levelTxt = new Text2('Lv.' + self.level, { size: 40, fill: '#fff' }); levelTxt.anchor.set(0.5, 0); levelTxt.y = 90; self.addChild(levelTxt); self.setType = function (type) { self.type = type; oreIcon.destroy(); var newOre = self.attachAsset('ore_' + type, { anchorX: 0.5, anchorY: 0.5, y: 60, scaleX: 0.7, scaleY: 0.7 }); }; self.upgrade = function () { if (money >= self.upgradeCost) { money -= self.upgradeCost; self.level += 1; self.production += 1; self.upgradeCost = Math.floor(self.upgradeCost * 2.975); levelTxt.setText('Lv.' + self.level); updateMoneyText(); } }; self.update = function () { self.timer++; // No automatic production }; return self; }); // Store class: sells computer parts to customers var Store = Container.expand(function () { var self = Container.call(this); self.level = 1; self.sellSpeed = 1; // customers per 2s self.upgradeCost = 120; self.attachAsset('store', { anchorX: 0.5, anchorY: 0.5 }); // Level text var levelTxt = new Text2('Lv.' + self.level, { size: 48, //{1Y} // 40'tan 48'e büyütüldü fill: '#fff' }); levelTxt.anchor.set(0.5, 0); levelTxt.y = 90; self.addChild(levelTxt); self.upgrade = function () { if (money >= self.upgradeCost) { money -= self.upgradeCost; self.level += 1; self.sellSpeed += 1; self.upgradeCost = Math.floor(self.upgradeCost * 3.85); levelTxt.setText('Lv.' + self.level); updateMoneyText(); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x181818 }); /**** * Game Code ****/ // mor // turuncu // yeşil // mavi // kırmızımsı // Her çalışana farklı renkli box tanımla // Create a factory class for each part type // Button // Customer // Factory, Store, Mine icons // Raw materials (3 types) // Computer parts (10 types) function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } var partTypes = ['mouse', 'gpu', 'ram', 'ssd', 'psu', 'mb', 'case', 'fan', 'hdd', 'cooler']; var oreTypes = ['copper', 'silicon', 'iron']; var FactoryClasses = {}; // Üretim süreleri sırası ile 2, 4, 6, ... 20 saniye (2 ve katları, 60fps) olacak şekilde ayarlanır var partProductionTimes = []; for (var i = 0; i < partTypes.length; i++) { partProductionTimes[i] = (i + 1) * 2 * 60; // 2,4,6,...,20 saniye (frame cinsinden) } for (var i = 0; i < partTypes.length; i++) { (function (type, idx) { FactoryClasses[type] = Container.expand(function () { var self = BaseFactory.call(this); self.setPartType(type); // Override getProductionTime to use diversified 1-3-5-7s pattern // Store a custom production time for this factory instance self.customProductionTime = partProductionTimes[idx]; self.getProductionTime = function () { // Use the customProductionTime, which is reduced by 10% on each upgrade var prodTime = self.customProductionTime; // Each 5 levels halves the time, min 1s (60 frames) var speedup = Math.floor((self.level - 1) / 5); prodTime = Math.floor(prodTime / Math.pow(2, speedup)); if (prodTime < 60) { prodTime = 60; } return prodTime; }; return self; }); })(partTypes[i], i); } // Inventory var rawMaterials = { copper: 10, silicon: 10, iron: 10 }; var parts = {}; for (var i = 0; i < partTypes.length; i++) { parts[partTypes[i]] = 0; } // Money var money = 2000; // UI Texts var moneyTxt = new Text2('₺' + money, { size: 50, fill: '#fff' }); moneyTxt.anchor.set(0.5, 0); moneyTxt.y = 10; LK.gui.top.addChild(moneyTxt); // Bakiye kullanım detayını gösteren text var bakiyeDetayTxt = new Text2('', { size: 28, fill: '#ffb' }); bakiyeDetayTxt.anchor.set(0.5, 0); bakiyeDetayTxt.x = moneyTxt.x; bakiyeDetayTxt.y = moneyTxt.y + moneyTxt.height + 2; LK.gui.top.addChild(bakiyeDetayTxt); // Bakiye detaylarını tutan dizi (en fazla 3 çeşit) var bakiyeDetayList = []; // Her detay için kalan süreyi tutan dizi (frame cinsinden) var bakiyeDetayTimers = []; // Bakiye detayına yeni bir satır ekle function addBakiyeDetay(metin) { // Eğer aynı metin varsa, süresini sıfırla for (var i = 0; i < bakiyeDetayList.length; i++) { if (bakiyeDetayList[i] === metin) { bakiyeDetayTimers[i] = 300; // 5 saniye (60fps*5) updateBakiyeDetayTxt(); return; } } // En fazla 3 çeşit tut if (bakiyeDetayList.length >= 3) { bakiyeDetayList.shift(); bakiyeDetayTimers.shift(); } bakiyeDetayList.push(metin); bakiyeDetayTimers.push(300); // 5 saniye (60fps*5) updateBakiyeDetayTxt(); } // Bakiye detayını güncelleyen fonksiyon function updateBakiyeDetayTxt() { if (bakiyeDetayList.length === 0) { bakiyeDetayTxt.setText("Bakiye kullanım detayları yok"); bakiyeDetayTxt.visible = true; } else { bakiyeDetayTxt.setText(bakiyeDetayList.join('\n')); bakiyeDetayTxt.visible = true; } } // Her frame timer azaltılır, 0 olunca detay silinir (her detay max 5 saniye kalır) LK.setInterval(function () { var changed = false; for (var i = bakiyeDetayTimers.length - 1; i >= 0; i--) { bakiyeDetayTimers[i]--; if (bakiyeDetayTimers[i] <= 0) { bakiyeDetayTimers.splice(i, 1); bakiyeDetayList.splice(i, 1); changed = true; } } if (changed) updateBakiyeDetayTxt(); }, 1); // Eski fonksiyonun yerine, ilk başta sadece boş göster updateBakiyeDetayTxt(); // --- Mağaza Button --- var magazaBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 180, height: 70 }); magazaBtn.x = moneyTxt.x - 220; magazaBtn.y = 40; LK.gui.top.addChild(magazaBtn); var magazaBtnTxt = new Text2('Mağaza', { size: 36, fill: '#fff' }); magazaBtnTxt.anchor.set(0.5, 0.5); magazaBtnTxt.x = magazaBtn.x; magazaBtnTxt.y = magazaBtn.y; LK.gui.top.addChild(magazaBtnTxt); // Mağaza butonuna tıklanınca açılır pencereyi göster var magazaPanel = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 700, height: 600, x: 2048 / 2, y: 2732 / 2 }); magazaPanel.visible = false; game.addChild(magazaPanel); var magazaPanelTitle = new Text2('Mağaza', { size: 40, //{3f} // Çalışan isimleriyle aynı font büyüklüğü fill: '#fff' }); magazaPanelTitle.anchor.set(0.5, 0); magazaPanelTitle.x = magazaPanel.x; magazaPanelTitle.y = magazaPanel.y - magazaPanel.height / 2 + 30; magazaPanelTitle.visible = false; game.addChild(magazaPanelTitle); var magazaPanelText = new Text2('Burada mağaza ile ilgili içerik veya açıklama eklenebilir.', { size: 40, //{3j} // Çalışan isimleriyle aynı font büyüklüğü fill: '#fff' }); magazaPanelText.anchor.set(0.5, 0.5); magazaPanelText.x = magazaPanel.x; magazaPanelText.y = magazaPanel.y - 120; magazaPanelText.visible = false; game.addChild(magazaPanelText); // Muhasebe bilgileri başlığı var magazaMuhasebeTitle = new Text2('Muhasebe Bilgileri', { size: 40, //{3n} // Çalışan isimleriyle aynı font büyüklüğü fill: '#ffb' }); magazaMuhasebeTitle.anchor.set(0.5, 0); magazaMuhasebeTitle.x = magazaPanel.x; magazaMuhasebeTitle.y = magazaPanel.y - 30; magazaMuhasebeTitle.visible = false; game.addChild(magazaMuhasebeTitle); // Muhasebe detayları var magazaMuhasebeText = new Text2('', { size: 40, //{3r} // Çalışan isimleriyle aynı font büyüklüğü fill: '#fff' }); magazaMuhasebeText.anchor.set(0.5, 0); magazaMuhasebeText.x = magazaPanel.x; magazaMuhasebeText.y = magazaPanel.y + 20; magazaMuhasebeText.visible = false; game.addChild(magazaMuhasebeText); // Muhasebe bilgilerini güncelleyen fonksiyon function updateMagazaMuhasebeText() { // Toplam satış adedi ve toplam gelir hesapla var toplamSatis = 0; var toplamGelir = 0; for (var i = 0; i < partTypes.length; i++) { // Her part için satılan miktarı ve gelirini hesapla // Satışlar, parts dizisinden değil, toplam üretilen - elde kalan ile bulunabilir // Basit bir örnek: toplam üretilen ve satılanı takip etmiyorsak, sadece mevcut stoğu göster // Gelişmiş: Satışları takip etmek için global değişkenler eklenebilir // Burada örnek olarak sadece mevcut stok ve para gösterelim // Gelişmiş takip için satılan miktarları ayrıca bir dizi ile tutmak gerekir // Şimdilik sadece mevcut stok ve para gösterelim toplamSatis += parts[partTypes[i]]; } // Toplam gelir olarak mevcut parayı gösterelim (örnek) toplamGelir = money; magazaMuhasebeText.setText("Mevcut Stok (adet): " + toplamSatis + "\nKasadaki Para: ₺" + toplamGelir + (typeof borc !== "undefined" && borc > 0 ? "\nBorç: ₺" + borc : "")); } // Paneli aç/kapat fonksiyonları magazaBtn.down = function (x, y, obj) { if (isSoundOn && LK.getSound) { var clickSound = LK.getSound('ClickSesi'); if (clickSound) clickSound.play(); } magazaPanel.visible = true; magazaPanelTitle.visible = true; magazaPanelText.visible = true; magazaKapatBtn.visible = true; magazaKapatBtnTxt.visible = true; magazaMuhasebeTitle.visible = true; magazaMuhasebeText.visible = true; updateMagazaMuhasebeText(); // Paneli en öne getir if (game.setChildIndex) { game.setChildIndex(magazaPanel, game.children.length - 1); game.setChildIndex(magazaPanelTitle, game.children.length - 1); game.setChildIndex(magazaPanelText, game.children.length - 1); game.setChildIndex(magazaKapatBtn, game.children.length - 1); game.setChildIndex(magazaKapatBtnTxt, game.children.length - 1); game.setChildIndex(magazaMuhasebeTitle, game.children.length - 1); game.setChildIndex(magazaMuhasebeText, game.children.length - 1); } }; // Paneli kapatmak için bir kapat butonu ekle var magazaKapatBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 120, height: 60, x: magazaPanel.x + 320, y: magazaPanel.y + 20 }); magazaKapatBtn.visible = false; game.addChild(magazaKapatBtn); var magazaKapatBtnTxt = new Text2('Kapat', { size: 32, fill: '#fff' }); magazaKapatBtnTxt.anchor.set(0.5, 0.5); magazaKapatBtnTxt.x = magazaKapatBtn.x; magazaKapatBtnTxt.y = magazaKapatBtn.y; magazaKapatBtnTxt.visible = false; game.addChild(magazaKapatBtnTxt); magazaKapatBtn.down = function (x, y, obj) { if (isSoundOn && LK.getSound) { var clickSound = LK.getSound('ClickSesi'); if (clickSound) clickSound.play(); } magazaPanel.visible = false; magazaPanelTitle.visible = false; magazaPanelText.visible = false; magazaKapatBtn.visible = false; magazaKapatBtnTxt.visible = false; magazaMuhasebeTitle.visible = false; magazaMuhasebeText.visible = false; }; // --- Yatırım Button ve Açılır Pencere --- // Yatırım butonunu mağaza butonunun soluna ekle var yatirimBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 180, height: 70 }); yatirimBtn.x = magazaBtn.x - 220; yatirimBtn.y = magazaBtn.y; LK.gui.top.addChild(yatirimBtn); var yatirimBtnTxt = new Text2('Yatırım', { size: 36, fill: '#fff' }); yatirimBtnTxt.anchor.set(0.5, 0.5); yatirimBtnTxt.x = yatirimBtn.x; yatirimBtnTxt.y = yatirimBtn.y; LK.gui.top.addChild(yatirimBtnTxt); // Açılır pencereyi oluştur (başta görünmez) - EKRANIN EN ÜSTÜNDE var yatirimPanel = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, // anchorY: 0.5 ile tam ortada başlat width: 950, // Paneli sağa doğru uzat (800 -> 950) // Sat butonuna hizalı olacak şekilde genişletildi height: 1050, // 12 coin için paneli aşağıya uzat x: 2048 / 2, // ekranın tam ortası y: 2732 / 2 // ekranın tam ortası }); yatirimPanel.visible = false; // Yatırım panelini ve başlığını en önde göstermek için game üstünde en sona ekle game.addChild(yatirimPanel); game.setChildIndex(yatirimPanel, game.children.length - 1); var yatirimTitle = new Text2('Yatırım - Popüler Coinler', { size: 44, fill: '#fff' }); yatirimTitle.anchor.set(0.5, 0); yatirimTitle.x = yatirimPanel.x; yatirimTitle.y = yatirimPanel.y - yatirimPanel.height / 2 + 20; // panelin üstüne hizala yatirimTitle.visible = false; game.addChild(yatirimTitle); game.setChildIndex(yatirimTitle, game.children.length - 1); // 12 popüler coin listesi var coinList = [{ name: "Bitcoin", symbol: "BTC" }, { name: "Ethereum", symbol: "ETH" }, { name: "Tether", symbol: "USDT" }, { name: "BNB", symbol: "BNB" }, { name: "Solana", symbol: "SOL" }, { name: "XRP", symbol: "XRP" }, { name: "Dogecoin", symbol: "DOGE" }, { name: "Cardano", symbol: "ADA" }, { name: "Toncoin", symbol: "TON" }, { name: "Shiba Inu", symbol: "SHIB" }, { name: "Avalanche", symbol: "AVAX" }, { name: "Polkadot", symbol: "DOT" }]; // Coin fiyatları ve kullanıcı bakiyesi var coinPrices = []; var coinHoldings = []; for (var i = 0; i < coinList.length; i++) { // Başlangıç fiyatları: BTC 1.000.000, ETH 50.000, diğerleri 10.000-1.000 arası var base = 1000000; if (i === 1) base = 50000;else if (i > 1) base = 10000 - i * 900; coinPrices[i] = base; coinHoldings[i] = 0; } // Coin ortalama maliyetlerini ve toplam harcanan tutarı tutan diziler var coinTotalCost = []; var coinAvgCost = []; for (var i = 0; i < coinList.length; i++) { coinTotalCost[i] = 0; coinAvgCost[i] = 0; } // Coin fiyatlarını gösterecek ve al/sat butonları var coinTxts = []; var coinPriceTxts = []; var coinHoldingTxts = []; var coinBuyBtns = []; var coinSellBtns = []; var coinBuyBtnTxts = []; var coinSellBtnTxts = []; var coinBuyInputTxts = []; var coinSellInputTxts = []; var coinBuyAmounts = []; var coinSellAmounts = []; for (var i = 0; i < coinList.length; i++) { // Coin adı (sadece parantez içindekiler, yani symbol) var coinTxt = new Text2(i + 1 + ". " + coinList[i].symbol, { size: 32, fill: '#bff' }); coinTxt.anchor.set(0, 0); // Panelin soluna daha yakın hizala (daha sola çek) coinTxt.x = yatirimPanel.x - yatirimPanel.width / 2 + 30; coinTxt.y = yatirimPanel.y + 80 + i * 75; coinTxt.visible = false; game.addChild(coinTxt); coinTxts.push(coinTxt); // Fiyat var coinPriceTxt = new Text2("₺" + coinPrices[i], { size: 28, fill: '#fff' }); coinPriceTxt.anchor.set(0, 0); // Panelin soluna daha yakın hizala coinPriceTxt.x = yatirimPanel.x - yatirimPanel.width / 2 + 210; coinPriceTxt.y = coinTxt.y; coinPriceTxt.visible = false; game.addChild(coinPriceTxt); coinPriceTxts.push(coinPriceTxt); // Kullanıcı bakiyesi var coinHoldingTxt = new Text2("Adet: 0", { size: 24, fill: '#ffb' }); coinHoldingTxt.anchor.set(0, 0); // Panelin soluna daha yakın hizala coinHoldingTxt.x = yatirimPanel.x - yatirimPanel.width / 2 + 370; coinHoldingTxt.y = coinTxt.y; coinHoldingTxt.visible = false; game.addChild(coinHoldingTxt); coinHoldingTxts.push(coinHoldingTxt); // Al butonu var buyBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 100, height: 60, // Panelin SAĞ kenarına hizala (yeni genişlik: 950) x: yatirimPanel.x + yatirimPanel.width / 2 - 150, y: coinTxt.y + 18 }); buyBtn.visible = false; game.addChild(buyBtn); coinBuyBtns.push(buyBtn); var buyBtnTxt = new Text2('Al', { size: 30, fill: '#fff' }); buyBtnTxt.anchor.set(0.5, 0.5); buyBtnTxt.x = buyBtn.x; buyBtnTxt.y = buyBtn.y; buyBtnTxt.visible = false; game.addChild(buyBtnTxt); coinBuyBtnTxts.push(buyBtnTxt); // Sat butonu var sellBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 100, height: 60, // Panelin SAĞ kenarına hizala, buyBtn'in sağında 130px boşluk bırak (yeni genişlik: 950) x: yatirimPanel.x + yatirimPanel.width / 2 - 50, y: coinTxt.y + 18 }); sellBtn.visible = false; game.addChild(sellBtn); coinSellBtns.push(sellBtn); var sellBtnTxt = new Text2('Sat', { size: 30, fill: '#fff' }); sellBtnTxt.anchor.set(0.5, 0.5); sellBtnTxt.x = sellBtn.x; sellBtnTxt.y = sellBtn.y; sellBtnTxt.visible = false; game.addChild(sellBtnTxt); coinSellBtnTxts.push(sellBtnTxt); // Alım miktarı (sabit 1, artırmak için input yok, mobilde kolaylık için) // Aradaki süre/label kaldırıldı coinBuyAmounts[i] = 1; coinSellAmounts[i] = 1; } // Paneli kapatmak için bir kapat butonu ekle var yatirimKapatBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 120, height: 60, // Panelin sağ kenarına hizala x: yatirimPanel.x + yatirimPanel.width / 2 - 70, y: yatirimPanel.y - yatirimPanel.height / 2 + 20 }); yatirimKapatBtn.visible = false; game.addChild(yatirimKapatBtn); var yatirimKapatBtnTxt = new Text2('Kapat', { size: 32, fill: '#fff' }); yatirimKapatBtnTxt.anchor.set(0.5, 0.5); yatirimKapatBtnTxt.x = yatirimKapatBtn.x; yatirimKapatBtnTxt.y = yatirimKapatBtn.y; yatirimKapatBtnTxt.visible = false; game.addChild(yatirimKapatBtnTxt); // Yatırım paneli açıldığında tüm ekranı kaplayan overlay'i oluştur (başta görünmez) if (typeof yatirimOverlay === "undefined") { var yatirimOverlay = LK.getAsset('button', { anchorX: 0, anchorY: 0, width: 2048, height: 2732, // Tüm ekranı kapla x: 0, y: 0 // Ekranın en üstünden başla }); yatirimOverlay.visible = false; yatirimOverlay.alpha = 0.65; // Yarı saydam game.addChild(yatirimOverlay); } // Panel açma yatirimBtn.down = function (x, y, obj) { if (isSoundOn && LK.getSound) { var clickSound = LK.getSound('ClickSesi'); if (clickSound) clickSound.play(); } yatirimPanel.visible = true; yatirimTitle.visible = true; yatirimKapatBtn.visible = true; yatirimKapatBtnTxt.visible = true; yatirimOverlay.visible = true; // Overlay'i göster // Panelin merkezine göre coin paneli elemanlarını hizala for (var i = 0; i < coinTxts.length; i++) { // Panelin soluna hizala coinTxts[i].x = yatirimPanel.x - yatirimPanel.width / 2 + 30; coinTxts[i].y = yatirimPanel.y - yatirimPanel.height / 2 + 80 + i * 75; coinPriceTxts[i].x = yatirimPanel.x - yatirimPanel.width / 2 + 210; coinPriceTxts[i].y = coinTxts[i].y; coinHoldingTxts[i].x = yatirimPanel.x - yatirimPanel.width / 2 + 370; coinHoldingTxts[i].y = coinTxts[i].y; // Al ve Sat butonlarını panelin sağ kenarına hizala (yeni genişlik: 950) coinBuyBtns[i].x = yatirimPanel.x + yatirimPanel.width / 2 - 180; coinBuyBtns[i].y = coinTxts[i].y + 18; coinSellBtns[i].x = yatirimPanel.x + yatirimPanel.width / 2 - 50; coinSellBtns[i].y = coinTxts[i].y + 18; coinBuyBtnTxts[i].x = coinBuyBtns[i].x; coinBuyBtnTxts[i].y = coinBuyBtns[i].y; coinSellBtnTxts[i].x = coinSellBtns[i].x; coinSellBtnTxts[i].y = coinSellBtns[i].y; coinTxts[i].visible = true; coinPriceTxts[i].visible = true; coinHoldingTxts[i].visible = true; coinBuyBtns[i].visible = true; coinSellBtns[i].visible = true; coinBuyBtnTxts[i].visible = true; coinSellBtnTxts[i].visible = true; } // Kapat butonunu ve başlığı panelin sağ kenarına hizala yatirimKapatBtn.x = yatirimPanel.x + yatirimPanel.width / 2 - 70; yatirimKapatBtn.y = yatirimPanel.y - yatirimPanel.height / 2 + 20; yatirimKapatBtnTxt.x = yatirimKapatBtn.x; yatirimKapatBtnTxt.y = yatirimKapatBtn.y; yatirimTitle.x = yatirimPanel.x; yatirimTitle.y = yatirimPanel.y - yatirimPanel.height / 2 + 20; updateCoinPanel(); // Panel ve içeriğini en öne getir if (game.setChildIndex) { // Önce overlay'i panelden hemen arkaya al // Paneli ve içeriğini en öne al game.setChildIndex(yatirimOverlay, game.children.length - 1); // overlay'i en öne al game.setChildIndex(yatirimPanel, game.children.length - 1); // paneli overlay'in önüne al game.setChildIndex(yatirimTitle, game.children.length - 1); game.setChildIndex(yatirimKapatBtn, game.children.length - 1); game.setChildIndex(yatirimKapatBtnTxt, game.children.length - 1); for (var i = 0; i < coinTxts.length; i++) { game.setChildIndex(coinTxts[i], game.children.length - 1); game.setChildIndex(coinPriceTxts[i], game.children.length - 1); game.setChildIndex(coinHoldingTxts[i], game.children.length - 1); game.setChildIndex(coinBuyBtns[i], game.children.length - 1); game.setChildIndex(coinSellBtns[i], game.children.length - 1); game.setChildIndex(coinBuyBtnTxts[i], game.children.length - 1); game.setChildIndex(coinSellBtnTxts[i], game.children.length - 1); } // Overlay panelden hemen arkada kalacak şekilde tekrar index ayarla var panelIdx = game.children.indexOf(yatirimPanel); if (panelIdx > 0) { game.setChildIndex(yatirimOverlay, panelIdx - 1); } } }; // Panel kapama yatirimKapatBtn.down = function (x, y, obj) { yatirimPanel.visible = false; yatirimTitle.visible = false; yatirimKapatBtn.visible = false; yatirimKapatBtnTxt.visible = false; if (typeof yatirimOverlay !== "undefined") yatirimOverlay.visible = false; for (var i = 0; i < coinTxts.length; i++) { coinTxts[i].visible = false; coinPriceTxts[i].visible = false; coinHoldingTxts[i].visible = false; coinBuyBtns[i].visible = false; coinSellBtns[i].visible = false; coinBuyBtnTxts[i].visible = false; coinSellBtnTxts[i].visible = false; } }; // Coin panelini güncelle function updateCoinPanel() { for (var i = 0; i < coinList.length; i++) { coinPriceTxts[i].setText("₺" + coinPrices[i]); // Ortalama maliyet gösterimi if (coinHoldings[i] > 0) { coinHoldingTxts[i].setText("Adet: " + coinHoldings[i] + "\nMaliyet: ₺" + Math.round(coinAvgCost[i])); } else { coinHoldingTxts[i].setText("Adet: 0"); } } } // Bakiye detayları için global değişkenler var toplamCoinAlim = 0; var toplamCoinSatisGeliri = 0; var toplamBorcOdeme = 0; var toplamYatirimHarcamasi = 0; var toplamFabrikaYukseltme = 0; var toplamMadenYukseltme = 0; var toplamStoreYukseltme = 0; var toplamInternetTeklifHarcamasi = 0; var toplamTopluSatisGeliri = 0; var toplamMusteriSatisGeliri = 0; // Coin alım-satım butonları for (var i = 0; i < coinList.length; i++) { // Al coinBuyBtns[i].down = function (idx) { return function (x, y, obj) { var adet = coinBuyAmounts[idx]; var tutar = coinPrices[idx] * adet; if (money >= tutar) { money -= tutar; toplamCoinAlim += tutar; // Ortalama maliyet ve toplam maliyet güncelle coinTotalCost[idx] += tutar; coinHoldings[idx] += adet; coinAvgCost[idx] = coinHoldings[idx] > 0 ? coinTotalCost[idx] / coinHoldings[idx] : 0; updateMoneyText(); updateCoinPanel(); // Buton animasyonu if (isSoundOn && LK.getSound) { var clickSound = LK.getSound('ClickSesi'); if (clickSound) clickSound.play(); } tween(coinBuyBtns[idx], { scaleX: 1.15, scaleY: 1.15 }, { duration: 80, onFinish: function onFinish() { tween(coinBuyBtns[idx], { scaleX: 1, scaleY: 1 }, { duration: 80 }); } }); } else { // Yetersiz bakiye animasyonu if (isSoundOn && LK.getSound) { var clickSound = LK.getSound('ClickSesi'); if (clickSound) clickSound.play(); } tween(coinBuyBtns[idx], { tint: 0xff2222 }, { duration: 120, onFinish: function onFinish() { tween(coinBuyBtns[idx], { tint: 0x222222 }, { duration: 120 }); } }); } }; }(i); // Sat coinSellBtns[i].down = function (idx) { return function (x, y, obj) { var adet = coinSellAmounts[idx]; // Zararına satış aktif: coinHoldings >= adet ise, maliyet bakılmaksızın satış yapılır if (coinHoldings[idx] >= adet) { var tutar = coinPrices[idx] * adet; toplamCoinSatisGeliri += tutar; // Satışta ortalama maliyeti azalt (FIFO: en basit haliyle, toplam maliyetten orantılı azalt) if (coinHoldings[idx] > 0) { var costPer = coinAvgCost[idx]; coinTotalCost[idx] -= costPer * adet; if (coinTotalCost[idx] < 0) coinTotalCost[idx] = 0; } coinHoldings[idx] -= adet; if (coinHoldings[idx] > 0) { coinAvgCost[idx] = coinTotalCost[idx] / coinHoldings[idx]; } else { coinAvgCost[idx] = 0; coinTotalCost[idx] = 0; } money += tutar; updateMoneyText(); updateCoinPanel(); // Buton animasyonu if (isSoundOn && LK.getSound) { var clickSound = LK.getSound('ClickSesi'); if (clickSound) clickSound.play(); } tween(coinSellBtns[idx], { scaleX: 1.15, scaleY: 1.15 }, { duration: 80, onFinish: function onFinish() { tween(coinSellBtns[idx], { scaleX: 1, scaleY: 1 }, { duration: 80 }); } }); // Satış işlemi anında gerçekleşir, bekleme süresi yok. } else { // Yetersiz coin animasyonu if (isSoundOn && LK.getSound) { var clickSound = LK.getSound('ClickSesi'); if (clickSound) clickSound.play(); } tween(coinSellBtns[idx], { tint: 0xff2222 }, { duration: 120, onFinish: function onFinish() { tween(coinSellBtns[idx], { tint: 0x222222 }, { duration: 120 }); } }); } }; }(i); } // Coin fiyatları başlangıç fiyatından maksimum %10 yükselip düşebilir, rastgele değişim uygula (her 2 saniyede bir) var coinBasePrices = []; for (var i = 0; i < coinList.length; i++) { // Başlangıç fiyatlarını coinPrices oluşturulurkenki ile aynı şekilde ata var base = 1000000; if (i === 1) base = 50000;else if (i > 1) base = 10000 - i * 900; coinBasePrices[i] = base; } // Her 40 saniyede bir coin fiyatlarını güncelle (2 saniyeden 40 saniyeye çıkarıldı, %95 yavaşlatıldı) LK.setInterval(function () { for (var i = 0; i < coinPrices.length; i++) { // Rastgele -%2.5 ile +%2.5 arası değişim uygula var degisim = 1 + (Math.random() * 0.05 - 0.025); var yeniFiyat = coinPrices[i] * degisim; // Sınırları uygula: min %10 düşüş, max %10 artış var minFiyat = Math.floor(coinBasePrices[i] * 0.9); var maxFiyat = Math.ceil(coinBasePrices[i] * 1.1); if (yeniFiyat < minFiyat) yeniFiyat = minFiyat; if (yeniFiyat > maxFiyat) yeniFiyat = maxFiyat; coinPrices[i] = Math.floor(yeniFiyat); } updateCoinPanel(); }, 2400); // 40 saniye (60fps * 40) function updateMoneyText() { moneyTxt.setText('₺' + money); updateBorcText && updateBorcText(); if (magazaMuhasebeText && magazaMuhasebeText.visible) updateMagazaMuhasebeText(); // Bakiye detaylarını güncelle // Her bir toplamX değişkeni için, eğer >0 ise addBakiyeDetay ile ekle if (typeof toplamCoinAlim !== "undefined" && toplamCoinAlim > 0) { addBakiyeDetay("Coin Alım: -₺" + toplamCoinAlim); } if (typeof toplamCoinSatisGeliri !== "undefined" && toplamCoinSatisGeliri > 0) { addBakiyeDetay("Coin Satış: +₺" + toplamCoinSatisGeliri); } if (typeof toplamBorcOdeme !== "undefined" && toplamBorcOdeme > 0) { addBakiyeDetay("Borç Ödeme: -₺" + toplamBorcOdeme); } if (typeof toplamYatirimHarcamasi !== "undefined" && toplamYatirimHarcamasi > 0) { addBakiyeDetay("Yatırım Harcama: -₺" + toplamYatirimHarcamasi); } if (typeof toplamFabrikaYukseltme !== "undefined" && toplamFabrikaYukseltme > 0) { addBakiyeDetay("Fabrika Yükseltme: -₺" + toplamFabrikaYukseltme); } if (typeof toplamMadenYukseltme !== "undefined" && toplamMadenYukseltme > 0) { addBakiyeDetay("Maden Yükseltme: -₺" + toplamMadenYukseltme); } if (typeof toplamStoreYukseltme !== "undefined" && toplamStoreYukseltme > 0) { addBakiyeDetay("Mağaza Yükseltme: -₺" + toplamStoreYukseltme); } if (typeof toplamInternetTeklifHarcamasi !== "undefined" && toplamInternetTeklifHarcamasi > 0) { addBakiyeDetay("İnternet Teklifi: -₺" + toplamInternetTeklifHarcamasi); } if (typeof toplamTopluSatisGeliri !== "undefined" && toplamTopluSatisGeliri > 0) { addBakiyeDetay("Toplu Satış: +₺" + toplamTopluSatisGeliri); } // Müşteri Satış bilgisi bakiye detayında gösterilmeyecek } // --- Banka Button & Borç Logic --- var bankBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 180, height: 70 }); bankBtn.x = moneyTxt.x + 220; bankBtn.y = 40; LK.gui.top.addChild(bankBtn); // --- Sound Toggle Icon Button --- // Use a simple colored box as icon: green for sound on, red for sound off var soundOnColor = 0x83de44; var soundOffColor = 0xd83318; var soundBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 70, height: 70 }); soundBtn.x = bankBtn.x + bankBtn.width / 2 + soundBtn.width / 2 + 20; soundBtn.y = bankBtn.y; LK.gui.top.addChild(soundBtn); // Sound icon state var isSoundOn = true; soundBtn.tint = soundOnColor; // Optional: Add a speaker icon text var soundBtnTxt = new Text2("\uD83D\uDD0A", { // Unicode speaker size: 38, fill: '#fff' }); soundBtnTxt.anchor.set(0.5, 0.5); soundBtnTxt.x = soundBtn.x; soundBtnTxt.y = soundBtn.y; LK.gui.top.addChild(soundBtnTxt); // Sound toggle logic soundBtn.down = function (x, y, obj) { isSoundOn = !isSoundOn; if (isSoundOn) { soundBtn.tint = soundOnColor; soundBtnTxt.setText("\uD83D\uDD0A"); // Speaker // Resume music LK.playMusic('ArkaplanMuzik', { fade: { start: 0, end: 1, duration: 300 } }); } else { soundBtn.tint = soundOffColor; soundBtnTxt.setText("\uD83D\uDD07"); // Muted speaker // Stop music LK.stopMusic(); } // Animate for feedback tween(soundBtn, { scaleX: 1.15, scaleY: 1.15 }, { duration: 80, onFinish: function onFinish() { tween(soundBtn, { scaleX: 1, scaleY: 1 }, { duration: 80 }); } }); }; var bankBtnTxt = new Text2('Banka', { size: 36, fill: '#fff' }); bankBtnTxt.anchor.set(0.5, 0.5); bankBtnTxt.x = bankBtn.x; bankBtnTxt.y = bankBtn.y; LK.gui.top.addChild(bankBtnTxt); var borc = 0; var borcTxt = new Text2('', { size: 32, fill: '#ffb' }); borcTxt.anchor.set(0.5, 0); borcTxt.x = moneyTxt.x + 420; borcTxt.y = 10; LK.gui.top.addChild(borcTxt); // Borç Öde button var borcOdeBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 140, height: 54 }); borcOdeBtn.x = borcTxt.x + 180; borcOdeBtn.y = borcTxt.y + 28; LK.gui.top.addChild(borcOdeBtn); var borcOdeBtnTxt = new Text2('Borç Öde', { size: 28, fill: '#fff' }); borcOdeBtnTxt.anchor.set(0.5, 0.5); borcOdeBtnTxt.x = borcOdeBtn.x; borcOdeBtnTxt.y = borcOdeBtn.y; LK.gui.top.addChild(borcOdeBtnTxt); // --- New Page Button below Banka button --- var newPageBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 140, height: 54 }); newPageBtn.x = bankBtn.x; newPageBtn.y = bankBtn.y + bankBtn.height / 2 + newPageBtn.height / 2 + 20; LK.gui.top.addChild(newPageBtn); var newPageBtnTxt = new Text2('Çalışanlar', { size: 28, fill: '#fff' }); newPageBtnTxt.anchor.set(0.5, 0.5); newPageBtnTxt.x = newPageBtn.x; newPageBtnTxt.y = newPageBtn.y; LK.gui.top.addChild(newPageBtnTxt); // --- New Page Panel (initially hidden) --- // %80 oranında küçültülmüş yeni sayfa paneli var newPagePanelWidth = Math.floor(2048 * 0.8); var newPagePanelHeight = Math.floor(2732 * 0.8); var newPagePanelX = Math.floor((2048 - newPagePanelWidth) / 2); var newPagePanelY = Math.floor((2732 - newPagePanelHeight) / 2); var newPagePanel = LK.getAsset('button', { anchorX: 0, anchorY: 0, width: newPagePanelWidth, height: newPagePanelHeight, x: newPagePanelX, y: newPagePanelY }); newPagePanel.visible = false; game.addChild(newPagePanel); // Title at top center var newPagePanelTitle = new Text2('Çalışanlar', { size: 64, fill: '#fff' }); newPagePanelTitle.anchor.set(0.5, 0); newPagePanelTitle.x = 2048 / 2; newPagePanelTitle.y = newPagePanelY + 40; newPagePanelTitle.visible = false; game.addChild(newPagePanelTitle); // Remove old panel text, add a subtle subtitle at top center under title var newPagePanelText = new Text2('Çalışanlar', { size: 40, fill: '#bff' }); newPagePanelText.anchor.set(0.5, 0); newPagePanelText.x = 2048 / 2; newPagePanelText.y = newPagePanelTitle.y + newPagePanelTitle.height + 10; newPagePanelText.visible = false; game.addChild(newPagePanelText); // Kapat butonu var newPageKapatBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 120, height: 60, x: newPagePanel.x + newPagePanelWidth - 80, y: newPagePanel.y + 20 }); newPageKapatBtn.visible = false; game.addChild(newPageKapatBtn); var newPageKapatBtnTxt = new Text2('Kapat', { size: 32, fill: '#fff' }); newPageKapatBtnTxt.anchor.set(0.5, 0.5); newPageKapatBtnTxt.x = newPageKapatBtn.x; newPageKapatBtnTxt.y = newPageKapatBtn.y; newPageKapatBtnTxt.visible = false; game.addChild(newPageKapatBtnTxt); // Yeni sayfa butonuna tıklanınca paneli aç newPageBtn.down = function (x, y, obj) { newPagePanel.visible = true; newPagePanelTitle.visible = true; newPagePanelText.visible = true; newPageKapatBtn.visible = true; newPageKapatBtnTxt.visible = true; // Paneli en öne getir if (game.setChildIndex) { game.setChildIndex(newPagePanel, game.children.length - 1); game.setChildIndex(newPagePanelTitle, game.children.length - 1); game.setChildIndex(newPagePanelText, game.children.length - 1); game.setChildIndex(newPageKapatBtn, game.children.length - 1); game.setChildIndex(newPageKapatBtnTxt, game.children.length - 1); } }; // Paneli kapatmak için kapat butonu newPageKapatBtn.down = function (x, y, obj) { newPagePanel.visible = false; newPagePanelTitle.visible = false; newPagePanelText.visible = false; newPageKapatBtn.visible = false; newPageKapatBtnTxt.visible = false; }; // Languages butonunu borç öde butonunun altına ekle var languagesBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 140, height: 54 }); languagesBtn.x = borcOdeBtn.x; languagesBtn.y = borcOdeBtn.y + 70; LK.gui.top.addChild(languagesBtn); var languagesBtnTxt = new Text2('Languages', { size: 28, fill: '#fff' }); languagesBtnTxt.anchor.set(0.5, 0.5); languagesBtnTxt.x = languagesBtn.x; languagesBtnTxt.y = languagesBtn.y; LK.gui.top.addChild(languagesBtnTxt); // INFO butonunu Yatırım butonunun altına ekle var infoBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 140, height: 54 }); infoBtn.x = yatirimBtn.x; infoBtn.y = yatirimBtn.y + 70; LK.gui.top.addChild(infoBtn); var infoBtnTxt = new Text2('INFO', { size: 28, fill: '#fff' }); infoBtnTxt.anchor.set(0.5, 0.5); infoBtnTxt.x = infoBtn.x; infoBtnTxt.y = infoBtn.y; LK.gui.top.addChild(infoBtnTxt); // "Nasıl Oynanır" butonunu INFO butonunun SAĞINA ekle var howToBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 220, height: 54 }); // INFO butonunun sağında 90px boşluk bırak howToBtn.x = infoBtn.x + infoBtn.width / 2 + howToBtn.width / 2 + 20; howToBtn.y = infoBtn.y; LK.gui.top.addChild(howToBtn); var howToBtnTxt = new Text2('Nasıl Oynanır', { size: 28, fill: '#fff' }); howToBtnTxt.anchor.set(0.5, 0.5); howToBtnTxt.x = howToBtn.x; howToBtnTxt.y = howToBtn.y; LK.gui.top.addChild(howToBtnTxt); // "Nasıl Oynanır" butonuna tıklanınca info panelini aç howToBtn.down = function (x, y, obj) { // Butona animasyon ekle tween(howToBtn, { scaleX: 1.12, scaleY: 1.12 }, { duration: 80, onFinish: function onFinish() { tween(howToBtn, { scaleX: 1, scaleY: 1 }, { duration: 80 }); } }); infoPanel.visible = true; infoPanelTitle.visible = true; infoPanelText.visible = true; infoKapatBtn.visible = true; infoKapatBtnTxt.visible = true; // Paneli en öne getir if (game.setChildIndex) { game.setChildIndex(infoPanel, game.children.length - 1); game.setChildIndex(infoPanelTitle, game.children.length - 1); game.setChildIndex(infoPanelText, game.children.length - 1); game.setChildIndex(infoKapatBtn, game.children.length - 1); game.setChildIndex(infoKapatBtnTxt, game.children.length - 1); } }; // INFO panel (açılır pencere) ekle // Create the infoPanelText first to measure its width var infoPanelText = new Text2('Bu oyunda amacınız fabrikalar kurarak bilgisayar parçaları üretmek ve mağazada satarak para kazanmaktır.\n\n' + '- Madenlerden ham madde üretin.\n' + '- Fabrikalarda bilgisayar parçaları üretin.\n' + '- Mağazada ve internetten satış yapın.\n' + '- Yatırım ve banka özelliklerini kullanın.\n\n' + 'İyi oyunlar!', { size: 30, fill: '#fff' }); infoPanelText.anchor.set(0.5, 0.5); // Calculate width based on text width, add padding var infoPanelTextWidth = infoPanelText.width; var infoPanelTextHeight = infoPanelText.height; var infoPanelWidth = Math.max(700, infoPanelTextWidth + 120); // min 700, 60px padding each side var infoPanelHeight = Math.max(500, infoPanelTextHeight + 120); // min 500, 60px padding top/bottom // Sol üstteki ayar/menu butonunun altına hizala // Sol üstte platform menüsü 100x100 px alanı kaplar, bu alanın hemen altına hizala var infoPanelX = 60 + infoPanelWidth / 2; // 60px padding from left var infoPanelY = 100 + 40 + infoPanelHeight / 2; // 100px platform menu + 40px padding var infoPanel = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: infoPanelWidth, height: infoPanelHeight, x: infoPanelX, y: infoPanelY }); infoPanel.visible = false; game.addChild(infoPanel); var infoPanelTitle = new Text2('INFO', { size: 40, fill: '#fff' }); infoPanelTitle.anchor.set(0.5, 0); // Panelin üst kenarına hizala infoPanelTitle.x = infoPanel.x; infoPanelTitle.y = infoPanel.y - infoPanel.height / 2 + 30; infoPanelTitle.visible = false; game.addChild(infoPanelTitle); // Reposition infoPanelText to center in the new panel infoPanelText.x = infoPanel.x; infoPanelText.y = infoPanel.y + 10; infoPanelText.visible = false; game.addChild(infoPanelText); // INFO panel kapat butonu var infoKapatBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 120, height: 60, // Panelin sağ üst köşesine hizala x: infoPanel.x + infoPanel.width / 2 - 70, y: infoPanel.y - infoPanel.height / 2 + 40 }); infoKapatBtn.visible = false; game.addChild(infoKapatBtn); var infoKapatBtnTxt = new Text2('Kapat', { size: 44, //{8T} // BÜYÜTÜLDÜ fill: '#fff' }); infoKapatBtnTxt.anchor.set(0.5, 0.5); infoKapatBtnTxt.x = infoKapatBtn.x; infoKapatBtnTxt.y = infoKapatBtn.y; infoKapatBtnTxt.visible = false; game.addChild(infoKapatBtnTxt); // INFO butonuna tıklanınca paneli aç infoBtn.down = function (x, y, obj) { tween(infoBtn, { scaleX: 1.12, scaleY: 1.12 }, { duration: 80, onFinish: function onFinish() { tween(infoBtn, { scaleX: 1, scaleY: 1 }, { duration: 80 }); } }); infoPanel.visible = true; infoPanelTitle.visible = true; infoPanelText.visible = true; infoKapatBtn.visible = true; infoKapatBtnTxt.visible = true; // Paneli en öne getir if (game.setChildIndex) { game.setChildIndex(infoPanel, game.children.length - 1); game.setChildIndex(infoPanelTitle, game.children.length - 1); game.setChildIndex(infoPanelText, game.children.length - 1); game.setChildIndex(infoKapatBtn, game.children.length - 1); game.setChildIndex(infoKapatBtnTxt, game.children.length - 1); } }; // INFO panel kapat butonu infoKapatBtn.down = function (x, y, obj) { infoPanel.visible = false; infoPanelTitle.visible = false; infoPanelText.visible = false; infoKapatBtn.visible = false; infoKapatBtnTxt.visible = false; }; // Languages panel (açılır pencere) ekle var languagesPanel = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 520, height: 420, x: 2048 / 2, y: 2732 / 2 }); languagesPanel.visible = false; game.addChild(languagesPanel); var languagesPanelTitle = new Text2('Languages', { size: 40, fill: '#fff' }); languagesPanelTitle.anchor.set(0.5, 0); languagesPanelTitle.x = languagesPanel.x; languagesPanelTitle.y = languagesPanel.y - languagesPanel.height / 2 + 30; languagesPanelTitle.visible = false; game.addChild(languagesPanelTitle); var languagesPanelText = new Text2('Select your language:', { size: 32, fill: '#fff' }); languagesPanelText.anchor.set(0.5, 0.5); languagesPanelText.x = languagesPanel.x; languagesPanelText.y = languagesPanel.y - 60; languagesPanelText.visible = false; game.addChild(languagesPanelText); // Language options var languageOptions = [{ code: "tr", label: "Türkçe" }, { code: "en", label: "English" }, { code: "de", label: "Deutsch" }, { code: "fr", label: "Français" }, { code: "es", label: "Español" }]; var languageBtns = []; var languageBtnTxts = []; var selectedLanguage = "tr"; // default for (var i = 0; i < languageOptions.length; i++) { var btn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 220, height: 60, x: languagesPanel.x, y: languagesPanel.y - 10 + i * 70 }); btn.visible = false; game.addChild(btn); languageBtns.push(btn); var btnTxt = new Text2(languageOptions[i].label, { size: 32, fill: '#fff' }); btnTxt.anchor.set(0.5, 0.5); btnTxt.x = btn.x; btnTxt.y = btn.y; btnTxt.visible = false; game.addChild(btnTxt); languageBtnTxts.push(btnTxt); // Closure for correct index (function (idx) { btn.down = function (x, y, obj) { var _tr, _en; // Animate button tween(btn, { scaleX: 1.12, scaleY: 1.12 }, { duration: 80, onFinish: function onFinish() { tween(btn, { scaleX: 1, scaleY: 1 }, { duration: 80 }); } }); // Set selected language selectedLanguage = languageOptions[idx].code; // Visual feedback: highlight selected for (var j = 0; j < languageBtns.length; j++) { if (j === idx) { languageBtns[j].tint = 0x83de44; // green highlight } else { languageBtns[j].tint = 0x222222; } } // Optionally, update UI text to reflect language (demo only) // You can add more logic here to actually change game language // --- TRANSLATION INFRASTRUCTURE --- // Ava: Add translation infrastructure and English translations for all game texts // 1. Translation dictionary var translations = { tr: (_tr = { "Mağaza": "Mağaza", "Burada mağaza ile ilgili içerik veya açıklama eklenebilir.": "Burada mağaza ile ilgili içerik veya açıklama eklenebilir.", "Muhasebe Bilgileri": "Muhasebe Bilgileri", "Mevcut Stok (adet):": "Mevcut Stok (adet):", "Kasadaki Para:": "Kasadaki Para:", "Borç:": "Borç:", "Kapat": "Kapat", "Yatırım": "Yatırım", "Yatırım - Popüler Coinler": "Yatırım - Popüler Coinler", "Adet:": "Adet:", "Maliyet:": "Maliyet:", "Al": "Al", "Sat": "Sat", "Banka": "Banka", "Borç Öde": "Borç Öde", "Languages": "Languages", "Select your language:": "Dilinizi seçin:", "Türkçe": "Türkçe", "English": "İngilizce", "Deutsch": "Almanca", "Français": "Fransızca", "Español": "İspanyolca", "Bakiye kullanım detayları yok": "Bakiye kullanım detayları yok", "Coin Alım: -₺": "Coin Alım: -₺", "Coin Satış: +₺": "Coin Satış: +₺", "Borç Ödeme: -₺": "Borç Ödeme: -₺", "Yatırım Harcama: -₺": "Yatırım Harcama: -₺", "Fabrika Yükseltme: -₺": "Fabrika Yükseltme: -₺", "Maden Yükseltme: -₺": "Maden Yükseltme: -₺", "Mağaza Yükseltme: -₺": "Mağaza Yükseltme: -₺", "İnternet Teklifi: -₺": "İnternet Teklifi: -₺", "Toplu Satış: +₺": "Toplu Satış: +₺", "Seviye:": "Seviye:", "Kazanç: ₺": "Kazanç: ₺", "Yükselt": "Yükselt", "Üretim Süresi: -%": "Üretim Süresi: -%", "Fabrika Yükseltme İndirimi: -%": "Fabrika Yükseltme İndirimi: -%", "Tıkla: ₺": "Tıkla: ₺", "Tüm Kazanç: +%": "Tüm Kazanç: +%", "Oto Üret: Kapalı": "Oto Üret: Kapalı", "Oto Üret: Açık": "Oto Üret: Açık", "Maden Yükselt": "Maden Yükselt", "ÜRET": "ÜRET", "Aç": "Aç", "Yükselt\n₺": "Yükselt\n₺", "Mağaza Yükselt": "Mağaza Yükselt", "Mağaza 2 Yükselt": "Mağaza 2 Yükselt", "İNTERNET TEKLİFİ": "İNTERNET TEKLİFİ", "Adet": "Adet", "Toplam: ₺": "Toplam: ₺", "Satın Al": "Satın Al", "Süre doldu!": "Süre doldu!", "Teklif tamamlandı!": "Teklif tamamlandı!", "Yeni teklif: ": "Yeni teklif: ", "dk": "dk", "sn": "sn", "TOPLU SATIŞ TEKLİFİ": "TOPLU SATIŞ TEKLİFİ", "Stokta ürün yok": "Stokta ürün yok", "Stok yetersiz": "Stok yetersiz" }, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_tr, "Sat", "Sat"), "Bakır: ", "Bakır: "), "Silikon: ", "Silikon: "), "Demir: ", "Demir: "), "Çalışan 1", "Çalışan 1"), "Çalışan 2", "Çalışan 2"), "Çalışan 3", "Çalışan 3"), "Çalışan 4", "Çalışan 4"), "Çalışan 5", "Çalışan 5"), "T\xFCm Kazan\xE7: +%", "Tüm Kazanç: +%"), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_tr, "Geri ödeme: ", "Geri ödeme: "), "Borç: ₺", "Borç: ₺"), "MOUSE", "MOUSE"), "Aç\n₺", "Aç\n₺"), "Y\xFCkselt\n\u20BA", "Yükselt\n₺"), "Mağaza 2 Yükselt\n₺", "Mağaza 2 Yükselt\n₺"), "Mağaza Yükselt\n₺", "Mağaza Yükselt\n₺"), "Maden Yükselt\n₺", "Maden Yükselt\n₺"), "Oto Üret: Kapalı\n₺", "Oto Üret: Kapalı\n₺"), "Oto Üret: Açık\n₺", "Oto Üret: Açık\n₺"), _defineProperty(_defineProperty(_tr, "Üretim: ", "Üretim: "), " sn", " sn")), en: (_en = { "Mağaza": "Store", "Burada mağaza ile ilgili içerik veya açıklama eklenebilir.": "You can add store-related content or description here.", "Muhasebe Bilgileri": "Accounting Info", "Mevcut Stok (adet):": "Current Stock (qty):", "Kasadaki Para:": "Cash in Register:", "Borç:": "Debt:", "Kapat": "Close", "Yatırım": "Investment", "Yatırım - Popüler Coinler": "Investment - Popular Coins", "Adet:": "Qty:", "Maliyet:": "Cost:", "Al": "Buy", "Sat": "Sell", "Banka": "Bank", "Borç Öde": "Pay Debt", "Languages": "Languages", "Select your language:": "Select your language:", "Türkçe": "Turkish", "English": "English", "Deutsch": "German", "Français": "French", "Español": "Spanish", "Bakiye kullanım detayları yok": "No balance usage details", "Coin Alım: -₺": "Coin Purchase: -₺", "Coin Satış: +₺": "Coin Sale: +₺", "Borç Ödeme: -₺": "Debt Payment: -₺", "Yatırım Harcama: -₺": "Investment Expense: -₺", "Fabrika Yükseltme: -₺": "Factory Upgrade: -₺", "Maden Yükseltme: -₺": "Mine Upgrade: -₺", "Mağaza Yükseltme: -₺": "Store Upgrade: -₺", "İnternet Teklifi: -₺": "Internet Offer: -₺", "Toplu Satış: +₺": "Bulk Sale: +₺", "Seviye:": "Level:", "Kazanç: ₺": "Earning: ₺", "Yükselt": "Upgrade", "Üretim Süresi: -%": "Production Time: -%", "Fabrika Yükseltme İndirimi: -%": "Factory Upgrade Discount: -%", "Tıkla: ₺": "Click: ₺", "Tüm Kazanç: +%": "All Earnings: +%", "Oto Üret: Kapalı": "Auto Prod: Off", "Oto Üret: Açık": "Auto Prod: On", "Maden Yükselt": "Upgrade Mine", "ÜRET": "PRODUCE", "Aç": "Unlock", "Yükselt\n₺": "Upgrade\n₺", "Mağaza Yükselt": "Upgrade Store", "Mağaza 2 Yükselt": "Upgrade Store 2", "İNTERNET TEKLİFİ": "INTERNET OFFER", "Adet": "Qty", "Toplam: ₺": "Total: ₺", "Satın Al": "Buy", "Süre doldu!": "Time's up!", "Teklif tamamlandı!": "Offer completed!", "Yeni teklif: ": "New offer: ", "dk": "min", "sn": "sec", "TOPLU SATIŞ TEKLİFİ": "BULK SALE OFFER", "Stokta ürün yok": "No product in stock", "Stok yetersiz": "Insufficient stock" }, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_en, "Sat", "Sell"), "Bakır: ", "Copper: "), "Silikon: ", "Silicon: "), "Demir: ", "Iron: "), "Çalışan 1", "Worker 1"), "Çalışan 2", "Worker 2"), "Çalışan 3", "Worker 3"), "Çalışan 4", "Worker 4"), "Çalışan 5", "Worker 5"), "T\xFCm Kazan\xE7: +%", "All Earnings: +%"), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_en, "Geri ödeme: ", "Repayment: "), "Borç: ₺", "Debt: ₺"), "MOUSE", "MOUSE"), "Aç\n₺", "Unlock\n₺"), "Y\xFCkselt\n\u20BA", "Upgrade\n₺"), "Mağaza 2 Yükselt\n₺", "Upgrade Store 2\n₺"), "Mağaza Yükselt\n₺", "Upgrade Store\n₺"), "Maden Yükselt\n₺", "Upgrade Mine\n₺"), "Oto Üret: Kapalı\n₺", "Auto Prod: Off\n₺"), "Oto Üret: Açık\n₺", "Auto Prod: On\n₺"), _defineProperty(_defineProperty(_en, "Üretim: ", "Production: "), " sn", " sec")) }; // 2. Translation function function t(key) { var lang = selectedLanguage || "tr"; if (translations[lang] && translations[lang][key] !== undefined) { return translations[lang][key]; } // fallback to Turkish if not found if (translations["tr"][key] !== undefined) return translations["tr"][key]; return key; } // 3. Patch all UI text updates to use t() // --- Patch static UI texts at creation time --- magazaBtnTxt.setText(t("Mağaza")); magazaPanelTitle.setText(t("Mağaza")); magazaPanelText.setText(t("Burada mağaza ile ilgili içerik veya açıklama eklenebilir.")); magazaMuhasebeTitle.setText(t("Muhasebe Bilgileri")); magazaKapatBtnTxt.setText(t("Kapat")); yatirimBtnTxt.setText(t("Yatırım")); yatirimTitle.setText(t("Yatırım - Popüler Coinler")); yatirimKapatBtnTxt.setText(t("Kapat")); bankBtnTxt.setText(t("Banka")); borcOdeBtnTxt.setText(t("Borç Öde")); languagesBtnTxt.setText(t("Languages")); languagesPanelTitle.setText(t("Languages")); languagesPanelText.setText(t("Select your language:")); languagesKapatBtnTxt.setText(t("Kapat")); offerTitle.setText(t("İNTERNET TEKLİFİ")); offerBtnTxt.setText(t("Satın Al")); sellTitle.setText(t("TOPLU SATIŞ TEKLİFİ")); sellBtnTxt.setText(t("Sat")); // Patch language option button texts for (var i = 0; i < languageOptions.length; i++) { languageBtnTxts[i].setText(t(languageOptions[i].label)); } // --- Patch dynamic UI text updates to use t() --- // Patch updateBakiyeDetayTxt var _old_updateBakiyeDetayTxt = updateBakiyeDetayTxt; updateBakiyeDetayTxt = function updateBakiyeDetayTxt() { if (bakiyeDetayList.length === 0) { bakiyeDetayTxt.setText(t("Bakiye kullanım detayları yok")); bakiyeDetayTxt.visible = true; } else { // Translate each line var lines = []; for (var i = 0; i < bakiyeDetayList.length; i++) { var line = bakiyeDetayList[i]; // Try to match prefix for lines with values var found = false; for (var k in translations["tr"]) { if (line.indexOf(k) === 0 && translations[selectedLanguage][k]) { lines.push(line.replace(k, t(k))); found = true; break; } } if (!found) lines.push(line); } bakiyeDetayTxt.setText(lines.join('\n')); bakiyeDetayTxt.visible = true; } }; // Patch updateMagazaMuhasebeText var _old_updateMagazaMuhasebeText = updateMagazaMuhasebeText; updateMagazaMuhasebeText = function updateMagazaMuhasebeText() { var toplamSatis = 0; var toplamGelir = 0; for (var i = 0; i < partTypes.length; i++) { toplamSatis += parts[partTypes[i]]; } toplamGelir = money; magazaMuhasebeText.setText(t("Mevcut Stok (adet):") + " " + toplamSatis + "\n" + t("Kasadaki Para:") + " ₺" + toplamGelir + (typeof borc !== "undefined" && borc > 0 ? "\n" + t("Borç:") + " ₺" + borc : "")); }; // Patch updateBorcText var _old_updateBorcText = updateBorcText; updateBorcText = function updateBorcText() { if (borc > 0) { borcTxt.setText(t("Borç: ₺") + borc); if (borcOdemeKalan > 0) { var min = Math.floor(borcOdemeKalan / 60); var sec = borcOdemeKalan % 60; var timeStr = min > 0 ? min + " " + t("dk") + " " + (sec < 10 ? "0" : "") + sec + " " + t("sn") : sec + " " + t("sn"); borcTimeTxt.setText(t("Geri ödeme: ") + timeStr); } else { borcTimeTxt.setText(''); } } else { borcTxt.setText(''); borcTimeTxt.setText(''); } }; // Patch updateRawText var _old_updateRawText = updateRawText; updateRawText = function updateRawText() { if (typeof copperRawTxt !== "undefined" && copperRawTxt) copperRawTxt.setText(t("Bakır: ") + rawMaterials.copper); if (typeof siliconRawTxt !== "undefined" && siliconRawTxt) siliconRawTxt.setText(t("Silikon: ") + rawMaterials.silicon); if (typeof ironRawTxt !== "undefined" && ironRawTxt) ironRawTxt.setText(t("Demir: ") + rawMaterials.iron); }; // Patch updatePartsText var _old_updatePartsText = updatePartsText; updatePartsText = function updatePartsText() { var lines = ['', '', '', '', '']; for (var i = 0; i < partTypes.length; i++) { var label = (i === 0 ? t("MOUSE") : partTypes[i].toUpperCase()) + ':' + parts[partTypes[i]]; var row = i % 5; var col = Math.floor(i / 5); if (col === 0) { lines[row] = label; } else { var maxLabelLen = 13; var left = lines[row]; var right = label; var pad = " "; lines[row] = left + pad + right; } } partsTxt.setText(lines.join('\n')); if (magazaMuhasebeText && magazaMuhasebeText.visible) updateMagazaMuhasebeText(); }; // Patch offer/sell panel static texts offerTitle.setText(t("İNTERNET TEKLİFİ")); offerBtnTxt.setText(t("Satın Al")); sellTitle.setText(t("TOPLU SATIŞ TEKLİFİ")); sellBtnTxt.setText(t("Sat")); // Patch worker label texts for (var i = 0; i < workerImages.length; i++) { if (workerImages[i].label) { workerImages[i].label.setText(t(workerNames[i])); workerImages[i].label.size = 40; workerImages[i].label.lineHeight = 52; } } // --- Language switching logic --- // When language is changed, update all UI texts function updateAllTextsForLanguage() { magazaBtnTxt.setText(t("Mağaza")); magazaPanelTitle.setText(t("Mağaza")); magazaPanelText.setText(t("Burada mağaza ile ilgili içerik veya açıklama eklenebilir.")); magazaMuhasebeTitle.setText(t("Muhasebe Bilgileri")); magazaKapatBtnTxt.setText(t("Kapat")); yatirimBtnTxt.setText(t("Yatırım")); yatirimTitle.setText(t("Yatırım - Popüler Coinler")); yatirimKapatBtnTxt.setText(t("Kapat")); bankBtnTxt.setText(t("Banka")); borcOdeBtnTxt.setText(t("Borç Öde")); languagesBtnTxt.setText(t("Languages")); languagesPanelTitle.setText(t("Languages")); languagesPanelText.setText(t("Select your language:")); languagesKapatBtnTxt.setText(t("Kapat")); offerTitle.setText(t("İNTERNET TEKLİFİ")); offerBtnTxt.setText(t("Satın Al")); sellTitle.setText(t("TOPLU SATIŞ TEKLİFİ")); sellBtnTxt.setText(t("Sat")); // Language option button texts for (var i = 0; i < languageOptions.length; i++) { languageBtnTxts[i].setText(t(languageOptions[i].label)); } // Worker label texts for (var i = 0; i < workerImages.length; i++) { if (workerImages[i].label) { workerImages[i].label.setText(t(workerNames[i])); workerImages[i].label.size = 40; // font büyüklüğü workerImages[i].label.lineHeight = 52; // satır aralığı } } // Update dynamic texts updateBakiyeDetayTxt(); updateMagazaMuhasebeText(); updateBorcText(); updateRawText(); updatePartsText(); // --- Ava: Patch all static/dynamic UI texts for English --- // Patch all static/dynamic UI texts for English if (selectedLanguage === "en") { // Patch static UI texts for English magazaBtnTxt.setText(t("Mağaza")); magazaPanelTitle.setText(t("Mağaza")); magazaPanelText.setText(t("Burada mağaza ile ilgili içerik veya açıklama eklenebilir.")); magazaMuhasebeTitle.setText(t("Muhasebe Bilgileri")); magazaKapatBtnTxt.setText(t("Kapat")); yatirimBtnTxt.setText(t("Yatırım")); yatirimTitle.setText(t("Yatırım - Popüler Coinler")); yatirimKapatBtnTxt.setText(t("Kapat")); bankBtnTxt.setText(t("Banka")); borcOdeBtnTxt.setText(t("Borç Öde")); languagesBtnTxt.setText(t("Languages")); languagesPanelTitle.setText(t("Languages")); languagesPanelText.setText(t("Select your language:")); languagesKapatBtnTxt.setText(t("Kapat")); offerTitle.setText(t("İNTERNET TEKLİFİ")); offerBtnTxt.setText(t("Satın Al")); sellTitle.setText(t("TOPLU SATIŞ TEKLİFİ")); sellBtnTxt.setText(t("Sat")); // Language option button texts for (var i = 0; i < languageOptions.length; i++) { languageBtnTxts[i].setText(t(languageOptions[i].label)); } // Worker label texts for (var i = 0; i < workerImages.length; i++) { if (workerImages[i].label) { workerImages[i].label.setText(t(workerNames[i])); workerImages[i].label.size = 40; workerImages[i].label.lineHeight = 52; } } // Update dynamic texts updateBakiyeDetayTxt(); updateMagazaMuhasebeText(); updateBorcText(); updateRawText(); updatePartsText(); } } // --- Patch language button logic to update UI on language change --- for (var i = 0; i < languageBtns.length; i++) { (function (idx) { var btn = languageBtns[idx]; btn.down = function (x, y, obj) { tween(btn, { scaleX: 1.12, scaleY: 1.12 }, { duration: 80, onFinish: function onFinish() { tween(btn, { scaleX: 1, scaleY: 1 }, { duration: 80 }); } }); // Set selected language selectedLanguage = languageOptions[idx].code; // Visual feedback: highlight selected for (var j = 0; j < languageBtns.length; j++) { if (j === idx) { languageBtns[j].tint = 0x83de44; // green highlight } else { languageBtns[j].tint = 0x222222; } } // Update all UI texts updateAllTextsForLanguage(); }; })(i); } }; })(i); } // Kapat butonu var languagesKapatBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 120, height: 60, x: languagesPanel.x + 180, y: languagesPanel.y + languagesPanel.height / 2 - 40 }); languagesKapatBtn.visible = false; game.addChild(languagesKapatBtn); var languagesKapatBtnTxt = new Text2('Kapat', { size: 32, fill: '#fff' }); languagesKapatBtnTxt.anchor.set(0.5, 0.5); languagesKapatBtnTxt.x = languagesKapatBtn.x; languagesKapatBtnTxt.y = languagesKapatBtn.y; languagesKapatBtnTxt.visible = false; game.addChild(languagesKapatBtnTxt); // Languages butonuna tıklanınca paneli aç languagesBtn.down = function (x, y, obj) { tween(languagesBtn, { scaleX: 1.12, scaleY: 1.12 }, { duration: 80, onFinish: function onFinish() { tween(languagesBtn, { scaleX: 1, scaleY: 1 }, { duration: 80 }); } }); // Paneli aç languagesPanel.visible = true; languagesPanelTitle.visible = true; languagesPanelText.visible = true; languagesKapatBtn.visible = true; languagesKapatBtnTxt.visible = true; // Show language buttons for (var i = 0; i < languageBtns.length; i++) { languageBtns[i].visible = true; languageBtnTxts[i].visible = true; // Highlight selected if (languageOptions[i].code === selectedLanguage) { languageBtns[i].tint = 0x83de44; } else { languageBtns[i].tint = 0x222222; } } // Paneli en öne getir if (game.setChildIndex) { game.setChildIndex(languagesPanel, game.children.length - 1); game.setChildIndex(languagesPanelTitle, game.children.length - 1); game.setChildIndex(languagesPanelText, game.children.length - 1); game.setChildIndex(languagesKapatBtn, game.children.length - 1); game.setChildIndex(languagesKapatBtnTxt, game.children.length - 1); // Bring language buttons to front for (var i = 0; i < languageBtns.length; i++) { game.setChildIndex(languageBtns[i], game.children.length - 1); game.setChildIndex(languageBtnTxts[i], game.children.length - 1); } } }; // Paneli kapatmak için kapat butonu languagesKapatBtn.down = function (x, y, obj) { languagesPanel.visible = false; languagesPanelTitle.visible = false; languagesPanelText.visible = false; languagesKapatBtn.visible = false; languagesKapatBtnTxt.visible = false; // Hide language buttons for (var i = 0; i < languageBtns.length; i++) { languageBtns[i].visible = false; languageBtnTxts[i].visible = false; } }; borcOdeBtn.down = function (x, y, obj) { if (borc > 0) { var odeme = Math.min(money, borc); if (odeme > 0) { money -= odeme; toplamBorcOdeme += odeme; borc -= odeme; if (borc < 0) { borc = 0; } updateMoneyText(); updateBorcText(); } // If borç is now 0, clear timers if (borc <= 0) { borc = 0; updateBorcText(); if (typeof borcOdemeTimer !== "undefined" && borcOdemeTimer) { LK.clearInterval(borcOdemeTimer); borcOdemeTimer = null; } if (typeof borcOdemeTimeTimer !== "undefined" && borcOdemeTimeTimer) { LK.clearInterval(borcOdemeTimeTimer); borcOdemeTimeTimer = null; } } } else { // Flash button red if no debt tween(borcOdeBtn, { tint: 0xff2222 }, { duration: 120, onFinish: function onFinish() { tween(borcOdeBtn, { tint: 0x222222 }, { duration: 120 }); } }); } }; // Repayment time text var borcTimeTxt = new Text2('', { size: 28, fill: '#ffb' }); borcTimeTxt.anchor.set(0.5, 0); borcTimeTxt.x = borcTxt.x; borcTimeTxt.y = borcTxt.y + 28; LK.gui.top.addChild(borcTimeTxt); var borcOdemeKalan = 0; // seconds left to next repayment var borcOdemeTimeTimer = null; function updateBorcText() { if (borc > 0) { borcTxt.setText('Borç: ₺' + borc); if (borcOdemeKalan > 0) { var min = Math.floor(borcOdemeKalan / 60); var sec = borcOdemeKalan % 60; var timeStr = min > 0 ? min + " dk " + (sec < 10 ? "0" : "") + sec + " sn" : sec + " sn"; borcTimeTxt.setText("Geri ödeme: " + timeStr); } else { borcTimeTxt.setText(''); } } else { borcTxt.setText(''); borcTimeTxt.setText(''); } } updateBorcText(); var borcOdemeTimer = null; bankBtn.down = function (x, y, obj) { // Only allow one active loan at a time if (borc > 0) { // Flash button red to indicate already borrowed tween(bankBtn, { tint: 0xff2222 }, { duration: 120, onFinish: function onFinish() { tween(bankBtn, { tint: 0x222222 }, { duration: 120 }); } }); return; } borc = 1000; money += 1000; updateMoneyText(); updateBorcText(); // Start repayment every 10 minutes (600s = 36000 frames) if (borcOdemeTimer) { LK.clearInterval(borcOdemeTimer); } if (borcOdemeTimeTimer) { LK.clearInterval(borcOdemeTimeTimer); } borcOdemeKalan = 600; // seconds to next repayment (10 minutes) updateBorcText(); // Repayment time countdown, updates every 1 second borcOdemeTimeTimer = LK.setInterval(function () { if (borc > 0) { borcOdemeKalan--; if (borcOdemeKalan < 0) { borcOdemeKalan = 0; } updateBorcText(); } else { borcOdemeKalan = 0; updateBorcText(); if (borcOdemeTimeTimer) { LK.clearInterval(borcOdemeTimeTimer); borcOdemeTimeTimer = null; } } }, 60); // 1 second at 60fps borcOdemeTimer = LK.setInterval(function () { if (borc > 0) { var odeme = Math.ceil(borc * 0.25); if (money >= odeme) { money -= odeme; borc -= odeme; if (borc < 0) { borc = 0; } updateMoneyText(); updateBorcText(); } else { // Not enough money, take all money and reduce borc accordingly borc -= money; money = 0; if (borc < 0) { borc = 0; } updateMoneyText(); updateBorcText(); } if (borc <= 0) { borc = 0; updateBorcText(); if (borcOdemeTimer) { LK.clearInterval(borcOdemeTimer); borcOdemeTimer = null; } if (borcOdemeTimeTimer) { LK.clearInterval(borcOdemeTimeTimer); borcOdemeTimeTimer = null; } } borcOdemeKalan = 600; // reset repayment time for next cycle (10 minutes) updateBorcText(); } }, 36000); // 10 minutes at 60fps }; // --- Madenlerin stok yazılarını maden resimlerinin tam üstüne ve ortasına yerleştir --- // Madenler oluşturulmadan önce tanımlanıyor, mines dizisi aşağıda dolacak var copperRawTxt, siliconRawTxt, ironRawTxt; // Global function to update raw material texts function updateRawText() { if (typeof copperRawTxt !== "undefined" && copperRawTxt) copperRawTxt.setText('Bakır: ' + rawMaterials.copper); if (typeof siliconRawTxt !== "undefined" && siliconRawTxt) siliconRawTxt.setText('Silikon: ' + rawMaterials.silicon); if (typeof ironRawTxt !== "undefined" && ironRawTxt) ironRawTxt.setText('Demir: ' + rawMaterials.iron); } // Madenler oluşturulduktan sonra, mines dizisi dolduktan sonra konumlandır LK.setTimeout(function () { // Güvenli kontrol: mines ve her mine var mı if (mines && mines.length >= 3) { // Bakır copperRawTxt = new Text2('', { size: 40, fill: '#ffb', fontWeight: 'bold' }); copperRawTxt.anchor.set(0.5, 0.5); copperRawTxt.x = mines[0].x; copperRawTxt.y = mines[0].y; game.addChild(copperRawTxt); // Silikon siliconRawTxt = new Text2('', { size: 40, fill: '#ffb', fontWeight: 'bold' }); siliconRawTxt.anchor.set(0.5, 0.5); siliconRawTxt.x = mines[1].x; siliconRawTxt.y = mines[1].y; game.addChild(siliconRawTxt); // Demir ironRawTxt = new Text2('', { size: 40, fill: '#ffb', fontWeight: 'bold' }); ironRawTxt.anchor.set(0.5, 0.5); ironRawTxt.x = mines[2].x; ironRawTxt.y = mines[2].y; game.addChild(ironRawTxt); updateRawText(); } }, 1); // mines dizisinin dolmasını bekle (1 frame sonra çalıştır) // Panel for parts count, placed below the sales offers (below sellPanel) // Ensure sellPanel is defined before using its x/y var partsPanelX = 120; // default fallback var partsPanelY = 1366 + 400 + 340 / 2 + 60; // biraz daha aşağı (ekstra +30px) if (typeof sellPanel !== "undefined" && sellPanel && typeof sellPanel.x === "number" && typeof sellPanel.y === "number" && typeof sellPanel.height === "number") { partsPanelX = sellPanel.x; partsPanelY = sellPanel.y + sellPanel.height / 2 + 60; // biraz daha aşağı (ekstra +30px) } // Panel boyutunu yazı boyutuna göre ayarla (2 sütun, 5 satır, her label max 13 karakter, font size 32, padding 24px) // Paneli üstteki sellPanel ile aynı genişlikte ve hizada yap // Panel genişliğini sağdan biraz daha küçült (ör: 1 kademe = 24px azalt) var partsPanelWidth = (typeof sellPanel !== "undefined" && sellPanel ? sellPanel.width : 2 * 13 * 18 + 48) - 72; // 72px azaltıldı (3 kademe) var partsPanelHeight = 5 * 38 + 36; // 5 satır * satır yüksekliği + padding var partsPanel = LK.getAsset('button', { anchorX: 0.5, anchorY: 0, width: partsPanelWidth, height: partsPanelHeight, x: partsPanelX, y: partsPanelY // sellPanel'den biraz daha aşağı }); game.addChild(partsPanel); var partsTxt = new Text2('', { size: 32, fill: '#bff' }); // Yazıları panelin sağ kenarına hizala partsTxt.anchor.set(1, 0.5); partsTxt.x = partsPanel.x + partsPanel.width / 2 - 16; // sağdan 16px padding bırak (panel küçüldüğü için padding azaltıldı) partsTxt.y = partsPanel.y + partsPanel.height / 2; game.addChild(partsTxt); function updatePartsText() { // 2 sütun, 5 satır olacak şekilde ürünleri aşağı doğru sırala // Her satırda iki sütun olacak şekilde, sağa hizalı var lines = ['', '', '', '', '']; for (var i = 0; i < partTypes.length; i++) { var label = (i === 0 ? "MOUSE" : partTypes[i].toUpperCase()) + ':' + parts[partTypes[i]]; var row = i % 5; var col = Math.floor(i / 5); if (col === 0) { lines[row] = label; } else { // Sola boşluk ekle, sağa hizalı olması için iki sütun arası boşluk artırıldı var maxLabelLen = 13; var left = lines[row]; var right = label; // Her iki sütunu da sağa hizalamak için, satırın toplam uzunluğunu panel genişliğine göre ayarla // 2 sütun arası 8 boşluk bırak var pad = " "; lines[row] = left + pad + right; } } partsTxt.setText(lines.join('\n')); if (magazaMuhasebeText && magazaMuhasebeText.visible) updateMagazaMuhasebeText(); } updatePartsText(); // Arkaplan müziğini başlat LK.playMusic('ArkaplanMuzik'); // --- Workers moved to new page panel --- var workerImages = []; // Her çalışana farklı bir resim atanacak şekilde image id'leri belirle var workerImageIds = ['6830b806dc6f2ae53a448901', '6830b6cfdc6f2ae53a4488d7', '6830b789dc6f2ae53a4488e8', '6830c278dc6f2ae53a4489a4', '6830ba15dc6f2ae53a448943']; var workerNames = ['Çalışan 1', 'Çalışan 2', 'Çalışan 3', 'Çalışan 4', 'Çalışan 5']; // Çalışanlar yeni sayfa panelinde gösterilecek var workerCount = 5; // --- 3'lü sıra halinde alt alta dizilim için yeni konumlandırma --- // 3 sütun, 2 satır (son satırda 2 çalışan olacak şekilde) var workerRows = 2; var workerCols = 3; var workerPanelMarginTop = 60; // başlık ve "Çalışanlar" yazısı için üstte daha fazla boşluk bırak var workerPanelMarginBottom = 80; var workerPanelHeight = newPagePanelHeight - workerPanelMarginTop - workerPanelMarginBottom; var workerPanelWidth = newPagePanelWidth; var workerCellWidth = Math.floor(workerPanelWidth / workerCols); var workerCellHeight = Math.floor(workerPanelHeight / workerRows); // "Çalışanlar" başlığının altına hizalamak için Y başlangıcı var workerGridStartY = newPagePanelText.y + newPagePanelText.height + 40; // başlığın altından 40px boşluk // Her çalışanın paneldeki X ve Y koordinatlarını hesapla function getWorkerPanelPos(idx) { // 0,1,2 üst satır; 3,4 alt satır var row = Math.floor(idx / workerCols); var col = idx % workerCols; // Son satırda çalışan sayısı 2 ise ortala if (row === 1 && workerCount === 5) { // 2 çalışanı ortalamak için col: 0 ve 1 için X ayarla var colInRow = idx - workerCols; // 3->0, 4->1 var x = newPagePanel.x + workerCellWidth * (colInRow + 1); var y = workerGridStartY + workerCellHeight * row + workerCellHeight / 2; return { x: x, y: y }; } else { // Üst satırda 3 çalışanı eşit aralıklı dağıt var x = newPagePanel.x + workerCellWidth * (col + 0.5); var y = workerGridStartY + workerCellHeight * row + workerCellHeight / 2; return { x: x, y: y }; } } // Çalışan 1 için seviye, kazanç oranı ve butonlar var worker1Level = 1; var worker1EarningBase = 10; var worker1UpgradeCost = 200; var worker1EarningTxt = null; var worker1LevelTxt = null; var worker1UpgradeBtn = null; var worker1UpgradeBtnTxt = null; // Çalışan 2 için seviye, üretim süresi azaltma ve butonlar var worker2Level = 1; var worker2UpgradeCost = 250; var worker2LevelTxt = null; var worker2SpeedTxt = null; var worker2UpgradeBtn = null; var worker2UpgradeBtnTxt = null; // Çalışan 3 için seviye, fabrika yükseltme maliyeti indirim oranı ve butonlar var worker3Level = 1; var worker3UpgradeCost = 300; var worker3LevelTxt = null; var worker3DiscountTxt = null; var worker3UpgradeBtn = null; var worker3UpgradeBtnTxt = null; // Çalışan 4 için seviye, tıklama kazancı ve butonlar var worker4Level = 1; var worker4BaseEarning = 50; var worker4UpgradeCost = 1000; var worker4EarningTxt = null; var worker4LevelTxt = null; var worker4UpgradeBtn = null; var worker4UpgradeBtnTxt = null; // Çalışan 5 için seviye, bonus ve butonlar var worker5Level = 1; var worker5BaseBonus = 0.05; var worker5UpgradeCost = 2000; var worker5BonusTxt = null; var worker5LevelTxt = null; var worker5UpgradeBtn = null; var worker5UpgradeBtnTxt = null; // Çalışan UI'larını panelde oluştur, başta görünmez // --- Ava: workerGapX ve workerY'yi tanımla (panelin genişliğine ve grid'e göre) --- var workerGapX = newPagePanelWidth / 6; // 3 sütun için 6 aralık (kenarlarda boşluk) var workerY = newPagePanelY + newPagePanelHeight / 2; // Panelin ortası (varsayılan, grid ile override edilir) for (var i = 0; i < 5; i++) { // Dağılımı tam ekran panelde ortala var workerX = workerGapX * (i + 1); var workerImg = LK.getAsset('worker' + (i + 1), { anchorX: 0.5, anchorY: 0.5, width: 140, height: 140, x: workerX, y: workerY }); workerImg.visible = false; game.addChild(workerImg); var workerLabel = new Text2(workerNames[i], { size: 40, //{iA} // font büyütüldü fill: '#fff', lineHeight: 48 // satır aralığı düzeltildi, daha iyi hizalama için 48 yapıldı }); workerLabel.anchor.set(0.5, 0); // Resmin alt kenarına ve ortasına hizala workerLabel.x = workerImg.x; workerLabel.y = workerImg.y + workerImg.height / 2 + 10; // 10px aşağı boşluk bırak workerLabel.visible = false; game.addChild(workerLabel); // Çalışan alt açıklama yazılarını (seviye, kazanç, bonus, vs) alt alta hizalı şekilde ayarlamak için // Her çalışan için alt açıklama yazıları bir diziye alınacak ve alt alta sıralanacak // (Aşağıda ilgili UI'lar eklenirken y konumları bu düzene göre ayarlanacak) // Çalışan 1 için seviye, kazanç ve buton ekle if (i === 0) { worker1LevelTxt = new Text2('Seviye: ' + worker1Level, { size: 26, fill: '#ffb' }); worker1LevelTxt.anchor.set(0.5, 0); worker1LevelTxt.x = workerImg.x; worker1LevelTxt.y = workerLabel.y + 24; worker1LevelTxt.visible = false; game.addChild(worker1LevelTxt); worker1EarningTxt = new Text2('Kazanç: ₺' + Math.round(worker1EarningBase * Math.pow(1.02, worker1Level - 1)), { size: 26, fill: '#bff' }); worker1EarningTxt.anchor.set(0.5, 0); worker1EarningTxt.x = workerImg.x; worker1EarningTxt.y = worker1LevelTxt.y + 22; worker1EarningTxt.visible = false; game.addChild(worker1EarningTxt); worker1UpgradeBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 140, //{iV} // buton genişliği büyütüldü height: 64, //{iW} // buton yüksekliği büyütüldü x: workerImg.x, y: worker1EarningTxt.y + 54 // biraz daha aşağı }); worker1UpgradeBtn.visible = false; game.addChild(worker1UpgradeBtn); worker1UpgradeBtnTxt = new Text2('Yükselt\n₺' + worker1UpgradeCost, { size: 28, //{iZ} // yazı boyutu büyütüldü fill: '#fff' }); worker1UpgradeBtnTxt.anchor.set(0.5, 0.5); worker1UpgradeBtnTxt.x = worker1UpgradeBtn.x; worker1UpgradeBtnTxt.y = worker1UpgradeBtn.y; worker1UpgradeBtnTxt.visible = false; game.addChild(worker1UpgradeBtnTxt); worker1UpgradeBtn.down = function (x, y, obj) { if (yatirimPanel && yatirimPanel.visible) return; if (money >= worker1UpgradeCost) { money -= worker1UpgradeCost; worker1Level += 1; worker1UpgradeCost = Math.floor(worker1UpgradeCost * 2.2); updateMoneyText(); worker1LevelTxt.setText('Seviye: ' + worker1Level); worker1EarningTxt.setText('Kazanç: ₺' + Math.round(worker1EarningBase * Math.pow(1.02, worker1Level - 1))); worker1UpgradeBtnTxt.setText('Yükselt\n₺' + worker1UpgradeCost); tween(worker1UpgradeBtn, { scaleX: 1.12, scaleY: 1.12 }, { duration: 80, onFinish: function onFinish() { tween(worker1UpgradeBtn, { scaleX: 1, scaleY: 1 }, { duration: 80 }); } }); } else { tween(worker1UpgradeBtn, { tint: 0xff2222 }, { duration: 120, onFinish: function onFinish() { tween(worker1UpgradeBtn, { tint: 0x222222 }, { duration: 120 }); } }); } }; } // Çalışan 2 için seviye, üretim süresi azaltma ve buton ekle if (i === 1) { worker2LevelTxt = new Text2('Seviye: ' + worker2Level, { size: 26, fill: '#ffb' }); worker2LevelTxt.anchor.set(0.5, 0); worker2LevelTxt.x = workerImg.x; worker2LevelTxt.y = workerLabel.y + 24; worker2LevelTxt.visible = false; game.addChild(worker2LevelTxt); worker2SpeedTxt = new Text2('Üretim Süresi: -%0', { size: 26, fill: '#bff' }); worker2SpeedTxt.anchor.set(0.5, 0); worker2SpeedTxt.x = workerImg.x; worker2SpeedTxt.y = worker2LevelTxt.y + 22; worker2SpeedTxt.visible = false; game.addChild(worker2SpeedTxt); worker2UpgradeBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 140, //{jI} // buton genişliği büyütüldü height: 64, //{jJ} // buton yüksekliği büyütüldü x: workerImg.x, y: worker2SpeedTxt.y + 54 }); worker2UpgradeBtn.visible = false; game.addChild(worker2UpgradeBtn); worker2UpgradeBtnTxt = new Text2('Yükselt\n₺' + worker2UpgradeCost, { size: 28, //{jM} // yazı boyutu büyütüldü fill: '#fff' }); worker2UpgradeBtnTxt.anchor.set(0.5, 0.5); worker2UpgradeBtnTxt.x = worker2UpgradeBtn.x; worker2UpgradeBtnTxt.y = worker2UpgradeBtn.y; worker2UpgradeBtnTxt.visible = false; game.addChild(worker2UpgradeBtnTxt); worker2UpgradeBtn.down = function (x, y, obj) { if (yatirimPanel && yatirimPanel.visible) return; if (money >= worker2UpgradeCost) { money -= worker2UpgradeCost; worker2Level += 1; worker2UpgradeCost = Math.floor(worker2UpgradeCost * 2.2); updateMoneyText(); worker2LevelTxt.setText('Seviye: ' + worker2Level); worker2SpeedTxt.setText('Üretim Süresi: -%' + (worker2Level - 1) * 2); worker2UpgradeBtnTxt.setText('Yükselt\n₺' + worker2UpgradeCost); tween(worker2UpgradeBtn, { scaleX: 1.12, scaleY: 1.12 }, { duration: 80, onFinish: function onFinish() { tween(worker2UpgradeBtn, { scaleX: 1, scaleY: 1 }, { duration: 80 }); } }); } else { tween(worker2UpgradeBtn, { tint: 0xff2222 }, { duration: 120, onFinish: function onFinish() { tween(worker2UpgradeBtn, { tint: 0x222222 }, { duration: 120 }); } }); } }; } // Çalışan 3 için seviye, fabrika yükseltme maliyeti indirim oranı ve buton ekle if (i === 2) { worker3LevelTxt = new Text2('Seviye: ' + worker3Level, { size: 26, fill: '#ffb' }); worker3LevelTxt.anchor.set(0.5, 0); worker3LevelTxt.x = workerImg.x; worker3LevelTxt.y = workerLabel.y + 24; worker3LevelTxt.visible = false; game.addChild(worker3LevelTxt); worker3DiscountTxt = new Text2('Fabrika Yükseltme İndirimi: -%0', { size: 26, fill: '#bff' }); worker3DiscountTxt.anchor.set(0.5, 0); worker3DiscountTxt.x = workerImg.x; worker3DiscountTxt.y = worker3LevelTxt.y + 22; worker3DiscountTxt.visible = false; game.addChild(worker3DiscountTxt); worker3UpgradeBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 140, //{kv} // buton genişliği büyütüldü height: 64, //{kw} // buton yüksekliği büyütüldü x: workerImg.x, y: worker3DiscountTxt.y + 54 }); worker3UpgradeBtn.visible = false; game.addChild(worker3UpgradeBtn); worker3UpgradeBtnTxt = new Text2('Yükselt\n₺' + worker3UpgradeCost, { size: 28, //{kz} // yazı boyutu büyütüldü fill: '#fff' }); worker3UpgradeBtnTxt.anchor.set(0.5, 0.5); worker3UpgradeBtnTxt.x = worker3UpgradeBtn.x; worker3UpgradeBtnTxt.y = worker3UpgradeBtn.y; worker3UpgradeBtnTxt.visible = false; game.addChild(worker3UpgradeBtnTxt); worker3UpgradeBtn.down = function (x, y, obj) { if (yatirimPanel && yatirimPanel.visible) return; if (money >= worker3UpgradeCost) { money -= worker3UpgradeCost; worker3Level += 1; worker3UpgradeCost = Math.floor(worker3UpgradeCost * 2.2); updateMoneyText && updateMoneyText(); worker3LevelTxt.setText('Seviye: ' + worker3Level); worker3DiscountTxt.setText('Fabrika Yükseltme İndirimi: -%' + (worker3Level - 1) * 2); worker3UpgradeBtnTxt.setText('Yükselt\n₺' + worker3UpgradeCost); tween(worker3UpgradeBtn, { scaleX: 1.12, scaleY: 1.12 }, { duration: 80, onFinish: function onFinish() { tween(worker3UpgradeBtn, { scaleX: 1, scaleY: 1 }, { duration: 80 }); } }); } else { tween(worker3UpgradeBtn, { tint: 0xff2222 }, { duration: 120, onFinish: function onFinish() { tween(worker3UpgradeBtn, { tint: 0x222222 }, { duration: 120 }); } }); } }; } // Çalışan 4 için seviye, tıklama kazancı ve yükseltme butonu ekle if (i === 3) { worker4LevelTxt = new Text2('Seviye: ' + worker4Level, { size: 26, fill: '#ffb' }); worker4LevelTxt.anchor.set(0.5, 0); worker4LevelTxt.x = workerImg.x; worker4LevelTxt.y = workerLabel.y + 24; worker4LevelTxt.visible = false; game.addChild(worker4LevelTxt); var earning = Math.round(worker4BaseEarning * Math.pow(1.25, worker4Level - 1)); worker4EarningTxt = new Text2('Resmime Tıkla', { size: 26, fill: '#bff' }); worker4EarningTxt.anchor.set(0.5, 0); worker4EarningTxt.x = workerImg.x; worker4EarningTxt.y = worker4LevelTxt.y + 22; worker4EarningTxt.visible = false; game.addChild(worker4EarningTxt); // Sadece ilk tıklamada 'Tıkla: ₺...' yazısı gösterilsin var worker4FirstClickDone = false; worker4UpgradeBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 140, //{lj} // buton genişliği büyütüldü height: 64, //{lk} // buton yüksekliği büyütüldü x: workerImg.x, y: worker4EarningTxt.y + 54 }); worker4UpgradeBtn.visible = false; game.addChild(worker4UpgradeBtn); worker4UpgradeBtnTxt = new Text2('Yükselt\n₺' + worker4UpgradeCost, { size: 28, //{ln} // yazı boyutu büyütüldü fill: '#fff' }); worker4UpgradeBtnTxt.anchor.set(0.5, 0.5); worker4UpgradeBtnTxt.x = worker4UpgradeBtn.x; worker4UpgradeBtnTxt.y = worker4UpgradeBtn.y; worker4UpgradeBtnTxt.visible = false; game.addChild(worker4UpgradeBtnTxt); workerImg.down = function (x, y, obj) { if (yatirimPanel && yatirimPanel.visible) return; var earning = Math.round(worker4BaseEarning * Math.pow(1.25, worker4Level - 1)); money += earning; updateMoneyText && updateMoneyText(); tween(workerImg, { scaleX: 1.12, scaleY: 1.12 }, { duration: 80, onFinish: function onFinish() { tween(workerImg, { scaleX: 1, scaleY: 1 }, { duration: 80 }); } }); if (worker4EarningTxt && !worker4FirstClickDone) { worker4EarningTxt.setText('Tıkla: ₺' + earning); worker4FirstClickDone = true; } }; worker4UpgradeBtn.down = function (x, y, obj) { if (yatirimPanel && yatirimPanel.visible) return; if (money >= worker4UpgradeCost) { money -= worker4UpgradeCost; worker4Level += 1; worker4UpgradeCost = Math.floor(worker4UpgradeCost * 2.5); updateMoneyText && updateMoneyText(); worker4LevelTxt.setText('Seviye: ' + worker4Level); var earning = Math.round(worker4BaseEarning * Math.pow(1.25, worker4Level - 1)); worker4EarningTxt.setText('Tıkla: ₺' + earning); worker4UpgradeBtnTxt.setText('Yükselt\n₺' + worker4UpgradeCost); tween(worker4UpgradeBtn, { scaleX: 1.12, scaleY: 1.12 }, { duration: 80, onFinish: function onFinish() { tween(worker4UpgradeBtn, { scaleX: 1, scaleY: 1 }, { duration: 80 }); } }); } else { tween(worker4UpgradeBtn, { tint: 0xff2222 }, { duration: 120, onFinish: function onFinish() { tween(worker4UpgradeBtn, { tint: 0x222222 }, { duration: 120 }); } }); } }; } // Çalışan 5 için seviye, bonus ve yükseltme butonu ekle if (i === 4) { worker5LevelTxt = new Text2('Seviye: ' + worker5Level, { size: 26, fill: '#ffb' }); worker5LevelTxt.anchor.set(0.5, 0); worker5LevelTxt.x = workerImg.x; worker5LevelTxt.y = workerLabel.y + 24; worker5LevelTxt.visible = false; game.addChild(worker5LevelTxt); var bonusPercent = Math.round(worker5BaseBonus * worker5Level * 100); worker5BonusTxt = new Text2('Tüm Kazanç: +%' + bonusPercent, { size: 26, fill: '#bff' }); worker5BonusTxt.anchor.set(0.5, 0); worker5BonusTxt.x = workerImg.x; worker5BonusTxt.y = worker5LevelTxt.y + 22; worker5BonusTxt.visible = false; game.addChild(worker5BonusTxt); worker5UpgradeBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 140, //{mv} // buton genişliği büyütüldü height: 64, //{mw} // buton yüksekliği büyütüldü x: workerImg.x, y: worker5BonusTxt.y + 54 }); worker5UpgradeBtn.visible = false; game.addChild(worker5UpgradeBtn); worker5UpgradeBtnTxt = new Text2('Yükselt\n₺' + worker5UpgradeCost, { size: 28, //{mz} // yazı boyutu büyütüldü fill: '#fff' }); worker5UpgradeBtnTxt.anchor.set(0.5, 0.5); worker5UpgradeBtnTxt.x = worker5UpgradeBtn.x; worker5UpgradeBtnTxt.y = worker5UpgradeBtn.y; worker5UpgradeBtnTxt.visible = false; game.addChild(worker5UpgradeBtnTxt); worker5UpgradeBtn.down = function (x, y, obj) { if (yatirimPanel && yatirimPanel.visible) return; if (money >= worker5UpgradeCost) { money -= worker5UpgradeCost; worker5Level += 1; worker5UpgradeCost = Math.floor(worker5UpgradeCost * 2.5); updateMoneyText && updateMoneyText(); worker5LevelTxt.setText('Seviye: ' + worker5Level); var bonusPercent = Math.round(worker5BaseBonus * worker5Level * 100); worker5BonusTxt.setText('Tüm Kazanç: +%' + bonusPercent); worker5UpgradeBtnTxt.setText('Yükselt\n₺' + worker5UpgradeCost); tween(worker5UpgradeBtn, { scaleX: 1.12, scaleY: 1.12 }, { duration: 80, onFinish: function onFinish() { tween(worker5UpgradeBtn, { scaleX: 1, scaleY: 1 }, { duration: 80 }); } }); } else { tween(worker5UpgradeBtn, { tint: 0xff2222 }, { duration: 120, onFinish: function onFinish() { tween(worker5UpgradeBtn, { tint: 0x222222 }, { duration: 120 }); } }); } }; } workerImages.push({ img: workerImg, label: workerLabel }); } // Çalışan 1 kazancını her 10 saniyede bir ekle LK.setInterval(function () { var earning = Math.round(worker1EarningBase * Math.pow(1.02, worker1Level - 1)); money += earning; updateMoneyText && updateMoneyText(); if (worker1EarningTxt) { worker1EarningTxt.setText('Kazanç: ₺' + earning); } }, 600); // 10 saniye (60fps * 10) // Panel açıldığında çalışanları göster newPageBtn.down = function (x, y, obj) { newPagePanel.visible = true; newPagePanelTitle.visible = true; newPagePanelText.visible = true; newPageKapatBtn.visible = true; newPageKapatBtnTxt.visible = true; // Çalışanları ve altındaki UI'ları göster ve panelde 3'lü sıra halinde alt alta ortala for (var i = 0; i < workerImages.length; i++) { var pos = getWorkerPanelPos(i); workerImages[i].img.x = pos.x; workerImages[i].img.y = pos.y; workerImages[i].img.visible = true; workerImages[i].label.x = pos.x; workerImages[i].label.y = pos.y + 80; workerImages[i].label.visible = true; // Alt açıklama yazılarını alt alta ve hizalı şekilde göster var baseY = workerImages[i].label.y + workerImages[i].label.height + 8; // label'ın altından 8px boşluk var lineGap = 8; // satırlar arası boşluk if (i === 0) { var y = baseY; if (worker1LevelTxt) { worker1LevelTxt.x = pos.x; worker1LevelTxt.y = y; worker1LevelTxt.visible = true; y += worker1LevelTxt.height + lineGap; } if (worker1EarningTxt) { worker1EarningTxt.x = pos.x; worker1EarningTxt.y = y; worker1EarningTxt.visible = true; y += worker1EarningTxt.height + lineGap; } if (worker1UpgradeBtn) { worker1UpgradeBtn.x = pos.x; worker1UpgradeBtn.y = y + worker1UpgradeBtn.height / 2; worker1UpgradeBtn.visible = true; } if (worker1UpgradeBtnTxt) { worker1UpgradeBtnTxt.x = pos.x; worker1UpgradeBtnTxt.y = worker1UpgradeBtn.y; worker1UpgradeBtnTxt.visible = true; } } if (i === 1) { var y = baseY; if (worker2LevelTxt) { worker2LevelTxt.x = pos.x; worker2LevelTxt.y = y; worker2LevelTxt.visible = true; y += worker2LevelTxt.height + lineGap; } if (worker2SpeedTxt) { worker2SpeedTxt.x = pos.x; worker2SpeedTxt.y = y; worker2SpeedTxt.visible = true; y += worker2SpeedTxt.height + lineGap; } if (worker2UpgradeBtn) { worker2UpgradeBtn.x = pos.x; worker2UpgradeBtn.y = y + worker2UpgradeBtn.height / 2; worker2UpgradeBtn.visible = true; } if (worker2UpgradeBtnTxt) { worker2UpgradeBtnTxt.x = pos.x; worker2UpgradeBtnTxt.y = worker2UpgradeBtn.y; worker2UpgradeBtnTxt.visible = true; } } if (i === 2) { var y = baseY; if (worker3LevelTxt) { worker3LevelTxt.x = pos.x; worker3LevelTxt.y = y; worker3LevelTxt.visible = true; y += worker3LevelTxt.height + lineGap; } if (worker3DiscountTxt) { worker3DiscountTxt.x = pos.x; worker3DiscountTxt.y = y; worker3DiscountTxt.visible = true; y += worker3DiscountTxt.height + lineGap; } if (worker3UpgradeBtn) { worker3UpgradeBtn.x = pos.x; worker3UpgradeBtn.y = y + worker3UpgradeBtn.height / 2; worker3UpgradeBtn.visible = true; } if (worker3UpgradeBtnTxt) { worker3UpgradeBtnTxt.x = pos.x; worker3UpgradeBtnTxt.y = worker3UpgradeBtn.y; worker3UpgradeBtnTxt.visible = true; } } if (i === 3) { var y = baseY; if (worker4LevelTxt) { worker4LevelTxt.x = pos.x; worker4LevelTxt.y = y; worker4LevelTxt.visible = true; y += worker4LevelTxt.height + lineGap; } if (worker4EarningTxt) { worker4EarningTxt.x = pos.x; worker4EarningTxt.y = y; worker4EarningTxt.visible = true; y += worker4EarningTxt.height + lineGap; } if (worker4UpgradeBtn) { worker4UpgradeBtn.x = pos.x; worker4UpgradeBtn.y = y + worker4UpgradeBtn.height / 2; worker4UpgradeBtn.visible = true; } if (worker4UpgradeBtnTxt) { worker4UpgradeBtnTxt.x = pos.x; worker4UpgradeBtnTxt.y = worker4UpgradeBtn.y; worker4UpgradeBtnTxt.visible = true; } } if (i === 4) { var y = baseY; if (worker5LevelTxt) { worker5LevelTxt.x = pos.x; worker5LevelTxt.y = y; worker5LevelTxt.visible = true; y += worker5LevelTxt.height + lineGap; } if (worker5BonusTxt) { worker5BonusTxt.x = pos.x; worker5BonusTxt.y = y; worker5BonusTxt.visible = true; y += worker5BonusTxt.height + lineGap; } if (worker5UpgradeBtn) { worker5UpgradeBtn.x = pos.x; worker5UpgradeBtn.y = y + worker5UpgradeBtn.height / 2; worker5UpgradeBtn.visible = true; } if (worker5UpgradeBtnTxt) { worker5UpgradeBtnTxt.x = pos.x; worker5UpgradeBtnTxt.y = worker5UpgradeBtn.y; worker5UpgradeBtnTxt.visible = true; } } } // Paneli en öne getir if (game.setChildIndex) { game.setChildIndex(newPagePanel, game.children.length - 1); game.setChildIndex(newPagePanelTitle, game.children.length - 1); game.setChildIndex(newPagePanelText, game.children.length - 1); game.setChildIndex(newPageKapatBtn, game.children.length - 1); game.setChildIndex(newPageKapatBtnTxt, game.children.length - 1); // Çalışanları ve altındaki UI'ları en öne getir for (var i = 0; i < workerImages.length; i++) { game.setChildIndex(workerImages[i].img, game.children.length - 1); game.setChildIndex(workerImages[i].label, game.children.length - 1); } if (worker1LevelTxt) game.setChildIndex(worker1LevelTxt, game.children.length - 1); if (worker1EarningTxt) game.setChildIndex(worker1EarningTxt, game.children.length - 1); if (worker1UpgradeBtn) game.setChildIndex(worker1UpgradeBtn, game.children.length - 1); if (worker1UpgradeBtnTxt) game.setChildIndex(worker1UpgradeBtnTxt, game.children.length - 1); if (worker2LevelTxt) game.setChildIndex(worker2LevelTxt, game.children.length - 1); if (worker2SpeedTxt) game.setChildIndex(worker2SpeedTxt, game.children.length - 1); if (worker2UpgradeBtn) game.setChildIndex(worker2UpgradeBtn, game.children.length - 1); if (worker2UpgradeBtnTxt) game.setChildIndex(worker2UpgradeBtnTxt, game.children.length - 1); if (worker3LevelTxt) game.setChildIndex(worker3LevelTxt, game.children.length - 1); if (worker3DiscountTxt) game.setChildIndex(worker3DiscountTxt, game.children.length - 1); if (worker3UpgradeBtn) game.setChildIndex(worker3UpgradeBtn, game.children.length - 1); if (worker3UpgradeBtnTxt) game.setChildIndex(worker3UpgradeBtnTxt, game.children.length - 1); if (worker4LevelTxt) game.setChildIndex(worker4LevelTxt, game.children.length - 1); if (worker4EarningTxt) game.setChildIndex(worker4EarningTxt, game.children.length - 1); if (worker4UpgradeBtn) game.setChildIndex(worker4UpgradeBtn, game.children.length - 1); if (worker4UpgradeBtnTxt) game.setChildIndex(worker4UpgradeBtnTxt, game.children.length - 1); if (worker5LevelTxt) game.setChildIndex(worker5LevelTxt, game.children.length - 1); if (worker5BonusTxt) game.setChildIndex(worker5BonusTxt, game.children.length - 1); if (worker5UpgradeBtn) game.setChildIndex(worker5UpgradeBtn, game.children.length - 1); if (worker5UpgradeBtnTxt) game.setChildIndex(worker5UpgradeBtnTxt, game.children.length - 1); } }; // Paneli kapatınca çalışanları gizle newPageKapatBtn.down = function (x, y, obj) { newPagePanel.visible = false; newPagePanelTitle.visible = false; newPagePanelText.visible = false; newPageKapatBtn.visible = false; newPageKapatBtnTxt.visible = false; // Çalışanları ve altındaki UI'ları gizle for (var i = 0; i < workerImages.length; i++) { workerImages[i].img.visible = false; workerImages[i].label.visible = false; } if (worker1LevelTxt) worker1LevelTxt.visible = false; if (worker1EarningTxt) worker1EarningTxt.visible = false; if (worker1UpgradeBtn) worker1UpgradeBtn.visible = false; if (worker1UpgradeBtnTxt) worker1UpgradeBtnTxt.visible = false; if (worker2LevelTxt) worker2LevelTxt.visible = false; if (worker2SpeedTxt) worker2SpeedTxt.visible = false; if (worker2UpgradeBtn) worker2UpgradeBtn.visible = false; if (worker2UpgradeBtnTxt) worker2UpgradeBtnTxt.visible = false; if (worker3LevelTxt) worker3LevelTxt.visible = false; if (worker3DiscountTxt) worker3DiscountTxt.visible = false; if (worker3UpgradeBtn) worker3UpgradeBtn.visible = false; if (worker3UpgradeBtnTxt) worker3UpgradeBtnTxt.visible = false; if (worker4LevelTxt) worker4LevelTxt.visible = false; if (worker4EarningTxt) worker4EarningTxt.visible = false; if (worker4UpgradeBtn) worker4UpgradeBtn.visible = false; if (worker4UpgradeBtnTxt) worker4UpgradeBtnTxt.visible = false; if (worker5LevelTxt) worker5LevelTxt.visible = false; if (worker5BonusTxt) worker5BonusTxt.visible = false; if (worker5UpgradeBtn) worker5UpgradeBtn.visible = false; if (worker5UpgradeBtnTxt) worker5UpgradeBtnTxt.visible = false; }; // --- Mines --- var mines = []; var mineAutoProduce = [false, false, false]; // Track auto-produce state for each mine var mineAutoBtns = []; var mineAutoTxts = []; for (var i = 0; i < 3; i++) { var mine = new Mine(); mine.x = 300 + i * 350; mine.y = 600; mine.setType(oreTypes[i]); game.addChild(mine); mines.push(mine); // Add auto-produce toggle button var autoBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5 }); // Oto üret butonunu ÜRET butonunun altına yerleştir autoBtn.x = mine.x - 170; // ÜRET butonuyla aynı hizada autoBtn.y = mine.y + 320 + 100; // ÜRET butonunun 100px altı game.addChild(autoBtn); var autoMineCost = (i + 1) * 500; // 500, 1000, 1500 for each mine var autoTxt = new Text2('Oto Üret: Kapalı', { size: 36, fill: '#fff' }); autoTxt.anchor.set(0.5, 0.5); autoTxt.x = autoBtn.x; autoTxt.y = autoBtn.y; game.addChild(autoTxt); autoBtn.mineIndex = i; autoBtn.down = function (x, y, obj) { // Disable if investment panel is open if (yatirimPanel && yatirimPanel.visible) return; var idx = this.mineIndex; var autoMineCost = (idx + 1) * 500; if (!mineAutoProduce[idx]) { if (money >= autoMineCost) { money -= autoMineCost; updateMoneyText(); mineAutoProduce[idx] = true; mineAutoTxts[idx].setText('Oto Üret: Açık'); } else { // Not enough money, flash button red tween(this, { tint: 0xff2222 }, { duration: 120, onFinish: function onFinish() { tween(autoBtn, { tint: 0x222222 }, { duration: 120 }); } }); } } else { // Oto Üret kapatılmasın: Satın alındıktan sonra kapatmaya izin verme // Artık kapatma işlemi yapılmıyor, buton işlevsiz. } }; mineAutoBtns.push(autoBtn); mineAutoTxts.push(autoTxt); // Set initial text autoTxt.setText('Oto Üret: Kapalı\n₺' + autoMineCost); } // --- Factories for each part --- var factories = []; var factoryUnlocks = []; var factoryUnlockCosts = [0, 350, 525, 700, 875, 1050, 1225, 1400, 1575, 1750]; // Apply 50% price increase to all except the first (CPU) for (var i = 1; i < factoryUnlockCosts.length; i++) { factoryUnlockCosts[i] = Math.floor(factoryUnlockCosts[i] * 1.5); } var factoryAutoProduce = []; var factoryAutoBtns = []; var factoryAutoTxts = []; for (var i = 0; i < partTypes.length; i++) { var FactoryClass = FactoryClasses[partTypes[i]]; var f = new FactoryClass(); // Arrange factories in two rows of 5, with extra vertical spacing between rows var col = i % 5; var row = Math.floor(i / 5); // Add vertical spacing (gap) between factory panels var factoryPanelGap = 24; f.x = 500 + col * 300 + col * factoryPanelGap; // Move MB, CASE, FAN, HDD, COOLER (indices 5,6,7,8,9) further down // Move the whole factories panel lower by +200px if (i >= 5) { // Increase the offset for the second row and move these factories further down f.y = 1300 + row * 420 + 320; } else { f.y = 1300 + row * 420; } game.addChild(f); factories.push(f); // Add production time text under the part icon var prodTime = f.getProductionTime ? f.getProductionTime() : 30; var prodTimeSec = (prodTime / 60).toFixed(2); // Add a panel image behind the production time text var prodTimePanel = LK.getAsset('button', { anchorX: 0.5, anchorY: 0, width: 220, height: 54, x: f.x, y: f.y - 60 + 60 * 0.7 + 28, // 10px higher to allow for text padding scaleX: 0.8, scaleY: 0.7 }); // Add horizontal gap to prodTimePanel to match factory panel gap prodTimePanel.x = f.x; game.addChild(prodTimePanel); var prodTimeTxt = new Text2("Üretim: " + prodTimeSec + " sn", { size: 32, fill: "#fff" }); prodTimeTxt.anchor.set(0.5, 0); // Place under the part icon (which is at y: -60, scale 0.7, so about -60+60*0.7+10) prodTimeTxt.x = f.x; prodTimeTxt.y = f.y - 60 + 60 * 0.7 + 38; game.addChild(prodTimeTxt); // Store reference for later update on upgrade f._prodTimeTxt = prodTimeTxt; // Unlock state: CPU (i==0) is always unlocked, others locked factoryUnlocks.push(i === 0 ? true : false); // Add auto-produce toggle button for each factory factoryAutoProduce.push(false); var autoBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5 }); autoBtn.x = f.x; // Move auto-produce button further down // Add horizontal gap to autoBtn to match factory panel gap autoBtn.x = f.x; if (i >= 5) { autoBtn.y = f.y + 530 + 80; } else { autoBtn.y = f.y + 530; } game.addChild(autoBtn); var autoTxt = new Text2('Oto Üret: Kapalı', { size: 36, fill: '#fff' }); autoTxt.anchor.set(0.5, 0.5); autoTxt.x = autoBtn.x; autoTxt.y = autoBtn.y; game.addChild(autoTxt); autoBtn.factoryIndex = i; autoBtn.down = function (x, y, obj) { // Disable if investment panel is open if (yatirimPanel && yatirimPanel.visible) return; var idx = this.factoryIndex; if (!factoryAutoProduce[idx]) { // Cost to enable auto-produce for factory: 1000 var autoFactoryCost = (idx + 1) * 1000; if (money >= autoFactoryCost) { money -= autoFactoryCost; updateMoneyText(); factoryAutoProduce[idx] = true; factoryAutoTxts[idx].setText('Oto Üret: Açık'); } else { // Not enough money, flash button red tween(this, { tint: 0xff2222 }, { duration: 120, onFinish: function onFinish() { tween(autoBtn, { tint: 0x222222 }, { duration: 120 }); } }); } } else { // Oto Üret kapatılmasın: Satın alındıktan sonra kapatmaya izin verme // Artık kapatma işlemi yapılmıyor, buton işlevsiz. } }; factoryAutoBtns.push(autoBtn); factoryAutoTxts.push(autoTxt); // Set initial text var autoFactoryCost = (i + 1) * 1000; autoTxt.setText('Oto Üret: Kapalı\n₺' + autoFactoryCost); } // --- Store --- var store = new Store(); store.x = 1850; // 1780'den 1850'ye sağa kaydırıldı store.y = 600; // Mağaza resmini biraz küçült store.scaleX = 0.82; store.scaleY = 0.82; game.addChild(store); // --- Store 2 --- var store2 = new Store(); store2.x = store.x; store2.y = store.y + 350; // Mağaza'nın altına yerleştir // Mağaza 2 resmini de biraz küçült store2.scaleX = 0.82; store2.scaleY = 0.82; game.addChild(store2); // --- Upgrade Buttons --- var mineBtns = []; for (var i = 0; i < 3; i++) { var btn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5 }); btn.x = mines[i].x - 80; // Move left to make space for produce button btn.y = mines[i].y + 200; game.addChild(btn); var txt = new Text2('Maden Yükselt\n₺' + mines[i].upgradeCost, { size: 44, fill: '#fff' }); txt.anchor.set(0.5, 0.5); txt.y = btn.y + 20; txt.x = btn.x; game.addChild(txt); btn.mineIndex = i; btn.txt = txt; btn.down = function (x, y, obj) { // Disable if investment panel is open if (yatirimPanel && yatirimPanel.visible) return; var idx = this.mineIndex; var m = mines[idx]; if (money >= m.upgradeCost) { toplamMadenYukseltme += m.upgradeCost; m.upgrade(); this.txt.setText('Maden Yükselt\n₺' + m.upgradeCost); } }; mineBtns.push(btn); // Add ÜRET (Produce) button next to upgrade var prodBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 180, height: 80 }); // ÜRET butonunu madenin altına yerleştir prodBtn.x = mines[i].x - 170; prodBtn.y = mines[i].y + 320; game.addChild(prodBtn); var prodTxt = new Text2('ÜRET', { size: 36, fill: '#fff' }); prodTxt.anchor.set(0.5, 0.5); // ÜRET yazısını butonun tam ortasına yerleştir prodTxt.x = prodBtn.x; prodTxt.y = prodBtn.y; game.addChild(prodTxt); prodBtn.mineIndex = i; prodBtn.down = function (x, y, obj) { // Disable if investment panel is open if (yatirimPanel && yatirimPanel.visible) return; var idx = this.mineIndex; var m = mines[idx]; // Instantly produce one batch of raw material for this mine rawMaterials[m.type] += m.production; updateRawText(); // Animate mine for feedback tween(m, { scaleX: 1.1, scaleY: 1.1 }, { duration: 120, easing: tween.easeOut, onFinish: function onFinish() { tween(m, { scaleX: 1, scaleY: 1 }, { duration: 120 }); } }); }; } // Factory upgrade buttons for each part var factoryBtns = []; var factoryUnlockBtns = []; for (var i = 0; i < factories.length; i++) { var f = factories[i]; // If factory is locked (except CPU), show unlock button instead of upgrade if (!factoryUnlocks[i]) { var unlockBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5 }); unlockBtn.x = f.x; // Add horizontal gap to unlock buttons to match factory panel gap unlockBtn.x = f.x; if (i >= 5) { unlockBtn.y = f.y + 200 + 80; } else { unlockBtn.y = f.y + 200; } game.addChild(unlockBtn); var unlockTxt = new Text2((i === 0 ? "MOUSE" : partTypes[i].toUpperCase()) + " Aç\n₺" + factoryUnlockCosts[i], { size: 44, fill: '#fff' }); unlockTxt.anchor.set(0.5, 0.5); unlockTxt.x = unlockBtn.x; unlockTxt.y = unlockBtn.y + 20; game.addChild(unlockTxt); unlockBtn.factoryIndex = i; unlockBtn.txt = unlockTxt; unlockBtn.down = function (x, y, obj) { // Disable if investment panel is open if (yatirimPanel && yatirimPanel.visible) return; var idx = this.factoryIndex; if (!factoryUnlocks[idx] && money >= factoryUnlockCosts[idx]) { money -= factoryUnlockCosts[idx]; updateMoneyText(); factoryUnlocks[idx] = true; // Remove unlock button and text this.destroy(); this.txt.destroy(); // Show upgrade button for this factory showFactoryUpgradeButton(idx); } }; factoryUnlockBtns.push(unlockBtn); // Don't show upgrade button for locked factories continue; } // Show upgrade button for unlocked factories var btn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5 }); btn.x = f.x; // Add horizontal gap to upgrade/unlock/production buttons to match factory panel gap btn.x = f.x; // Move MB, CASE, FAN, HDD, COOLER (indices 5,6,7,8,9) buttons further down if (i >= 5) { btn.y = f.y + 200 + 80; } else { btn.y = f.y + 200; } game.addChild(btn); var txt = new Text2((i === 0 ? "MOUSE" : partTypes[i].toUpperCase()) + " Yükselt\n₺" + f.upgradeCost, { size: 44, fill: '#fff' }); txt.anchor.set(0.5, 0.5); txt.x = btn.x; txt.y = btn.y + 20; game.addChild(txt); btn.factoryIndex = i; btn.txt = txt; btn.down = function (x, y, obj) { // Disable if investment panel is open if (yatirimPanel && yatirimPanel.visible) return; var idx = this.factoryIndex; var f = factories[idx]; // Çalışan 3 indirimini uygula var discount = 1 - (worker3Level - 1) * 0.02; if (discount < 0.1) discount = 0.1; // Maksimum %90 indirim var discountedCost = Math.floor(f.upgradeCost * discount); if (money >= discountedCost) { toplamFabrikaYukseltme += discountedCost; money -= discountedCost; f.upgrade(); updateMoneyText && updateMoneyText(); this.txt.setText((idx === 0 ? "MOUSE" : partTypes[idx].toUpperCase()) + " Yükselt\n₺" + f.upgradeCost); } }; factoryBtns.push(btn); } // Helper to show upgrade button after unlock function showFactoryUpgradeButton(idx) { var f = factories[idx]; var btn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5 }); btn.x = f.x; // Add horizontal gap to upgrade button after unlock to match factory panel gap btn.x = f.x; if (idx >= 5) { btn.y = f.y + 200 + 80; } else { btn.y = f.y + 200; } game.addChild(btn); var txt = new Text2((idx === 0 ? "MOUSE" : partTypes[idx].toUpperCase()) + " Yükselt\n₺" + f.upgradeCost, { size: 44, fill: '#fff' }); txt.anchor.set(0.5, 0.5); txt.x = btn.x; txt.y = btn.y + 20; game.addChild(txt); btn.factoryIndex = idx; btn.txt = txt; btn.down = function (x, y, obj) { // Disable if investment panel is open if (yatirimPanel && yatirimPanel.visible) return; var idx = this.factoryIndex; var f = factories[idx]; // Çalışan 3 indirimini uygula var discount = 1 - (worker3Level - 1) * 0.02; if (discount < 0.1) discount = 0.1; // Maksimum %90 indirim var discountedCost = Math.floor(f.upgradeCost * discount); if (money >= discountedCost) { money -= discountedCost; f.upgrade(); updateMoneyText && updateMoneyText(); this.txt.setText((idx === 0 ? "MOUSE" : partTypes[idx].toUpperCase()) + " Yükselt\n₺" + f.upgradeCost); } }; factoryBtns[idx] = btn; } // Store upgrade button var storeBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5 }); storeBtn.x = store.x; storeBtn.y = store.y + 160; // 40px yukarı kaldırıldı game.addChild(storeBtn); var storeBtnTxt = new Text2('Mağaza Yükselt\n₺' + store.upgradeCost, { size: 44, fill: '#fff' }); storeBtnTxt.anchor.set(0.5, 0.5); storeBtnTxt.x = storeBtn.x; storeBtnTxt.y = storeBtn.y + 20; game.addChild(storeBtnTxt); storeBtn.down = function (x, y, obj) { if (money >= store.upgradeCost) { toplamStoreYukseltme += store.upgradeCost; store.upgrade(); storeBtnTxt.setText('Mağaza Yükselt\n₺' + store.upgradeCost); } }; // --- Store 2 Upgrade Button --- var store2Btn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5 }); store2Btn.x = store2.x; store2Btn.y = store2.y + 160; // 40px yukarı kaldırıldı game.addChild(store2Btn); var store2BtnTxt = new Text2('Mağaza 2 Yükselt\n₺' + store2.upgradeCost, { size: 44, fill: '#fff' }); store2BtnTxt.anchor.set(0.5, 0.5); store2BtnTxt.x = store2Btn.x; store2BtnTxt.y = store2Btn.y + 20; game.addChild(store2BtnTxt); store2Btn.down = function (x, y, obj) { if (money >= store2.upgradeCost) { toplamStoreYukseltme += store2.upgradeCost; store2.upgrade(); store2BtnTxt.setText('Mağaza 2 Yükselt\n₺' + store2.upgradeCost); } }; // --- Production Buttons and Logic for each factory --- var prodBtns = []; for (var i = 0; i < factories.length; i++) { (function (idx) { var f = factories[idx]; var btn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5 }); btn.x = f.x; // Add horizontal gap to production buttons to match factory panel gap btn.x = f.x; // Move MB, CASE, FAN, HDD, COOLER (indices 5,6,7,8,9) production buttons further down if (idx >= 5) { btn.y = f.y + 350 + 80; } else { btn.y = f.y + 350; } game.addChild(btn); var txt = new Text2('ÜRET', { size: 36, fill: '#fff' }); txt.anchor.set(0.5, 0.5); txt.x = btn.x; txt.y = btn.y; game.addChild(txt); btn.factoryIndex = idx; btn.down = function (x, y, obj) { // Disable if investment panel is open if (yatirimPanel && yatirimPanel.visible) return; var idx = this.factoryIndex; // Only allow production if factory is unlocked if (!factoryUnlocks[idx]) { // Optionally, flash or shake to indicate locked tween(factories[idx], { scaleX: 1.15, scaleY: 1.15 }, { duration: 80, onFinish: function onFinish() { tween(factories[idx], { scaleX: 1, scaleY: 1 }, { duration: 80 }); } }); return; } var f = factories[idx]; var part = partTypes[idx]; var produced = 0; for (var j = 0; j < f.production; j++) { // Each part needs: copper:2, silicon:1, iron:1 // Calculate production cost as 50% of the sale price (which is 30~49, so use 40 as avg, or use 30 + Math.floor(Math.random()*20)/2 for dynamic) var salePrice = 30 + Math.floor(Math.random() * 20); var productionCost = Math.floor(salePrice * 0.5); if (rawMaterials.copper >= 2 && rawMaterials.silicon >= 1 && rawMaterials.iron >= 1 && money >= productionCost) { rawMaterials.copper -= 2; rawMaterials.silicon -= 1; rawMaterials.iron -= 1; money -= productionCost; updateMoneyText(); parts[part] += 1; produced++; } } if (produced > 0) { updateRawText(); updatePartsText(); // Animate factory tween(f, { scaleX: 1.1, scaleY: 1.1 }, { duration: 120, easing: tween.easeOut, onFinish: function onFinish() { tween(f, { scaleX: 1, scaleY: 1 }, { duration: 120 }); } }); } }; prodBtns.push(btn); })(i); } // --- Customer/Store Logic --- var customers = []; // Separate timers and intervals for each store var customerTimer1 = 0; var customerTimer2 = 0; // Each store can have its own interval (can be randomized for more variety) var customerInterval1 = 120; // 2s for store 1 var customerInterval2 = 120; // 2s for store 2 // Şehir görselini başlangıçta göster (müşteri gelmese bile) var cityImage = LK.getAsset('city', { anchorX: 0.5, anchorY: 0, width: 320, height: 480, x: store.x - 340, y: store.y + 120 - 120, scaleX: 0.92, scaleY: 0.92 }); game.addChild(cityImage); function spawnCustomerForStore(targetStore) { // Only allow customer for parts that have been produced at least once var availableParts = []; for (var i = 0; i < partTypes.length; i++) { if (parts[partTypes[i]] > 0) { availableParts.push(partTypes[i]); } } if (availableParts.length === 0) { // No available parts, do not spawn customer return; } // Şehir görselini sadece ilk müşteri spawn'ında ekle (veya her seferinde eklenebilir, ama bir kez eklemek daha iyi) // cityImage zaten başlangıçta eklendiği için burada tekrar eklemeye gerek yok var c = new Customer(); c.x = targetStore.x - 300; c.y = targetStore.y + 120; c.targetStore = targetStore; // Hedef mağazayı kaydet // Pick a random available part type to buy var idx = Math.floor(Math.random() * availableParts.length); var part = availableParts[idx]; c.setPart(part); c.partType = part; game.addChild(c); customers.push(c); // Animate customer moving to store (slower) tween(c, { x: targetStore.x }, { duration: 1200, // doubled duration for slower movement easing: tween.cubicOut }); } function processCustomers() { for (var i = customers.length - 1; i >= 0; i--) { var c = customers[i]; // Hedef mağazaya ulaştıysa satış yap var targetStore = c.targetStore || store; if (Math.abs(c.x - targetStore.x) < 10) { var part = c.partType; if (parts[part] > 0) { parts[part] -= 1; var price = 30 + Math.floor(Math.random() * 20); money += price; toplamMusteriSatisGeliri += price; updateMoneyText(); updatePartsText(); // Animate customer leaving (slower) tween(c, { x: targetStore.x + 300 }, { duration: 800, // doubled duration for slower movement onFinish: function onFinish() { c.destroy(); } }); customers.splice(i, 1); } } } } // --- Game Update --- game.update = function () { // Auto-produce for mines for (var i = 0; i < mines.length; i++) { mines[i].update(); // Auto-produce for mine if enabled if (mineAutoProduce[i]) { // Çalışan 2'nin seviyesiyle üretim süresini azalt: her seviye %2 daha hızlı var baseInterval = 30; // 0.5s var speedBonus = 1 - (worker2Level - 1) * 0.02; if (speedBonus < 0.1) speedBonus = 0.1; // min %90 azaltma (maks %900 hız) var interval = Math.max(2, Math.floor(baseInterval * speedBonus)); if (!mines[i].autoTick) { mines[i].autoTick = 0; } mines[i].autoTick++; if (mines[i].autoTick >= interval) { rawMaterials[mines[i].type] += mines[i].production; updateRawText(); // Animate mine for feedback tween(mines[i], { scaleX: 1.1, scaleY: 1.1 }, { duration: 120, easing: tween.easeOut, onFinish: function onFinish() { tween(this.target, { scaleX: 1, scaleY: 1 }, { duration: 120 }); }.bind({ target: mines[i] }) }); mines[i].autoTick = 0; } } } // Auto-produce for factories for (var i = 0; i < factories.length; i++) { if (factoryAutoProduce[i] && factoryUnlocks[i]) { if (!factories[i].autoTick) { factories[i].autoTick = 0; } factories[i].autoTick++; // Use per-factory production time (speed up with level) // Çalışan 2'nin seviyesiyle üretim süresi indirimi uygula var prodTime = factories[i].getProductionTime ? factories[i].getProductionTime() : 30; // Çalışan 2'nin seviyesiyle fabrika üretim süresi indirimi uygula var worker2FactoryBonus = 1 - (worker2Level - 1) * 0.02; if (worker2FactoryBonus < 0.1) worker2FactoryBonus = 0.1; // min %90 azaltma (maks %900 hız) prodTime = Math.max(2, Math.floor(prodTime * worker2FactoryBonus)); // Çalışan 2'nin seviyesiyle ek olarak üretim hızını %2 düşür (yani prodTime'ı tekrar %2 azalt) var worker2ExtraSpeedBonus = 1 - (worker2Level - 1) * 0.02; if (worker2ExtraSpeedBonus < 0.1) worker2ExtraSpeedBonus = 0.1; prodTime = Math.max(2, Math.floor(prodTime * worker2ExtraSpeedBonus)); if (factories[i].autoTick >= prodTime) { var f = factories[i]; var part = partTypes[i]; var produced = 0; // Çalışan 2'nin seviyesiyle üretim miktarını artır: her seviye %2 daha fazla üretim var worker2ProductionBonus = 1 + (worker2Level - 1) * 0.02; var totalProduction = Math.floor(f.production * worker2ProductionBonus); if (totalProduction < 1) totalProduction = 1; for (var j = 0; j < totalProduction; j++) { // Each part needs: copper:2, silicon:1, iron:1 // Calculate production cost as 50% of the sale price (which is 30~49, so use 40 as avg, or use 30 + Math.floor(Math.random()*20)/2 for dynamic) var salePrice = 30 + Math.floor(Math.random() * 20); var productionCost = Math.floor(salePrice * 0.5); if (rawMaterials.copper >= 2 && rawMaterials.silicon >= 1 && rawMaterials.iron >= 1 && money >= productionCost) { rawMaterials.copper -= 2; rawMaterials.silicon -= 1; rawMaterials.iron -= 1; money -= productionCost; updateMoneyText(); parts[part] += 1; produced++; } } if (produced > 0) { updateRawText(); updatePartsText(); // Animate factory tween(f, { scaleX: 1.1, scaleY: 1.1 }, { duration: 120, easing: tween.easeOut, onFinish: function onFinish() { tween(this.target, { scaleX: 1, scaleY: 1 }, { duration: 120 }); }.bind({ target: f }) }); } factories[i].autoTick = 0; } } } // Customer spawn logic for both stores independently customerTimer1++; customerTimer2++; // Store 1 if (customerTimer1 >= customerInterval1 / store.sellSpeed) { customerTimer1 = 0; spawnCustomerForStore(store); } // Store 2 if (customerTimer2 >= customerInterval2 / store2.sellSpeed) { customerTimer2 = 0; spawnCustomerForStore(store2); } processCustomers(); }; // --- Dragging (for fun, not required) --- var dragNode = null; game.down = function (x, y, obj) { // No drag for now }; game.move = function (x, y, obj) { // No drag for now }; game.up = function (x, y, obj) { // No drag for now }; // --- Internet Offer Panel --- // Panel variables var offerPanel = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 420, height: 340, x: 120, y: 1366 // center of 2732 }); game.addChild(offerPanel); var offerTitle = new Text2('İNTERNET TEKLİFİ', { size: 32, fill: '#fff' }); // Move to right edge of panel offerTitle.anchor.set(1, 0); offerTitle.x = offerPanel.x + offerPanel.width / 2 - 20; offerTitle.y = offerPanel.y - 140; game.addChild(offerTitle); var offerPartTxt = new Text2('', { size: 28, fill: '#bff' }); offerPartTxt.anchor.set(0.5, 0); offerPartTxt.x = offerPanel.x; offerPartTxt.y = offerPanel.y - 60; game.addChild(offerPartTxt); var offerAmountTxt = new Text2('', { size: 28, fill: '#fff' }); offerAmountTxt.anchor.set(0.5, 0); offerAmountTxt.x = offerPanel.x; offerAmountTxt.y = offerPanel.y - 10; game.addChild(offerAmountTxt); var offerPriceTxt = new Text2('', { size: 28, fill: '#ffb' }); offerPriceTxt.anchor.set(0.5, 0); offerPriceTxt.x = offerPanel.x; offerPriceTxt.y = offerPanel.y + 40; game.addChild(offerPriceTxt); var offerBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 220, height: 70, x: offerPanel.x, y: offerPanel.y + 180 // moved 30px lower (was 150), now 180 }); game.addChild(offerBtn); var offerBtnTxt = new Text2('Satın Al', { size: 36, fill: '#fff' }); offerBtnTxt.anchor.set(0.5, 0.5); offerBtnTxt.x = offerBtn.x; offerBtnTxt.y = offerBtn.y; game.addChild(offerBtnTxt); // Offer state var currentOffer = { part: null, amount: 0, price: 0, active: false // yeni teklif aktif mi }; // Helper to generate a new offer var offerTimeLeft = 0; var offerTimerInterval = null; var offerTimeTxt = new Text2('', { size: 32, fill: '#ffb' }); offerTimeTxt.anchor.set(0.5, 0); offerTimeTxt.x = offerPanel.x; offerTimeTxt.y = offerPanel.y + 90; game.addChild(offerTimeTxt); function updateOfferTimeTxt() { if (offerTimeLeft > 0) { var min = Math.floor(offerTimeLeft / 60); var sec = offerTimeLeft % 60; var timeStr = min > 0 ? min + " dk " + (sec < 10 ? "0" : "") + sec + " sn" : sec + " sn"; offerTimeTxt.setText("Yeni teklif: " + timeStr); } else { offerTimeTxt.setText(''); } } function generateInternetOffer() { // Pick a random part type var idx = Math.floor(Math.random() * partTypes.length); var part = partTypes[idx]; // Random amount: 2-8 var amount = 2 + Math.floor(Math.random() * 7); // Random price per item: 18-32 var pricePer = 18 + Math.floor(Math.random() * 15); var totalPrice = pricePer * amount; currentOffer.part = part; currentOffer.amount = amount; currentOffer.price = totalPrice; currentOffer.active = true; // Update UI offerPartTxt.setText(idx === 0 ? "MOUSE" : part.toUpperCase()); offerAmountTxt.setText("Adet: " + amount); offerPriceTxt.setText("Toplam: ₺" + totalPrice); offerBtn.visible = true; offerBtnTxt.visible = true; // Rastgele 1-2 dakika (60-120 saniye) arası süre belirle offerTimeLeft = (60 + Math.floor(Math.random() * 61)) * 60; updateOfferTimeTxt(); // Start timer for next offer if (offerTimerInterval) { LK.clearInterval(offerTimerInterval); offerTimerInterval = null; } offerTimerInterval = LK.setInterval(function () { if (!currentOffer.active) { LK.clearInterval(offerTimerInterval); offerTimerInterval = null; return; } offerTimeLeft--; updateOfferTimeTxt(); if (offerTimeLeft <= 0) { // Süre doldu, yeni teklif gelsin currentOffer.active = false; offerBtn.visible = false; offerBtnTxt.visible = false; offerPartTxt.setText("Süre doldu!"); offerAmountTxt.setText(""); offerPriceTxt.setText(""); updateOfferTimeTxt(); LK.clearInterval(offerTimerInterval); offerTimerInterval = null; LK.setTimeout(function () { generateInternetOffer(); }, 60); // 1 frame sonra yeni teklif gelsin } }, 60); // 1 saniye } generateInternetOffer(); // Button logic offerBtn.down = function (x, y, obj) { if (!currentOffer.active) return; if (money >= currentOffer.price) { money -= currentOffer.price; toplamInternetTeklifHarcamasi += currentOffer.price; parts[currentOffer.part] += currentOffer.amount; updateMoneyText(); updatePartsText(); // Animate panel for feedback tween(offerPanel, { scaleX: 1.08, scaleY: 1.08 }, { duration: 120, onFinish: function onFinish() { tween(offerPanel, { scaleX: 1, scaleY: 1 }, { duration: 120 }); } }); // Teklif tamamlandı, yeni teklif gelene kadar butonu kapat currentOffer.active = false; offerBtn.visible = false; offerBtnTxt.visible = false; offerPartTxt.setText("Teklif tamamlandı!"); offerAmountTxt.setText(""); offerPriceTxt.setText(""); offerTimeLeft = 1200; updateOfferTimeTxt(); if (offerTimerInterval) { LK.clearInterval(offerTimerInterval); offerTimerInterval = null; } // Yeni teklif rastgele 1-2 dakika sonra gelsin var nextOfferDelay = (60 + Math.floor(Math.random() * 61)) * 60; LK.setTimeout(function () { generateInternetOffer(); }, nextOfferDelay); } else { // Not enough money, flash button red tween(offerBtn, { tint: 0xff2222 }, { duration: 120, onFinish: function onFinish() { tween(offerBtn, { tint: 0x222222 }, { duration: 120 }); } }); } }; // --- Toplu Satış Paneli --- var sellPanel = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 420, height: 340, x: 120, y: 1366 + 400 // offerPanel.y + 400 px altına }); game.addChild(sellPanel); var sellTitle = new Text2('TOPLU SATIŞ TEKLİFİ', { size: 32, fill: '#fff' }); // Move to right edge of panel sellTitle.anchor.set(1, 0); sellTitle.x = sellPanel.x + sellPanel.width / 2 - 20; sellTitle.y = sellPanel.y - 140; game.addChild(sellTitle); var sellPartTxt = new Text2('', { size: 28, fill: '#bff' }); sellPartTxt.anchor.set(0.5, 0); sellPartTxt.x = sellPanel.x; sellPartTxt.y = sellPanel.y - 60; game.addChild(sellPartTxt); var sellAmountTxt = new Text2('', { size: 28, fill: '#fff' }); sellAmountTxt.anchor.set(0.5, 0); sellAmountTxt.x = sellPanel.x; sellAmountTxt.y = sellPanel.y - 10; game.addChild(sellAmountTxt); var sellPriceTxt = new Text2('', { size: 28, fill: '#ffb' }); sellPriceTxt.anchor.set(0.5, 0); sellPriceTxt.x = sellPanel.x; sellPriceTxt.y = sellPanel.y + 40; game.addChild(sellPriceTxt); var sellBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 220, height: 70, x: sellPanel.x, y: sellPanel.y + 180 // moved 30px lower (was 150), now 180 }); game.addChild(sellBtn); var sellBtnTxt = new Text2('Sat', { size: 36, fill: '#fff' }); sellBtnTxt.anchor.set(0.5, 0.5); sellBtnTxt.x = sellBtn.x; sellBtnTxt.y = sellBtn.y; game.addChild(sellBtnTxt); // Satış teklifi state var currentSellOffer = { part: null, amount: 0, price: 0, active: false }; // Helper to generate a new sell offer var sellOfferTimeLeft = 0; var sellOfferTimerInterval = null; var sellOfferTimeTxt = new Text2('', { size: 32, fill: '#ffb' }); sellOfferTimeTxt.anchor.set(0.5, 0); sellOfferTimeTxt.x = sellPanel.x; sellOfferTimeTxt.y = sellPanel.y + 90; game.addChild(sellOfferTimeTxt); function updateSellOfferTimeTxt() { if (sellOfferTimeLeft > 0) { var min = Math.floor(sellOfferTimeLeft / 60); var sec = sellOfferTimeLeft % 60; var timeStr = min > 0 ? min + " dk " + (sec < 10 ? "0" : "") + sec + " sn" : sec + " sn"; sellOfferTimeTxt.setText("Yeni teklif: " + timeStr); } else { sellOfferTimeTxt.setText(''); } } // Helper to generate a new sell offer function generateSellOffer() { // Sadece stoğunda en az 2 olanlardan rastgele seç var available = []; for (var i = 0; i < partTypes.length; i++) { if (parts[partTypes[i]] >= 2) available.push(partTypes[i]); } // Eğer hiç stoğu olan ürün yoksa, teklif oluşturma if (available.length === 0) { currentSellOffer.part = null; currentSellOffer.amount = 0; currentSellOffer.price = 0; currentSellOffer.active = false; sellPartTxt.setText("Stokta ürün yok"); sellAmountTxt.setText(""); sellPriceTxt.setText(""); sellBtn.visible = false; sellBtnTxt.visible = false; return; } var idx = Math.floor(Math.random() * available.length); var part = available[idx]; // Satış miktarı: mevcut stoğun %50-%75 aralığında, en az 2, en fazla 8 ve stoğun kendisinden fazla olamaz var stock = parts[part]; var minAmount = Math.max(2, Math.floor(stock * 0.5)); var maxAmount = Math.max(minAmount, Math.min(Math.floor(stock * 0.75), 8)); var amount = minAmount; if (maxAmount > minAmount) { amount = minAmount + Math.floor(Math.random() * (maxAmount - minAmount + 1)); } // Satış fiyatı: 28-45 arası birim fiyat var pricePer = 28 + Math.floor(Math.random() * 18); var totalPrice = pricePer * amount; currentSellOffer.part = part; currentSellOffer.amount = amount; currentSellOffer.price = totalPrice; currentSellOffer.active = true; sellPartTxt.setText(idx === 0 ? "MOUSE" : part.toUpperCase()); sellAmountTxt.setText("Adet: " + amount); sellPriceTxt.setText("Toplam: ₺" + totalPrice); sellBtn.visible = true; sellBtnTxt.visible = true; // Süreyi rastgele 1-2 dakika (60-120 saniye) arası belirle sellOfferTimeLeft = (60 + Math.floor(Math.random() * 61)) * 60; updateSellOfferTimeTxt(); // Timer varsa temizle if (sellOfferTimerInterval) { LK.clearInterval(sellOfferTimerInterval); sellOfferTimerInterval = null; } sellOfferTimerInterval = LK.setInterval(function () { if (!currentSellOffer.active) { LK.clearInterval(sellOfferTimerInterval); sellOfferTimerInterval = null; return; } sellOfferTimeLeft--; updateSellOfferTimeTxt(); if (sellOfferTimeLeft <= 0) { // Süre doldu, yeni teklif gelsin currentSellOffer.active = false; sellBtn.visible = false; sellBtnTxt.visible = false; sellPartTxt.setText("Süre doldu!"); sellAmountTxt.setText(""); sellPriceTxt.setText(""); updateSellOfferTimeTxt(); LK.clearInterval(sellOfferTimerInterval); sellOfferTimerInterval = null; LK.setTimeout(function () { generateSellOffer(); }, 60); // 1 frame sonra yeni teklif gelsin } }, 60); // 1 saniye } generateSellOffer(); // Satış butonu logic sellBtn.down = function (x, y, obj) { // If not active or not enough stock, do nothing (button is visually disabled) if (!currentSellOffer.active || parts[currentSellOffer.part] < currentSellOffer.amount) { // Optionally, flash button red and show warning if user tries to press when not enough stock tween(sellBtn, { tint: 0xff2222 }, { duration: 120, onFinish: function onFinish() { tween(sellBtn, { tint: 0x222222 }, { duration: 120 }); } }); // 'Stok yetersiz' uyarısı göster sellBtnTxt.setText('Stok yetersiz'); LK.setTimeout(function () { // Eğer buton hala görünürse eski haline döndür if (sellBtn.visible) { sellBtnTxt.setText('Sat'); } // Teklifi yenileme, teklif tamamlanmasın! }, 300); // 5 saniye = 300 frame return; } // Satış işlemi parts[currentSellOffer.part] -= currentSellOffer.amount; money += currentSellOffer.price; toplamTopluSatisGeliri += currentSellOffer.price; updateMoneyText(); updatePartsText(); // Panel animasyonu tween(sellPanel, { scaleX: 1.08, scaleY: 1.08 }, { duration: 120, onFinish: function onFinish() { tween(sellPanel, { scaleX: 1, scaleY: 1 }, { duration: 120 }); } }); // Teklif tamamlandı, yeni teklif gelene kadar butonu kapat currentSellOffer.active = false; sellBtn.visible = false; sellBtnTxt.visible = false; sellPartTxt.setText("Teklif tamamlandı!"); sellAmountTxt.setText(""); sellPriceTxt.setText(""); // Yeni teklif rastgele 1-2 dakika sonra gelsin var nextSellOfferDelay = (60 + Math.floor(Math.random() * 61)) * 60; LK.setTimeout(function () { generateSellOffer(); }, nextSellOfferDelay); }; // Satış teklifi her rastgele 1-5 dakikada bir yenilensin (eğer aktif değilse) function scheduleNextSellOfferInterval() { var interval = (60 + Math.floor(Math.random() * 61)) * 60; LK.setTimeout(function () { if (!currentSellOffer.active) generateSellOffer(); scheduleNextSellOfferInterval(); }, interval); } scheduleNextSellOfferInterval();
===================================================================
--- original.js
+++ change.js
@@ -2623,8 +2623,10 @@
worker4EarningTxt.x = workerImg.x;
worker4EarningTxt.y = worker4LevelTxt.y + 22;
worker4EarningTxt.visible = false;
game.addChild(worker4EarningTxt);
+ // Sadece ilk tıklamada 'Tıkla: ₺...' yazısı gösterilsin
+ var worker4FirstClickDone = false;
worker4UpgradeBtn = LK.getAsset('button', {
anchorX: 0.5,
anchorY: 0.5,
width: 140,
@@ -2664,10 +2666,11 @@
duration: 80
});
}
});
- if (worker4EarningTxt) {
+ if (worker4EarningTxt && !worker4FirstClickDone) {
worker4EarningTxt.setText('Tıkla: ₺' + earning);
+ worker4FirstClickDone = true;
}
};
worker4UpgradeBtn.down = function (x, y, obj) {
if (yatirimPanel && yatirimPanel.visible) return;
Factory. In-Game asset. 2d. High contrast. No shadows
Copper. In-Game asset. 2d. High contrast. No shadows
Müşteri. In-Game asset. 2d. High contrast. No shadows
Iron. In-Game asset. 2d. High contrast. No shadows
Silicon. In-Game asset. 2d. High contrast. No shadows
Store. In-Game asset. 2d. High contrast. No shadows
CPU. In-Game asset. 2d. High contrast. No shadows
PC Case. In-Game asset. 2d. High contrast. No shadows
PC GPU. In-Game asset. 2d. High contrast. No shadows
PC RAM. In-Game asset. 2d. High contrast. No shadows
PC Klavye. In-Game asset. 2d. High contrast. No shadows
PC Monitör. In-Game asset. 2d. High contrast. No shadows
City. In-Game asset. 2d. High contrast. No shadows
Bilgisayar teknikeri personel. In-Game asset. 2d. High contrast. No shadows
Mavi gömlekli bilgisayar teknikeri personeli. In-Game asset. 2d. High contrast. No shadows
Silver madeni. In-Game asset. 2d. High contrast. No shadows
Altın cevheri. In-Game asset. 2d. High contrast. No shadows
Nikel cevheri. In-Game asset. 2d. High contrast. No shadows
SSD bilgisayar Parçası. In-Game asset. 2d. High contrast. No shadows
PSU bilgisayar Parçası. In-Game asset. 2d. High contrast. No shadows
ANAKART Bilgisayar Parçası. In-Game asset. 2d. High contrast. No shadows
Maden girişi. In-Game asset. 2d. High contrast. No shadows
2000 sayısı ve Buy butonu. In-Game asset. 2d. High contrast. No shadows