Skip to content

Commit

Permalink
Merge pull request #49 from NCCBitCamp/soojeong
Browse files Browse the repository at this point in the history
true ending
  • Loading branch information
soojeongmin authored Jul 6, 2024
2 parents d9e1ee7 + 8a74865 commit 522fb56
Show file tree
Hide file tree
Showing 7 changed files with 644 additions and 128 deletions.
171 changes: 93 additions & 78 deletions BitCamp/101Room.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,29 +144,41 @@
};

const createInventory = (scene) => {
inventoryBag = scene.add.image(1150, 40, 'bag').setInteractive();
inventoryBag.setScale(0.5).setScrollFactor(0);
inventoryBag.on('pointerdown', () => {
toggleInventoryModal(scene);
});
inventoryBag.on('pointerover', () => {
document.body.style.cursor = 'pointer';
});
inventoryBag.on('pointerout', () => {
document.body.style.cursor = 'default';
});
inventoryBag = scene.add.image(1150, 40, 'bag').setInteractive();
inventoryBag.setScale(0.5).setScrollFactor(0);
inventoryBag.on('pointerdown', () => {
toggleInventoryModal(scene);
});
inventoryBag.on('pointerover', () => {
document.body.style.cursor = 'pointer';
});
inventoryBag.on('pointerout', () => {
document.body.style.cursor = 'default';
});

overlay = scene.add.rectangle(scene.cameras.main.centerX, scene.cameras.main.centerY, bgImage.width, bgImage.height, 0x000000, 0.5);
overlay.setAlpha(0);

modalBackground = scene.add.rectangle(scene.cameras.main.centerX, scene.cameras.main.centerY - 180, 800, 300, 0xFFFAFA).setAlpha(0).setInteractive().setScrollFactor(0);
modalText = scene.add.text(scene.cameras.main.centerX, 60, '소지품', {
fontFamily: 'KyoboHandwriting2023wsa',
fontSize: '24px',
fill: '#000000'
}).setAlpha(0).setOrigin(0.5).setScrollFactor(0);
modal = scene.add.container(0, 0, [modalBackground, modalText]).setAlpha(0);

// Load items from local storage
const storedInventory = JSON.parse(localStorage.getItem('inventory')) || [];
const storedInventoryImages = JSON.parse(localStorage.getItem('inventoryImages')) || [];

storedInventory.forEach((item, index) => {
inventory.push(item);
inventoryImages.push(storedInventoryImages[index]);
});

updateInventoryDisplay();
};

overlay = scene.add.rectangle(scene.cameras.main.centerX, scene.cameras.main.centerY, bgImage.width, bgImage.height, 0x000000, 0.5);
overlay.setAlpha(0);

modalBackground = scene.add.rectangle(scene.cameras.main.centerX, scene.cameras.main.centerY - 180, 800, 300, 0xFFFAFA).setAlpha(0).setInteractive().setScrollFactor(0); // 배경색 변경 예시
modalText = scene.add.text(scene.cameras.main.centerX, 60, '소지품', {
fontFamily: 'KyoboHandwriting2023wsa',
fontSize: '24px',
fill: '#000000'
}).setAlpha(0).setOrigin(0.5).setScrollFactor(0);
modal = scene.add.container(0, 0, [modalBackground, modalText]).setAlpha(0);
};

