///////////////////////////// // MenuApp let MenuApp = { preload: function() { game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png'); }, create: function() { this.game.stage.backgroundColor = '#4d4d4d'; // top let backButton = new BackButton( () => { sessionStorageManager.clear(); location.href = '../../web/client/login.html'; }); let fullscreenButton = new FullscreenButton(this.game); // app icons let space_invaders = new AppButton(AppButton.TYPE_MOUSE, "icon_fullscreen", () => { sessionStorageManager.playingAppName = "space_invaders"; location.href = '../../web/client/start.html'; } ); space_invaders.move(400, 400); let typing_practice = new AppButton(AppButton.TYPE_TYPING, "icon_fullscreen", () => { console.log("typing practice"); } ); typing_practice.move(600, 400); // bottom let screenBottom = new ScreenBottom(game); screenBottom.makeBottomLine(); // screenBottom.printBottomLeftText("게임 진행 정보"); let playingAppName = appInfoManager.getAppNameKorean(sessionStorageManager.playingAppName); screenBottom.printBottomCenterText(playingAppName); screenBottom.printBottomRightText(sessionStorageManager.playerName); // this.loadTypingStageData(); }, loadTypingStageData: function() { var self = this; xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { // console.log("onreadystatechange : " + xhr); // console.log("xhr.readyState : " + xhr.readyState); // console.log("xhr.status : " + xhr.status); if(xhr.readyState == 4 && xhr.status == 200) { // console.log(xhr.responseText); var jsonData = JSON.parse(xhr.responseText); self.updateStageButton(jsonData); } } xhr.open('GET', 'activated_stage_list.php', true); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.send(); }, updateStageButton: function(jsonData) { // console.log(JSON.stringify(jsonData)); for(var i = 0; i < jsonData.length; i++) { // console.log(jsonData[i]["StageName"] + " : " + jsonData[i]["Activated"]); this.activateStageButton( // jsonData[i]["Language"], jsonData[i]["StageName"], jsonData[i]["Activated"] ); } }, activateStageButton: function(stageName, isActivated) { for(var i = 0; i < this.stageButtonArray.length; i++) { var buttonName = this.stageButtonArray[i].name; var buttonLanguage = buttonName.charAt(0) == "k" ? "korean" : "english"; var buttonStageName = getStageCodeByStageNo(buttonName.substring(1)); var buttonNewName = buttonLanguage + "_" + buttonStageName; // console.log("buttonNewName : " + buttonNewName); if(buttonNewName == stageName) { if(isActivated == true) { // console.log("stageName : " + stageName); this.stageButtonArray[i].startButton.alpha = 1; this.stageButtonArray[i].startButton.inputEnabled = true; return; } else { // console.log("this.stageButtonArray[" + i + "].name : " + this.stageButtonArray[i].name); // console.log("buttonNewName : " + buttonNewName); this.stageButtonArray[i].startButton.alpha = 0.3; this.stageButtonArray[i].startButton.inputEnabled = false; return; } } } }, startStage: function() { var language = this.name.substring(0, 1) == "k" ? LANGUAGE_KOREAN : LANGUAGE_ENGLISH; var level = this.name.substring(1); playingStageData = new StageData(language, level); // console.log(playingStageData); this.startState('TypingTestStage'); }, }