/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Uygulama ikonları için temel sınıf var AppIcon = Container.expand(function () { var self = Container.call(this); // Varsayılan değerler, dışarıdan atanmazsa hata engellenir self.iconId = typeof self.iconId !== "undefined" ? self.iconId : "galleryIcon"; self.iconColor = typeof self.iconColor !== "undefined" ? self.iconColor : 0xffffff; self.appName = typeof self.appName !== "undefined" ? self.appName : ""; // Uygulama kutusu var box = self.attachAsset('appBox', { width: 320, height: 320, color: 0x222244, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); self.box = box; self.addChild(box); // Uygulama simgesi (farklı renkler) self.icon = self.attachAsset(self.iconId, { width: 180, height: 180, color: self.iconColor, shape: 'ellipse', anchorX: 0.5, anchorY: 0.5, y: 0 }); self.addChild(self.icon); // Uygulama adı self.label = new Text2(self.appName, { size: 60, fill: 0xB8E0FF }); self.label.anchor.set(0.5, 0); self.label.y = 110; self.addChild(self.label); // Hacklenme durumu self.hacked = false; self.aiHacked = false; // AI işareti (başta görünmez) self.aiMark = self.attachAsset('aiMark', { anchorX: 0.5, anchorY: 1, y: -120 }); self.aiMark.visible = false; self.addChild(self.aiMark); // Hack animasyonu self.flash = function (color) { tween(self, { alpha: 0.5 }, { duration: 100, onFinish: function onFinish() { tween(self, { alpha: 1 }, { duration: 200 }); } }); }; // AI işareti güncelleme fonksiyonu self.updateAIMark = function () { self.aiMark.visible = !!self.aiHacked; }; return self; }); // Mini oyun ekranı var MiniGame = Container.expand(function () { var self = Container.call(this); // Arkaplan var bg = self.attachAsset('miniGameBg', { width: 1200, height: 900, color: 0x181c2a, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); // Rastgele sayı dizisi self.code = []; self.codeLen = 5; self.input = ''; self.active = false; self.codeText = new Text2('', { size: 120, fill: "#fff" }); self.codeText.anchor.set(0.5, 0.5); self.codeText.y = -120; self.addChild(self.codeText); self.inputText = new Text2('', { size: 100, fill: 0x00FF99 }); self.inputText.anchor.set(0.5, 0.5); self.inputText.y = 60; self.addChild(self.inputText); // Kapatma butonu self.closeBtn = self.attachAsset('closeBtn', { width: 80, height: 80, color: 0xff4444, shape: 'ellipse', anchorX: 0.5, anchorY: 0.5, x: 540, y: -400 }); self.closeBtn.interactive = true; self.closeBtn.down = function () { self.hide(); }; self.show = function (codeLen) { self.codeLen = codeLen || 4; self.code = []; for (var i = 0; i < self.codeLen; i++) { self.code.push(Math.floor(Math.random() * 10)); } self.input = ''; self.codeText.setText(self.code.join(' ')); self.inputText.setText(''); self.visible = true; self.active = true; }; self.hide = function () { self.visible = false; self.active = false; }; self.onInput = function (num) { if (!self.active) return; if (self.input.length >= self.codeLen) return; self.input += num; self.inputText.setText(self.input); if (self.input.length === self.codeLen) { if (self.input === self.code.join('')) { self.active = false; if (self.onSuccess) self.onSuccess(); } else { self.inputText.setText('Yanlış!'); tween(self.inputText, { alpha: 0 }, { duration: 200, onFinish: function onFinish() { self.inputText.alpha = 1; self.input = ''; self.inputText.setText(''); } }); } } }; return self; }); // Rakam tuş takımı var NumPad = Container.expand(function () { var self = Container.call(this); self.buttons = []; var btnSize = 180; var margin = 30; var startX = -btnSize - margin; var startY = -btnSize - margin; for (var i = 1; i <= 9; i++) { var btn = self.attachAsset('numBtn' + i, { width: btnSize, height: btnSize, color: 0x2a3a4a, shape: 'ellipse', anchorX: 0.5, anchorY: 0.5, x: startX + (i - 1) % 3 * (btnSize + margin), y: startY + Math.floor((i - 1) / 3) * (btnSize + margin) }); btn.num = i; btn.interactive = true; btn.down = function (x, y, obj) { if (self.onNum) self.onNum(this.num); }; var txt = new Text2('' + i, { size: 80, fill: "#fff" }); txt.anchor.set(0.5, 0.5); btn.addChild(txt); self.buttons.push(btn); } // 0 tuşu var btn0 = self.attachAsset('numBtn0', { width: btnSize, height: btnSize, color: 0x2a3a4a, shape: 'ellipse', anchorX: 0.5, anchorY: 0.5, x: startX + btnSize + margin, y: startY + 3 * (btnSize + margin) }); btn0.num = 0; btn0.interactive = true; btn0.down = function (x, y, obj) { if (self.onNum) self.onNum(this.num); }; var txt0 = new Text2('0', { size: 80, fill: "#fff" }); txt0.anchor.set(0.5, 0.5); btn0.addChild(txt0); self.buttons.push(btn0); return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x0a0c18 }); /**** * Game Code ****/ // Uygulama tanımları // AI'nin hacklediği uygulamanın üstünde gösterilecek işaret // Her uygulama için ayrı assetler var appDefs = [{ appName: "Galeri", iconId: "galleryIcon", iconColor: 0x6ec6ff }, { appName: "Mesajlar", iconId: "msgIcon", iconColor: 0xffb347 }, { appName: "Ayarlar", iconId: "settingsIcon", iconColor: 0x8aff80 }, { appName: "Oyunlar", iconId: "gamesIcon", iconColor: 0xff6e9c }, { appName: "Hava Durumu", iconId: "weatherIcon", iconColor: 0x4fc3f7 }, { appName: "Tok Tik", iconId: "toktikIcon", iconColor: 0x8e44ad }]; // Ana arka planı ekle (ikonlardan önce, en arkada olacak şekilde) var mainBg = LK.getAsset('mainBg', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); game.addChild(mainBg); // Uygulama ikonları var appIcons = []; // 3 sol, 3 sağ dikey sütun için grid ayarları var appGridCols = 2; var appGridRows = 3; var appGridDX = 800; // Sütunlar arası mesafe (daha da arttırıldı) var appGridDY = 520; // Satırlar arası mesafe (daha da arttırıldı) // Sol sütun x pozisyonu, sağ sütun x pozisyonu var leftColX = 2048 / 2 - appGridDX / 2 - 180; var rightColX = 2048 / 2 + appGridDX / 2 + 180; var appGridStartY = 900; // AI hack ilerlemesi var aiProgress = [false, false, false, false, false, false]; // Oyuncu hack ilerlemesi var playerProgress = [false, false, false, false, false, false]; // Oyun durumu var currentMiniGame = null; var currentAppIndex = null; var aiTimer = null; var aiSpeed = 3500; // ms, AI'nin bir uygulamayı hacklemesi için gereken süre (daha yavaş) var gameEnded = false; // Skor göstergesi var playerScoreTxt = new Text2('0', { size: 90, fill: 0x00FF99 }); playerScoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(playerScoreTxt); var aiScoreTxt = new Text2('0', { size: 90, fill: 0xFF4444 }); aiScoreTxt.anchor.set(0.5, 0); // Daha solda göstermek için gui.top'a ekle ve x pozisyonunu ayarla LK.gui.top.addChild(aiScoreTxt); aiScoreTxt.x = 400; // Sol üstten biraz sağda, topRight yerine // Uygulama ikonlarını oluştur (3 sol, 3 sağ dikey sütun) for (var i = 0; i < appDefs.length; i++) { var def = appDefs[i]; var icon = new AppIcon(); icon.iconId = def.iconId; icon.iconColor = def.iconColor; icon.appName = def.appName; // Sütun ve satır hesapla var col = i < 3 ? 0 : 1; // 0: sol, 1: sağ var row = i % 3; icon.x = col === 0 ? leftColX : rightColX; icon.y = appGridStartY + row * appGridDY; icon.interactive = true; icon.appIndex = i; icon.down = function (x, y, obj) { if (gameEnded) return; var idx = this.appIndex; if (playerProgress[idx] || aiProgress[idx]) return; openMiniGame(idx); }; appIcons.push(icon); game.addChild(icon); } // Mini oyun ekranı ve tuş takımı var miniGame = new MiniGame(); miniGame.x = 2048 / 2; miniGame.y = 2732 / 2; miniGame.visible = false; game.addChild(miniGame); var numPad = new NumPad(); numPad.x = 2048 / 2; numPad.y = 2732 / 2 + 400; numPad.visible = false; game.addChild(numPad); // Mini oyun aç function openMiniGame(appIdx) { if (typeof startScreen !== "undefined" && startScreen.visible) { return; } currentAppIndex = appIdx; miniGame.show(5); // Kod uzunluğu her zaman 5 basamaklı numPad.visible = true; miniGame.visible = true; miniGame.onSuccess = function () { playerProgress[appIdx] = true; appIcons[appIdx].hacked = true; appIcons[appIdx].flash(0x00ff99); updateScores(); closeMiniGame(); checkGameEnd(); }; } // Mini oyun kapat function closeMiniGame() { miniGame.hide(); numPad.visible = false; currentAppIndex = null; } // NumPad input numPad.onNum = function (num) { if (miniGame.active) { miniGame.onInput('' + num); } }; // Skorları güncelle function updateScores() { var playerScore = 0, aiScore = 0; for (var i = 0; i < appDefs.length; i++) { if (playerProgress[i]) playerScore++; if (aiProgress[i]) aiScore++; } playerScoreTxt.setText('SEN: ' + playerScore); aiScoreTxt.setText('AI: ' + aiScore); } // AI hack ilerlemesi function startAI() { if (aiTimer) LK.clearInterval(aiTimer); aiTimer = LK.setInterval(function () { if (gameEnded || typeof startScreen !== "undefined" && startScreen.visible) { LK.clearInterval(aiTimer); return; } // AI henüz hacklemediği bir uygulama seçsin var available = []; for (var i = 0; i < appDefs.length; i++) { if (!aiProgress[i] && !playerProgress[i]) available.push(i); } if (available.length === 0) return; var pick = available[Math.floor(Math.random() * available.length)]; aiProgress[pick] = true; appIcons[pick].aiHacked = true; appIcons[pick].flash(0xff4444); updateScores(); checkGameEnd(); }, aiSpeed); } // Oyun bitiş kontrolü function checkGameEnd() { var playerScore = 0, aiScore = 0; for (var i = 0; i < appDefs.length; i++) { if (playerProgress[i]) playerScore++; if (aiProgress[i]) aiScore++; } if (playerScore + aiScore === appDefs.length) { gameEnded = true; if (playerScore > aiScore) { LK.showYouWin(); } else if (aiScore > playerScore) { LK.showGameOver(); } else { LK.showGameOver(); } } } // Oyun başlat function resetGame() { for (var i = 0; i < appDefs.length; i++) { playerProgress[i] = false; aiProgress[i] = false; appIcons[i].hacked = false; appIcons[i].aiHacked = false; appIcons[i].alpha = 1; } gameEnded = false; updateScores(); startAI(); closeMiniGame(); } // Başlama ekranı overlay'i var startScreen = new Container(); var startBg = LK.getAsset('mainBg', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); startScreen.addChild(startBg); var startTitle = new Text2("Uygulamaları Hackle!", { size: 140, fill: "#fff" }); startTitle.anchor.set(0.5, 0.5); startTitle.x = 2048 / 2; startTitle.y = 900; startScreen.addChild(startTitle); var startBtn = LK.getAsset('appBox', { width: 500, height: 180, color: 0x00c853, anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 1500 }); startBtn.interactive = true; startScreen.addChild(startBtn); var startBtnText = new Text2("BAŞLA", { size: 90, fill: "#fff" }); startBtnText.anchor.set(0.5, 0.5); startBtnText.x = 2048 / 2; startBtnText.y = 1500; startScreen.addChild(startBtnText); startBtn.down = function () { startScreen.visible = false; resetGame(); }; game.addChild(startScreen); // Oyun başında overlay açık, oyun başlamaz startScreen.visible = true; // resetGame(); // Oyun güncellemesi game.update = function () { // Başlama ekranı açıksa oyun güncellemesi çalışmasın if (typeof startScreen !== "undefined" && startScreen.visible) { return; } // Uygulama ikonlarının hack durumunu göster for (var i = 0; i < appIcons.length; i++) { var icon = appIcons[i]; if (icon.hacked) { icon.box.tint = 0x00ff99; icon.label.setText(icon.appName + "\n(HACKLENDİ)"); } else if (icon.aiHacked) { icon.box.tint = 0xff4444; icon.label.setText(icon.appName + "\n(AI)"); } else { icon.box.tint = 0x222244; icon.label.setText(icon.appName); } // AI işareti güncelle if (icon.updateAIMark) icon.updateAIMark(); } }; // Oyun resetlenince tekrar başlat LK.on('reset', function () { resetGame(); }); // Ekran dışı tıklama ile mini oyunu kapatma game.down = function (x, y, obj) { if (miniGame.visible && !miniGame.active) { closeMiniGame(); } }; // Not: Assetler engine tarafından otomatik oluşturulacak: // - appBox: kutu // - galleryIcon, msgIcon, settingsIcon, gamesIcon: farklı renkli elipsler // - miniGameBg: mini oyun arka planı // - closeBtn: kırmızı daire // - numBtn0-9: rakam tuşları (elips)
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// Uygulama ikonları için temel sınıf
var AppIcon = Container.expand(function () {
var self = Container.call(this);
// Varsayılan değerler, dışarıdan atanmazsa hata engellenir
self.iconId = typeof self.iconId !== "undefined" ? self.iconId : "galleryIcon";
self.iconColor = typeof self.iconColor !== "undefined" ? self.iconColor : 0xffffff;
self.appName = typeof self.appName !== "undefined" ? self.appName : "";
// Uygulama kutusu
var box = self.attachAsset('appBox', {
width: 320,
height: 320,
color: 0x222244,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5
});
self.box = box;
self.addChild(box);
// Uygulama simgesi (farklı renkler)
self.icon = self.attachAsset(self.iconId, {
width: 180,
height: 180,
color: self.iconColor,
shape: 'ellipse',
anchorX: 0.5,
anchorY: 0.5,
y: 0
});
self.addChild(self.icon);
// Uygulama adı
self.label = new Text2(self.appName, {
size: 60,
fill: 0xB8E0FF
});
self.label.anchor.set(0.5, 0);
self.label.y = 110;
self.addChild(self.label);
// Hacklenme durumu
self.hacked = false;
self.aiHacked = false;
// AI işareti (başta görünmez)
self.aiMark = self.attachAsset('aiMark', {
anchorX: 0.5,
anchorY: 1,
y: -120
});
self.aiMark.visible = false;
self.addChild(self.aiMark);
// Hack animasyonu
self.flash = function (color) {
tween(self, {
alpha: 0.5
}, {
duration: 100,
onFinish: function onFinish() {
tween(self, {
alpha: 1
}, {
duration: 200
});
}
});
};
// AI işareti güncelleme fonksiyonu
self.updateAIMark = function () {
self.aiMark.visible = !!self.aiHacked;
};
return self;
});
// Mini oyun ekranı
var MiniGame = Container.expand(function () {
var self = Container.call(this);
// Arkaplan
var bg = self.attachAsset('miniGameBg', {
width: 1200,
height: 900,
color: 0x181c2a,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5
});
// Rastgele sayı dizisi
self.code = [];
self.codeLen = 5;
self.input = '';
self.active = false;
self.codeText = new Text2('', {
size: 120,
fill: "#fff"
});
self.codeText.anchor.set(0.5, 0.5);
self.codeText.y = -120;
self.addChild(self.codeText);
self.inputText = new Text2('', {
size: 100,
fill: 0x00FF99
});
self.inputText.anchor.set(0.5, 0.5);
self.inputText.y = 60;
self.addChild(self.inputText);
// Kapatma butonu
self.closeBtn = self.attachAsset('closeBtn', {
width: 80,
height: 80,
color: 0xff4444,
shape: 'ellipse',
anchorX: 0.5,
anchorY: 0.5,
x: 540,
y: -400
});
self.closeBtn.interactive = true;
self.closeBtn.down = function () {
self.hide();
};
self.show = function (codeLen) {
self.codeLen = codeLen || 4;
self.code = [];
for (var i = 0; i < self.codeLen; i++) {
self.code.push(Math.floor(Math.random() * 10));
}
self.input = '';
self.codeText.setText(self.code.join(' '));
self.inputText.setText('');
self.visible = true;
self.active = true;
};
self.hide = function () {
self.visible = false;
self.active = false;
};
self.onInput = function (num) {
if (!self.active) return;
if (self.input.length >= self.codeLen) return;
self.input += num;
self.inputText.setText(self.input);
if (self.input.length === self.codeLen) {
if (self.input === self.code.join('')) {
self.active = false;
if (self.onSuccess) self.onSuccess();
} else {
self.inputText.setText('Yanlış!');
tween(self.inputText, {
alpha: 0
}, {
duration: 200,
onFinish: function onFinish() {
self.inputText.alpha = 1;
self.input = '';
self.inputText.setText('');
}
});
}
}
};
return self;
});
// Rakam tuş takımı
var NumPad = Container.expand(function () {
var self = Container.call(this);
self.buttons = [];
var btnSize = 180;
var margin = 30;
var startX = -btnSize - margin;
var startY = -btnSize - margin;
for (var i = 1; i <= 9; i++) {
var btn = self.attachAsset('numBtn' + i, {
width: btnSize,
height: btnSize,
color: 0x2a3a4a,
shape: 'ellipse',
anchorX: 0.5,
anchorY: 0.5,
x: startX + (i - 1) % 3 * (btnSize + margin),
y: startY + Math.floor((i - 1) / 3) * (btnSize + margin)
});
btn.num = i;
btn.interactive = true;
btn.down = function (x, y, obj) {
if (self.onNum) self.onNum(this.num);
};
var txt = new Text2('' + i, {
size: 80,
fill: "#fff"
});
txt.anchor.set(0.5, 0.5);
btn.addChild(txt);
self.buttons.push(btn);
}
// 0 tuşu
var btn0 = self.attachAsset('numBtn0', {
width: btnSize,
height: btnSize,
color: 0x2a3a4a,
shape: 'ellipse',
anchorX: 0.5,
anchorY: 0.5,
x: startX + btnSize + margin,
y: startY + 3 * (btnSize + margin)
});
btn0.num = 0;
btn0.interactive = true;
btn0.down = function (x, y, obj) {
if (self.onNum) self.onNum(this.num);
};
var txt0 = new Text2('0', {
size: 80,
fill: "#fff"
});
txt0.anchor.set(0.5, 0.5);
btn0.addChild(txt0);
self.buttons.push(btn0);
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x0a0c18
});
/****
* Game Code
****/
// Uygulama tanımları
// AI'nin hacklediği uygulamanın üstünde gösterilecek işaret
// Her uygulama için ayrı assetler
var appDefs = [{
appName: "Galeri",
iconId: "galleryIcon",
iconColor: 0x6ec6ff
}, {
appName: "Mesajlar",
iconId: "msgIcon",
iconColor: 0xffb347
}, {
appName: "Ayarlar",
iconId: "settingsIcon",
iconColor: 0x8aff80
}, {
appName: "Oyunlar",
iconId: "gamesIcon",
iconColor: 0xff6e9c
}, {
appName: "Hava Durumu",
iconId: "weatherIcon",
iconColor: 0x4fc3f7
}, {
appName: "Tok Tik",
iconId: "toktikIcon",
iconColor: 0x8e44ad
}];
// Ana arka planı ekle (ikonlardan önce, en arkada olacak şekilde)
var mainBg = LK.getAsset('mainBg', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
game.addChild(mainBg);
// Uygulama ikonları
var appIcons = [];
// 3 sol, 3 sağ dikey sütun için grid ayarları
var appGridCols = 2;
var appGridRows = 3;
var appGridDX = 800; // Sütunlar arası mesafe (daha da arttırıldı)
var appGridDY = 520; // Satırlar arası mesafe (daha da arttırıldı)
// Sol sütun x pozisyonu, sağ sütun x pozisyonu
var leftColX = 2048 / 2 - appGridDX / 2 - 180;
var rightColX = 2048 / 2 + appGridDX / 2 + 180;
var appGridStartY = 900;
// AI hack ilerlemesi
var aiProgress = [false, false, false, false, false, false];
// Oyuncu hack ilerlemesi
var playerProgress = [false, false, false, false, false, false];
// Oyun durumu
var currentMiniGame = null;
var currentAppIndex = null;
var aiTimer = null;
var aiSpeed = 3500; // ms, AI'nin bir uygulamayı hacklemesi için gereken süre (daha yavaş)
var gameEnded = false;
// Skor göstergesi
var playerScoreTxt = new Text2('0', {
size: 90,
fill: 0x00FF99
});
playerScoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(playerScoreTxt);
var aiScoreTxt = new Text2('0', {
size: 90,
fill: 0xFF4444
});
aiScoreTxt.anchor.set(0.5, 0);
// Daha solda göstermek için gui.top'a ekle ve x pozisyonunu ayarla
LK.gui.top.addChild(aiScoreTxt);
aiScoreTxt.x = 400; // Sol üstten biraz sağda, topRight yerine
// Uygulama ikonlarını oluştur (3 sol, 3 sağ dikey sütun)
for (var i = 0; i < appDefs.length; i++) {
var def = appDefs[i];
var icon = new AppIcon();
icon.iconId = def.iconId;
icon.iconColor = def.iconColor;
icon.appName = def.appName;
// Sütun ve satır hesapla
var col = i < 3 ? 0 : 1; // 0: sol, 1: sağ
var row = i % 3;
icon.x = col === 0 ? leftColX : rightColX;
icon.y = appGridStartY + row * appGridDY;
icon.interactive = true;
icon.appIndex = i;
icon.down = function (x, y, obj) {
if (gameEnded) return;
var idx = this.appIndex;
if (playerProgress[idx] || aiProgress[idx]) return;
openMiniGame(idx);
};
appIcons.push(icon);
game.addChild(icon);
}
// Mini oyun ekranı ve tuş takımı
var miniGame = new MiniGame();
miniGame.x = 2048 / 2;
miniGame.y = 2732 / 2;
miniGame.visible = false;
game.addChild(miniGame);
var numPad = new NumPad();
numPad.x = 2048 / 2;
numPad.y = 2732 / 2 + 400;
numPad.visible = false;
game.addChild(numPad);
// Mini oyun aç
function openMiniGame(appIdx) {
if (typeof startScreen !== "undefined" && startScreen.visible) {
return;
}
currentAppIndex = appIdx;
miniGame.show(5); // Kod uzunluğu her zaman 5 basamaklı
numPad.visible = true;
miniGame.visible = true;
miniGame.onSuccess = function () {
playerProgress[appIdx] = true;
appIcons[appIdx].hacked = true;
appIcons[appIdx].flash(0x00ff99);
updateScores();
closeMiniGame();
checkGameEnd();
};
}
// Mini oyun kapat
function closeMiniGame() {
miniGame.hide();
numPad.visible = false;
currentAppIndex = null;
}
// NumPad input
numPad.onNum = function (num) {
if (miniGame.active) {
miniGame.onInput('' + num);
}
};
// Skorları güncelle
function updateScores() {
var playerScore = 0,
aiScore = 0;
for (var i = 0; i < appDefs.length; i++) {
if (playerProgress[i]) playerScore++;
if (aiProgress[i]) aiScore++;
}
playerScoreTxt.setText('SEN: ' + playerScore);
aiScoreTxt.setText('AI: ' + aiScore);
}
// AI hack ilerlemesi
function startAI() {
if (aiTimer) LK.clearInterval(aiTimer);
aiTimer = LK.setInterval(function () {
if (gameEnded || typeof startScreen !== "undefined" && startScreen.visible) {
LK.clearInterval(aiTimer);
return;
}
// AI henüz hacklemediği bir uygulama seçsin
var available = [];
for (var i = 0; i < appDefs.length; i++) {
if (!aiProgress[i] && !playerProgress[i]) available.push(i);
}
if (available.length === 0) return;
var pick = available[Math.floor(Math.random() * available.length)];
aiProgress[pick] = true;
appIcons[pick].aiHacked = true;
appIcons[pick].flash(0xff4444);
updateScores();
checkGameEnd();
}, aiSpeed);
}
// Oyun bitiş kontrolü
function checkGameEnd() {
var playerScore = 0,
aiScore = 0;
for (var i = 0; i < appDefs.length; i++) {
if (playerProgress[i]) playerScore++;
if (aiProgress[i]) aiScore++;
}
if (playerScore + aiScore === appDefs.length) {
gameEnded = true;
if (playerScore > aiScore) {
LK.showYouWin();
} else if (aiScore > playerScore) {
LK.showGameOver();
} else {
LK.showGameOver();
}
}
}
// Oyun başlat
function resetGame() {
for (var i = 0; i < appDefs.length; i++) {
playerProgress[i] = false;
aiProgress[i] = false;
appIcons[i].hacked = false;
appIcons[i].aiHacked = false;
appIcons[i].alpha = 1;
}
gameEnded = false;
updateScores();
startAI();
closeMiniGame();
}
// Başlama ekranı overlay'i
var startScreen = new Container();
var startBg = LK.getAsset('mainBg', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
startScreen.addChild(startBg);
var startTitle = new Text2("Uygulamaları Hackle!", {
size: 140,
fill: "#fff"
});
startTitle.anchor.set(0.5, 0.5);
startTitle.x = 2048 / 2;
startTitle.y = 900;
startScreen.addChild(startTitle);
var startBtn = LK.getAsset('appBox', {
width: 500,
height: 180,
color: 0x00c853,
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 1500
});
startBtn.interactive = true;
startScreen.addChild(startBtn);
var startBtnText = new Text2("BAŞLA", {
size: 90,
fill: "#fff"
});
startBtnText.anchor.set(0.5, 0.5);
startBtnText.x = 2048 / 2;
startBtnText.y = 1500;
startScreen.addChild(startBtnText);
startBtn.down = function () {
startScreen.visible = false;
resetGame();
};
game.addChild(startScreen);
// Oyun başında overlay açık, oyun başlamaz
startScreen.visible = true;
// resetGame();
// Oyun güncellemesi
game.update = function () {
// Başlama ekranı açıksa oyun güncellemesi çalışmasın
if (typeof startScreen !== "undefined" && startScreen.visible) {
return;
}
// Uygulama ikonlarının hack durumunu göster
for (var i = 0; i < appIcons.length; i++) {
var icon = appIcons[i];
if (icon.hacked) {
icon.box.tint = 0x00ff99;
icon.label.setText(icon.appName + "\n(HACKLENDİ)");
} else if (icon.aiHacked) {
icon.box.tint = 0xff4444;
icon.label.setText(icon.appName + "\n(AI)");
} else {
icon.box.tint = 0x222244;
icon.label.setText(icon.appName);
}
// AI işareti güncelle
if (icon.updateAIMark) icon.updateAIMark();
}
};
// Oyun resetlenince tekrar başlat
LK.on('reset', function () {
resetGame();
});
// Ekran dışı tıklama ile mini oyunu kapatma
game.down = function (x, y, obj) {
if (miniGame.visible && !miniGame.active) {
closeMiniGame();
}
};
// Not: Assetler engine tarafından otomatik oluşturulacak:
// - appBox: kutu
// - galleryIcon, msgIcon, settingsIcon, gamesIcon: farklı renkli elipsler
// - miniGameBg: mini oyun arka planı
// - closeBtn: kırmızı daire
// - numBtn0-9: rakam tuşları (elips)