Add: ExtractWordManager
This commit is contained in:
@@ -0,0 +1,158 @@
|
|||||||
|
function ExtractWordManager() {
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
ExtractWordManager.prototype.init = function() {
|
||||||
|
this.contents = [];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
this.wordList = [];
|
||||||
|
|
||||||
|
this.wordList[0] = "hello";
|
||||||
|
this.wordList[1] = "world";
|
||||||
|
|
||||||
|
this.wordIndex = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ExtractWordManager.prototype.getWord = function(wordLevel, difficulty) {
|
||||||
|
this.wordIndex = 1 - this.wordIndex;
|
||||||
|
return this.wordList[this.wordIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
ExtractWordManager.prototype.removeWord = function(wordLevel, word) {
|
||||||
|
console.log("remove : " + wordLevel + ", " + word);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ExtractWordManager.prototype.getContents = function() {
|
||||||
|
return this.contents;
|
||||||
|
}
|
||||||
|
|
||||||
|
ExtractWordManager.prototype.add = function(arr) {
|
||||||
|
this.contents = this.contents.concat(arr);
|
||||||
|
}
|
||||||
|
|
||||||
|
ExtractWordManager.prototype.slice = function(start, end) {
|
||||||
|
this.contents = this.contents.slice(start, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
ExtractWordManager.prototype.getShuffledArray = function(arr) {
|
||||||
|
return Phaser.ArrayUtils.shuffle(arr);
|
||||||
|
}
|
||||||
|
|
||||||
|
ExtractWordManager.prototype.fillLeftRightBasicKey = function() {
|
||||||
|
var length = this.contents.length;
|
||||||
|
// console.log(length);
|
||||||
|
|
||||||
|
for(var i = length - 1; i > -1; i--) {
|
||||||
|
var char = this.contents[i];
|
||||||
|
// console.log(char);
|
||||||
|
if(this.isKoreanConsonant(char)) {
|
||||||
|
this.contents.splice(i + 1, 0, "ㅓ");
|
||||||
|
} else if(this.isKoreanVowel(char)) {
|
||||||
|
this.contents.splice(i, 0, "ㄹ");
|
||||||
|
} else if(this.isEnglishLeftHand(char)) {
|
||||||
|
this.contents.splice(i + 1, 0, "j");
|
||||||
|
} else if(this.isEnglishRightHand(char)) {
|
||||||
|
this.contents.splice(i, 0, "f");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ExtractWordManager.prototype.isKoreanConsonant = function(char) {
|
||||||
|
if(char.length != 1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(ExtractWordManager.KOREAN_LETTER_CHO.indexOf(char) > -1)
|
||||||
|
return true;
|
||||||
|
else if(ExtractWordManager.KOREAN_LETTER_JONG.indexOf(char) > -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ExtractWordManager.prototype.isKoreanVowel = function(char) {
|
||||||
|
if(char.length != 1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(ExtractWordManager.KOREAN_LETTER_JUNG.indexOf(char) > -1)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ExtractWordManager.prototype.isEnglishLeftHand = function(char) {
|
||||||
|
if(char.length != 1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(ExtractWordManager.ENGLISH_LETTER_LEFT.indexOf(char) > -1)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ExtractWordManager.prototype.isEnglishRightHand = function(char) {
|
||||||
|
if(char.length != 1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(ExtractWordManager.ENGLISH_LETTER_RIGHT.indexOf(char) > -1)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ExtractWordManager.prototype.makePracticeContents = function(arr, repeatCount) {
|
||||||
|
this.init();
|
||||||
|
this.add(arr);
|
||||||
|
for(var i = 0; i < repeatCount; i++) {
|
||||||
|
this.add(this.getShuffledArray(arr));
|
||||||
|
}
|
||||||
|
this.fillLeftRightBasicKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
ExtractWordManager.prototype.makeTestContents = function(arr) {
|
||||||
|
this.init();
|
||||||
|
this.add(this.getShuffledArray(arr));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ExtractWordManager.shuffledArray = function(arr) {
|
||||||
|
return Phaser.ArrayUtils.shuffle(arr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ExtractWordManager.KOREAN_LETTER_CHO = [
|
||||||
|
"ㄱ", "ㄲ", "ㄴ", "ㄷ", "ㄸ", "ㄹ", "ㅁ", "ㅂ", "ㅃ", "ㅅ",
|
||||||
|
"ㅆ", "ㅇ", "ㅈ", "ㅉ", "ㅊ", "ㅋ", "ㅌ", "ㅍ", "ㅎ"
|
||||||
|
];
|
||||||
|
|
||||||
|
ExtractWordManager.KOREAN_LETTER_JUNG = [
|
||||||
|
"ㅏ", "ㅐ", "ㅑ", "ㅒ", "ㅓ", "ㅔ", "ㅕ", "ㅖ", "ㅗ", "ㅘ",
|
||||||
|
"ㅙ", "ㅚ", "ㅛ", "ㅜ", "ㅝ", "ㅞ", "ㅟ", "ㅠ", "ㅡ", "ㅢ", "ㅣ"
|
||||||
|
];
|
||||||
|
|
||||||
|
ExtractWordManager.KOREAN_LETTER_JONG = [
|
||||||
|
"", "ㄱ", "ㄲ", "ㄳ", "ㄴ", "ㄵ", "ㄶ", "ㄷ", "ㄹ", "ㄺ",
|
||||||
|
"ㄻ", "ㄼ", "ㄽ", "ㄾ", "ㄿ", "ㅀ", "ㅁ", "ㅂ", "ㅄ", "ㅅ",
|
||||||
|
"ㅆ", "ㅇ", "ㅈ", "ㅊ", "ㅋ", "ㅌ", "ㅍ", "ㅎ"
|
||||||
|
];
|
||||||
|
|
||||||
|
ExtractWordManager.ENGLISH_LETTER_LEFT = [
|
||||||
|
"q", "w", "e", "r", "t",
|
||||||
|
"a", "s", "d", "f", "g",
|
||||||
|
"z", "x", "c", "v", "b"
|
||||||
|
];
|
||||||
|
|
||||||
|
ExtractWordManager.ENGLISH_LETTER_RIGHT = [
|
||||||
|
"y", "u", "i", "o", "p",
|
||||||
|
"h", "j", "k", "l",
|
||||||
|
"n", "m"
|
||||||
|
];
|
||||||
@@ -55,7 +55,7 @@ FlyingSaucer.prototype.initVariables = function() {
|
|||||||
|
|
||||||
this.scoreManager = null;
|
this.scoreManager = null;
|
||||||
this.heartManager = null;
|
this.heartManager = null;
|
||||||
this.wordManager = null;
|
this.extractWordManager = null;
|
||||||
this.gameLevelManager = null;
|
this.gameLevelManager = null;
|
||||||
|
|
||||||
this.timerEvent = null;
|
this.timerEvent = null;
|
||||||
@@ -143,8 +143,8 @@ FlyingSaucer.prototype.setHeartManager = function(heartManager) {
|
|||||||
this.heartManager = heartManager;
|
this.heartManager = heartManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
FlyingSaucer.prototype.setWordManager = function(wordManager) {
|
FlyingSaucer.prototype.setExtractWordManager = function(extractWordManager) {
|
||||||
this.wordManager = wordManager;
|
this.extractWordManager = extractWordManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
FlyingSaucer.prototype.setGameLevelManager = function(gameLevelManager) {
|
FlyingSaucer.prototype.setGameLevelManager = function(gameLevelManager) {
|
||||||
@@ -191,7 +191,7 @@ FlyingSaucer.prototype.moveInitialPos = function() {
|
|||||||
FlyingSaucer.prototype.startAttack = function() {
|
FlyingSaucer.prototype.startAttack = function() {
|
||||||
this.wordLevel = this.gameLevelManager.getWordLevel();
|
this.wordLevel = this.gameLevelManager.getWordLevel();
|
||||||
this.difficulty = this.gameLevelManager.getDifficulty();
|
this.difficulty = this.gameLevelManager.getDifficulty();
|
||||||
this.word = this.wordManager.getWord(this.wordLevel, this.difficulty);
|
this.word = this.extractWordManager.getWord(this.wordLevel, this.difficulty);
|
||||||
this.setWord(this.word);
|
this.setWord(this.word);
|
||||||
this.standardScore = this.gameLevelManager.getStandardScore(this.wordLevel, this.speed);
|
this.standardScore = this.gameLevelManager.getStandardScore(this.wordLevel, this.speed);
|
||||||
// console.log(this.standardScore);
|
// console.log(this.standardScore);
|
||||||
@@ -241,7 +241,7 @@ FlyingSaucer.prototype.checkWord = function(inputText) {
|
|||||||
|
|
||||||
if(this.word == inputText) {
|
if(this.word == inputText) {
|
||||||
this.gameLevelManager.clearWord(this.wordLevel, this.getLandingRatio());
|
this.gameLevelManager.clearWord(this.wordLevel, this.getLandingRatio());
|
||||||
this.wordManager.removeWord(this.wordLevel, this.word);
|
this.extractWordManager.removeWord(this.wordLevel, this.word);
|
||||||
this.setWord("");
|
this.setWord("");
|
||||||
this.setActive(false);
|
this.setActive(false);
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ var WordFlyingSaucer = {
|
|||||||
this.flyingsaucers[i] = new FlyingSaucer(i);
|
this.flyingsaucers[i] = new FlyingSaucer(i);
|
||||||
this.flyingsaucers[i].setScoreManager(this.scoreManager);
|
this.flyingsaucers[i].setScoreManager(this.scoreManager);
|
||||||
this.flyingsaucers[i].setHeartManager(this.heartManager);
|
this.flyingsaucers[i].setHeartManager(this.heartManager);
|
||||||
this.flyingsaucers[i].setWordManager(this.wordManager);
|
this.flyingsaucers[i].setExtractWordManager(this.extractWordManager);
|
||||||
this.flyingsaucers[i].setGameLevelManager(this.gameLevelManager);
|
this.flyingsaucers[i].setGameLevelManager(this.gameLevelManager);
|
||||||
this.flyingsaucers[i].setActive(true);
|
this.flyingsaucers[i].setActive(true);
|
||||||
this.flyingsaucers[i].startAttack();
|
this.flyingsaucers[i].startAttack();
|
||||||
@@ -104,7 +104,7 @@ var WordFlyingSaucer = {
|
|||||||
|
|
||||||
|
|
||||||
initVariables: function() {
|
initVariables: function() {
|
||||||
this.wordManager = new WordManager();
|
this.extractWordManager = new ExtractWordManager();
|
||||||
this.gameLevelManager = new GameLevelManager();
|
this.gameLevelManager = new GameLevelManager();
|
||||||
|
|
||||||
this.speedLevel = 0;
|
this.speedLevel = 0;
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
function TypingScore() {
|
|
||||||
this.typingCount = 0;
|
|
||||||
|
|
||||||
var fontStyle = TypingScore.DEFAULT_TEXT_FONT;
|
|
||||||
|
|
||||||
fontStyle.align = "right";
|
|
||||||
fontStyle.boundsAlignH = "right";
|
|
||||||
this.scoreTitleText = game.add.text(game.world.width / 2 - 40, TypingScore.SCORE_POS_Y, "연속 성공 타수 : ", fontStyle)
|
|
||||||
this.scoreTitleText.anchor.set(0.5);
|
|
||||||
|
|
||||||
fontStyle.align = "left";
|
|
||||||
fontStyle.boundsAlignH = "left";
|
|
||||||
this.scoreText = game.add.text(game.world.width / 2 + 100, TypingScore.SCORE_POS_Y, "0", fontStyle)
|
|
||||||
this.scoreText.anchor.set(0.5);
|
|
||||||
|
|
||||||
// var grd = this.scoreText.context.createLinearGradient(0, 0, 0, TypingScore.SCORE_POS_Y);
|
|
||||||
// grd.addColorStop(0, '#8ED6FF');
|
|
||||||
// grd.addColorStop(1, '#004CB3');
|
|
||||||
// this.scoreText.fill = grd;
|
|
||||||
// this.scoreText.fill = grd;
|
|
||||||
|
|
||||||
// this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
|
||||||
// this.scoreText.stroke = '#000';
|
|
||||||
// this.scoreText.strokeThickness = 3;
|
|
||||||
};
|
|
||||||
|
|
||||||
TypingScore.prototype.score = function() {
|
|
||||||
return this.typingCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
TypingScore.prototype.increase = function() {
|
|
||||||
this.typingCount++;
|
|
||||||
this.print(this.typingCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
TypingScore.prototype.reset = function() {
|
|
||||||
this.typingCount = 0;
|
|
||||||
this.print(this.typingCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
TypingScore.prototype.print = function(typingCount) {
|
|
||||||
this.scoreText.text = typingCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
TypingScore.SCORE_POS_Y = 35;
|
|
||||||
|
|
||||||
TypingScore.DEFAULT_TEXT_FONT = {
|
|
||||||
font: "38px Arial",
|
|
||||||
align: "center",
|
|
||||||
boundsAlignH: "center", // left, center. right
|
|
||||||
boundsAlignV: "middle", // top, middle, bottom
|
|
||||||
fill: "#fff"
|
|
||||||
};
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
function WordManager() {
|
|
||||||
this.wordList = [];
|
|
||||||
|
|
||||||
this.wordList[0] = "hello";
|
|
||||||
this.wordList[1] = "world";
|
|
||||||
|
|
||||||
this.wordIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
WordManager.prototype.getWord = function(wordLevel, difficulty) {
|
|
||||||
this.wordIndex = 1 - this.wordIndex;
|
|
||||||
return this.wordList[this.wordIndex];
|
|
||||||
}
|
|
||||||
|
|
||||||
WordManager.prototype.removeWord = function(wordLevel, word) {
|
|
||||||
console.log("remove : " + wordLevel + ", " + word);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -85,10 +85,9 @@
|
|||||||
<script src="../../game/typing/word_list/english_word.js"></script>
|
<script src="../../game/typing/word_list/english_word.js"></script>
|
||||||
|
|
||||||
<!-- Shoot down! flyingsaucer : source files -->
|
<!-- Shoot down! flyingsaucer : source files -->
|
||||||
<script src="../../game/typing/lib/typing_text_manager.js"></script>
|
|
||||||
<script src="../../game/typing/lib/typing_content_bg.js"></script>
|
<script src="../../game/typing/lib/typing_content_bg.js"></script>
|
||||||
|
<script src="../../game/typing/lib/extract_word_manager.js"></script>
|
||||||
|
|
||||||
<script src="../../game/typing/word_flyingsaucer/word_manager.js"></script>
|
|
||||||
<script src="../../game/typing/word_flyingsaucer/game_level_manager.js"></script>
|
<script src="../../game/typing/word_flyingsaucer/game_level_manager.js"></script>
|
||||||
<script src="../../game/typing/word_flyingsaucer/loading.js"></script>
|
<script src="../../game/typing/word_flyingsaucer/loading.js"></script>
|
||||||
<script src="../../game/typing/word_flyingsaucer/flyingsaucer.js"></script>
|
<script src="../../game/typing/word_flyingsaucer/flyingsaucer.js"></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user