const addItemToInventory = (item, imageKey) => {
if (!inventory.includes(item)) {
Expand Down Expand Up @@ -287,73 +299,76 @@
this.load.image('dialogueBox', 'images/wallpaper-torn-paper-ripped-white-paper.png');
this.load.image('background', 'images/cctvRoom.png');
this.load.image('bag', 'images/bag.svg');
this.load.image('key', 'images/key.png');
this.load.image('exitkey', 'images/exitkey.png');
this.load.image('photo', 'images/photo.png');
this.load.image('photo_enlarge', 'images/photograph.png');
this.load.image('newspaper', 'images/newspaper.png');
this.load.image('newspaper_enlarge', 'images/newspaper_enlarge.png');
this.load.image('confirmBox', 'images/dialogueBox.png');
this.load.audio('bagSound', 'sounds/가방 여는 소리.wav');
this.load.audio('itemSound', 'sounds/아이템 획득 소리.mp3');
}

function create() {
bgImage = this.add.image(0, 0, 'background').setOrigin(0, 0);

const scaleX = this.cameras.main.width / bgImage.width;
const scaleY = this.cameras.main.height / bgImage.height;

const scale = Math.max(scaleX, scaleY);
bgImage.setScale(scale).setScrollFactor(0);

bgImage.x = this.cameras.main.width / 2 - (bgImage.displayWidth / 2);
bgImage.y = this.cameras.main.height / 2 - (bgImage.displayHeight / 2);

createInventory(this);
hideNavButtons();

// 엘리베이터 관리 영역
createClickableZone(this, 570.5, 128, 347, 240, () => {
const choices = [
{ text: "예", nextAction: () => { window.location.href = 'cable_game.html'; } },
{ text: "아니오", nextAction: () => { showDialogue(["일단 다른 곳부터 조사해보자."]); } }
];
showChoicesDialog(this, choices, "여기서 엘리베이터를 수리할 수 있는 듯하다. \n 엘리베이터 수리를 시도해볼까?", (choice) => {
choice.nextAction();
});
});

// cctv 관리 영역
createClickableZone(this, 1032, 169.5, 276, 195, () => {
showDialogue(["CCTV 화면이 비춰지고 있다.", "...", "응?", "저건.. 강사님?", "노이즈가 껴서 잘 안보이지만 \n 누군가와 대화하고 있는 것처럼 보인다.", "이 건물에 누가 더 있었나?", "5층으로 가서 확인해봐야겠다.", "콰과과과광", "?", "이게 무슨 소리지?"]);
localStorage.setItem('cctvChecked', 'true');
});
bgImage = this.add.image(0, 0, 'background').setOrigin(0, 0);

const scaleX = this.cameras.main.width / bgImage.width;
const scaleY = this.cameras.main.height / bgImage.height;

const scale = Math.max(scaleX, scaleY);
bgImage.setScale(scale).setScrollFactor(0);

bgImage.x = this.cameras.main.width / 2 - (bgImage.displayWidth / 2);
bgImage.y = this.cameras.main.height / 2 - (bgImage.displayHeight / 2);

createInventory(this);
hideNavButtons();

// 엘리베이터 관리 영역
createClickableZone(this, 570.5, 128, 347, 240, () => {
const choices = [
{ text: "예", nextAction: () => { window.location.href = 'cable_game.html'; } },
{ text: "아니오", nextAction: () => { showDialogue(["일단 다른 곳부터 조사해보자."]); } }
];
showChoicesDialog(this, choices, "여기서 엘리베이터를 수리할 수 있는 듯하다. \n 엘리베이터 수리를 시도해볼까?", (choice) => {
choice.nextAction();
});
});

// cctv 관리 영역
createClickableZone(this, 1032, 169.5, 276, 195, () => {
showDialogue(["CCTV 화면이 비춰지고 있다.", "...", "응?", "저건.. 강사님?", "노이즈가 껴서 잘 안보이지만 \n 누군가와 대화하고 있는 것처럼 보인다.", "이 건물에 누가 더 있었나?", "5층으로 가서 확인해봐야겠다.", "콰과과과광", "?", "이게 무슨 소리지?"]);
localStorage.setItem('cctvChecked', 'true');
});

// 비상벨 영역
createClickableZone(this, 1064, 608.5, 428, 219, () => {
if (localStorage.getItem('cctvChecked') === 'true') {
showDialogue(["비상벨 같아 보인다.", "무슨 일인지 아까까지만 해도 아무 문제 없던 비상벨이 \n 큰소리를 내며 울리고 있다.", "바깥에서 난 소리와 관련이 있는 걸까?"]);
} else {
showDialogue(["비상벨 같아 보인다.", "이런 비상 사태에서도 울리지 않다니\n 정말 쓸모없는 비상벨이다."]);
}
});

// 비상벨 영역
createClickableZone(this, 1064, 608.5, 428, 219, () => {
if (localStorage.getItem('cctvChecked') === 'true') {
showDialogue(["비상벨 같아 보인다.", "무슨 일인지 아까까지만 해도 아무 문제 없던 비상벨이 \n 큰소리를 내며 울리고 있다.", "바깥에서 난 소리와 관련이 있는 걸까?"]);
} else {
showDialogue(["비상벨 같아 보인다.", "이런 비상 사태에서도 울리지 않다니\n 정말 쓸모없는 비상벨이다."]);
}
});
dialogBox = this.add.image(this.cameras.main.width / 2, this.cameras.main.height - 100, 'dialogueBox').setOrigin(0.5, 1).setInteractive();
dialogText = this.add.text(this.cameras.main.width / 2, this.cameras.main.height - 120, '', {
fontFamily: 'KyoboHandwriting2023wsa',
fontSize: '35px',
fill: '#000000',
wordWrap: { width: 600, useAdvancedWrap: true }
}).setOrigin(0.5);

dialogBox = this.add.image(this.cameras.main.width / 2, this.cameras.main.height - 100, 'dialogueBox').setOrigin(0.5, 1).setInteractive();
dialogText = this.add.text(this.cameras.main.width / 2, this.cameras.main.height - 120, '', {
fontFamily: 'KyoboHandwriting2023wsa',
fontSize: '35px',
fill: '#000000',
wordWrap: { width: 600, useAdvancedWrap: true }
}).setOrigin(0.5);
dialogBox.setVisible(false);
dialogText.setVisible(false);

dialogBox.setVisible(false);
dialogText.setVisible(false);
// 추가된 부분: 클릭 시 마우스 좌표를 콘솔에 출력
this.input.on('pointerdown', function (pointer) {
console.log(`Mouse X: ${pointer.x}, Mouse Y: ${pointer.y}`);
});

// 추가된 부분: 클릭 시 마우스 좌표를 콘솔에 출력
this.input.on('pointerdown', function (pointer) {
console.log(`Mouse X: ${pointer.x}, Mouse Y: ${pointer.y}`);
});
// back-button 설정
document.getElementById('back-button').style.display = 'block';
}

// back-button 설정
document.getElementById('back-button').style.display = 'block';
}

function createClickableZone(scene, x, y, width, height, clickHandler) {
const zone = scene.add.zone(x, y, width, height).setOrigin(0.5).setInteractive();
Expand Down
12 changes: 11 additions & 1 deletion BitCamp/201Room.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,21 @@
overlay = scene.add.rectangle(scene.cameras.main.centerX, scene.cameras.main.centerY, bgImage.width, bgImage.height, 0x000000, 0.5);
overlay.setAlpha(0);

modalBackground = scene.add.rectangle(scene.cameras.main.centerX, scene.cameras.main.centerY - 180, 800, 300, 0xFFFAFA).setAlpha(0).setInteractive().setScrollFactor(0); // 배경색 변경 예시
modalBackground = scene.add.rectangle(scene.cameras.main.centerX, scene.cameras.main.centerY - 180, 800, 300, 0xFFFAFA).setAlpha(0).setInteractive().setScrollFactor(0);
modalText = scene.add.text(scene.cameras.main.centerX, 60, '소지품', {
fontFamily: 'KyoboHandwriting2023wsa',
fontSize: '24px',
fill: '#000000'
}).setAlpha(0).setOrigin(0.5).setScrollFactor(0);
modal = scene.add.container(0, 0, [modalBackground, modalText]).setAlpha(0);

// Load items from local storage
inventory = JSON.parse(localStorage.getItem('inventory')) || [];
inventoryImages = JSON.parse(localStorage.getItem('inventoryImages')) || [];
updateInventoryDisplay();
};


const addItemToInventory = (item, imageKey) => {
if (!inventory.includes(item)) {
inventory.push(item);
Expand Down Expand Up @@ -342,6 +348,10 @@
this.load.image('key', 'images/key.png');
this.load.image('exitkey', 'images/exitkey.png');
this.load.image('confirmBox', 'images/dialogueBox.png');
this.load.image('photo', 'images/photo.png');
this.load.image('photo_enlarge', 'images/photograph.png');
this.load.image('newspaper', 'images/newspaper.png');
this.load.image('newspaper_enlarge', 'images/newspaper_enlarge.png');
this.load.audio('drawerSound', 'sounds/서랍 여는 소리.mp3');
this.load.audio('doorstopSound', 'sounds/문 덜컹덜컹.mp3');
this.load.audio('bagSound', 'sounds/가방 여는 소리.wav');
Expand Down
73 changes: 42 additions & 31 deletions BitCamp/floor1.html
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,18 @@

// 엘리베이터 클릭 영역
createClickableZone(scene, 1309.5, 261, 321, 296, () => {
const hasNewspaper = inventory.includes("옛날 신문기사");
const hasPhoto = inventory.includes("누군가의 옛날 사진");
if (cctvChecked && elevatorRepairCompleted) {
showDialogue(["엘리베이터는 이제 작동한다.", "5층으로 이동할 수 있다."]);
localStorage.setItem('cctvChecked', 'false');
localStorage.setItem('elevatorRepairCompleted', 'false');
setTimeout(() => {
window.location.href = 'floor5_endN.html';
if (hasNewspaper && hasPhoto) {
window.location.href = 'floor5_endT.html';
} else {
window.location.href = 'floor5_endN.html';
}
}, 3000); // 3초 후 페이지 이동
} else if (localStorage.getItem('cctvChecked') === 'true') {
showDialogue(["아직도 엘리베이터는 작동할 기미가 보이지 않는다.", "방재실에서 수리할 방법을 찾아봐야할 것 같다."]);
Expand Down Expand Up @@ -510,48 +516,53 @@
this.load.image('dialogueBox', 'images/wallpaper-torn-paper-ripped-white-paper.png');
this.load.image('bag', 'images/bag.svg');
this.load.image('key', 'images/key.png');
this.load.image('photo', 'images/photo.png');
this.load.image('photo_enlarge', 'images/photograph.png');
this.load.image('newspaper', 'images/newspaper.png');
this.load.image('newspaper_enlarge', 'images/newspaper_enlarge.png');
this.load.audio('doorstopSound', 'sounds/문 덜컹덜컹.mp3');
this.load.audio('bagSound', 'sounds/가방 여는 소리.wav');
this.load.audio('itemSound', 'sounds/아이템 획득 소리.mp3');
}

function create() {
bgImage = this.add.image(0, 0, 'background').setOrigin(0, 0);
bgImage = this.add.image(0, 0, 'background').setOrigin(0, 0);

let scaleX = config.width / bgImage.width;
let scaleY = config.height / bgImage.height;
let scale = Math.max(scaleX, scaleY);
let scaleX = config.width / bgImage.width;
let scaleY = config.height / bgImage.height;
let scale = Math.max(scaleX, scaleY);

bgImage.setScale(scale).setOrigin(0, 0);
bgImage.setScale(scale).setOrigin(0, 0);

camera = this.cameras.main;
camera.setViewport(0, 0, config.width, config.height);
camera = this.cameras.main;
camera.setViewport(0, 0, config.width, config.height);

sectionWidth = (bgImage.displayWidth - config.width) / (totalSections - 1);
sectionWidth = (bgImage.displayWidth - config.width) / (totalSections - 1);

dialogBox = this.add.image(config.width / 2, 530, 'dialogueBox').setOrigin(0.5, 0).setInteractive();
dialogBox.setVisible(false);
dialogBox = this.add.image(config.width / 2, 530, 'dialogueBox').setOrigin(0.5, 0).setInteractive();
dialogBox.setVisible(false);

dialogText = this.add.text(config.width / 2, config.height - 70, '', {
fontFamily: 'KyoboHandwriting2023wsa',
fontSize: '35px',
fill: '#000000',
wordWrap: { width: 1000, useAdvancedWrap: true }
}).setOrigin(0.5).setAlign('center');
dialogText.setVisible(false);

createInventory(this);
loadInventoryFromLocalStorage();
updateInventoryDisplay();
createClickableAreas(this);

// 마우스 클릭 이벤트 리스너 수정
this.input.on('pointerdown', function (pointer) {
const x = pointer.x + camera.scrollX; // 현재 카메라의 스크롤 위치를 고려한 X 좌표
const y = pointer.y + camera.scrollY; // 현재 카메라의 스크롤 위치를 고려한 Y 좌표
console.log(`Mouse X: ${x}, Mouse Y: ${y}`);
});
}

dialogText = this.add.text(config.width / 2, config.height - 70, '', {
fontFamily: 'KyoboHandwriting2023wsa',
fontSize: '35px',
fill: '#000000',
wordWrap: { width: 1000, useAdvancedWrap: true }
}).setOrigin(0.5).setAlign('center');
dialogText.setVisible(false);

createInventory(this);
loadInventoryFromLocalStorage();
updateInventoryDisplay();
createClickableAreas(this);

// 마우스 클릭 이벤트 리스너 수정
this.input.on('pointerdown', function (pointer) {
const x = pointer.x + camera.scrollX; // 현재 카메라의 스크롤 위치를 고려한 X 좌표
const y = pointer.y + camera.scrollY; // 현재 카메라의 스크롤 위치를 고려한 Y 좌표
console.log(`Mouse X: ${x}, Mouse Y: ${y}`);
});
}

function update() {
dialogBox.x = camera.scrollX + config.width / 2;
Expand Down
5 changes: 5 additions & 0 deletions BitCamp/floor2.html
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,13 @@
this.load.image('dialogueBox', 'images/wallpaper-torn-paper-ripped-white-paper.png');
this.load.image('bag', 'images/bag.svg');
this.load.image('key', 'images/key.png');
this.load.image('photo', 'images/photo.png');
this.load.image('photo_enlarge', 'images/photograph.png');
this.load.image('newspaper', 'images/newspaper.png');
this.load.image('newspaper_enlarge', 'images/newspaper_enlarge.png');
this.load.audio('doorstopSound', 'sounds/문 덜컹덜컹.mp3');
this.load.audio('bagSound', 'sounds/가방 여는 소리.wav');

}

function create() {
Expand Down
Loading

0 comments on commit 522fb56

Please sign in to comment.