Game: Improve gauge

This commit is contained in:
LoveEevee 2020-03-05 18:58:49 +03:00
parent 09c212df8b
commit 41afc2a905
7 changed files with 94 additions and 42 deletions

View File

@ -1347,10 +1347,10 @@
var secondTop = config.multiplayer ? 0 : 8 var secondTop = config.multiplayer ? 0 : 8
config.percentage = Math.max(0, Math.min(1, config.percentage)) config.percentage = Math.max(0, Math.min(1, config.percentage))
var cleared = config.percentage - 1 / 50 >= config.clear var cleared = config.percentage >= config.clear
var gaugeW = 14 * 50 var gaugeW = 14 * 50
var gaugeClear = gaugeW * config.clear var gaugeClear = gaugeW * (config.clear - 1 / 50)
var gaugeFilled = gaugeW * config.percentage var gaugeFilled = gaugeW * config.percentage
ctx.fillStyle = "#000" ctx.fillStyle = "#000"

View File

@ -171,7 +171,7 @@ class Controller{
gameEnded(){ gameEnded(){
var score = this.getGlobalScore() var score = this.getGlobalScore()
var vp var vp
if(Math.round(score.gauge / 2) - 1 >= 25){ if(this.game.rules.clearReached(score.gauge)){
if(score.bad === 0){ if(score.bad === 0){
vp = "fullcombo" vp = "fullcombo"
this.playSound("v_fullcombo", 1.350) this.playSound("v_fullcombo", 1.350)

View File

@ -18,10 +18,11 @@ class Game{
title: selectedSong.title, title: selectedSong.title,
difficulty: this.rules.difficulty difficulty: this.rules.difficulty
} }
this.HPGain = 100 / this.songData.circles.filter(circle => { var combo = this.songData.circles.filter(circle => {
var type = circle.type var type = circle.type
return (type === "don" || type === "ka" || type === "daiDon" || type === "daiKa") && (!circle.branch || circle.branch.active) return (type === "don" || type === "ka" || type === "daiDon" || type === "daiKa") && (!circle.branch || circle.branch.active)
}).length }).length
this.soulPoints = this.rules.soulPoints(combo)
this.paused = false this.paused = false
this.started = false this.started = false
this.mainMusicPlaying = false this.mainMusicPlaying = false
@ -628,12 +629,15 @@ class Game{
switch(score){ switch(score){
case 450: case 450:
this.globalScore.good++ this.globalScore.good++
this.globalScore.gauge += this.soulPoints.good
break break
case 230: case 230:
this.globalScore.ok++ this.globalScore.ok++
this.globalScore.gauge += this.soulPoints.ok
break break
case 0: case 0:
this.globalScore.bad++ this.globalScore.bad++
this.globalScore.gauge += this.soulPoints.bad
break break
} }
if (this.songData.scoremode) { if (this.songData.scoremode) {
@ -647,12 +651,10 @@ class Game{
} }
} }
// Gauge update // Gauge update
if(score !== 0){ if(this.globalScore.gauge < 0){
this.globalScore.gauge += this.HPGain
}else if(this.globalScore.gauge - this.HPGain > 0){
this.globalScore.gauge -= this.HPGain
}else{
this.globalScore.gauge = 0 this.globalScore.gauge = 0
}else if(this.globalScore.gauge > 10000){
this.globalScore.gauge = 10000
} }
// Points update // Points update
if (this.songData.scoremode == 2) { if (this.songData.scoremode == 2) {
@ -719,10 +721,6 @@ class Game{
this.currentCircle = closestCircle this.currentCircle = closestCircle
} }
} }
this.HPGain = 100 / this.songData.circles.filter(circle => {
var type = circle.type
return (type === "don" || type === "ka" || type === "daiDon" || type === "daiKa") && (!circle.branch || circle.branch.active)
}).length
if(this.controller.multiplayer === 1){ if(this.controller.multiplayer === 1){
p2.send("branch", activeName) p2.send("branch", activeName)
} }

View File

@ -18,7 +18,51 @@ class GameRules{
this.bad = 13 / 2 * frame this.bad = 13 / 2 * frame
break break
} }
switch(this.difficulty){
case "easy":
this.gaugeClear = 30 / 50
break
case "normal":
case "hard":
this.gaugeClear = 35 / 50
break
case "oni":
case "ura":
this.gaugeClear = 40 / 50
break
}
this.daiLeniency = 2 * frame this.daiLeniency = 2 * frame
} }
soulPoints(combo){
var good, ok, bad
switch(this.difficulty){
case "easy":
good = Math.floor(10000 / combo * 1.575)
ok = Math.floor(good * 0.75)
bad = Math.ceil(good * -2)
break
case "normal":
good = Math.floor(10000 / combo / 0.7)
ok = Math.floor(good * 0.75)
bad = Math.ceil(good / -0.75)
break
case "hard":
good = Math.floor(10000 / combo * 1.5)
ok = Math.floor(good * 0.75)
bad = Math.ceil(good / -0.8)
break
case "oni":
case "ura":
good = Math.floor(10000 / combo / 0.7)
ok = Math.floor(good * 0.5)
bad = Math.ceil(good * -1.6)
break
}
return {good: good, ok: ok, bad: bad}
}
clearReached(gauge){
var gaugePercent = Math.round(gauge / 200) / 50
return gaugePercent >= this.gaugeClear
}
} }

View File

@ -319,15 +319,18 @@ class Scoresheet{
var elapsed = 0 var elapsed = 0
} }
var gaugePercent = Math.round(this.results.gauge / 2) / 50 var gaugePercent = Math.round(this.results.gauge / 200) / 50
var gaugeClear = [this.controller.game.rules.gaugeClear]
if(players === 2){ if(players === 2){
var gauge2 = Math.round(p2.results.gauge / 2) / 50 gaugeClear.push(this.controller.syncWith.game.rules.gaugeClear)
if(gauge2 > gaugePercent){ }
gaugePercent = gauge2 var failedOffset = gaugePercent >= gaugeClear[0] ? 0 : -2000
if(players === 2){
var gauge2 = Math.round(p2.results.gauge / 200) / 50
if(gauge2 > gaugePercent && failedOffset !== 0 && gauge2 >= gaugeClear[1]){
failedOffset = 0
} }
} }
var gaugeClear = 25 / 50
var failedOffset = gaugePercent >= gaugeClear ? 0 : -2000
if(elapsed >= 3100 + failedOffset){ if(elapsed >= 3100 + failedOffset){
for(var p = 0; p < players; p++){ for(var p = 0; p < players; p++){
ctx.save() ctx.save()
@ -335,8 +338,8 @@ class Scoresheet{
if(p === 1){ if(p === 1){
results = p2.results results = p2.results
} }
var resultGauge = Math.round(results.gauge / 2) / 50 var resultGauge = Math.round(results.gauge / 200) / 50
var clear = resultGauge >= gaugeClear var clear = resultGauge >= gaugeClear[p]
if(p === 1 || !this.multiplayer && clear){ if(p === 1 || !this.multiplayer && clear){
ctx.translate(0, 290) ctx.translate(0, 290)
} }
@ -570,7 +573,7 @@ class Scoresheet{
if(this.tetsuoHanaClass){ if(this.tetsuoHanaClass){
this.tetsuoHana.classList.remove(this.tetsuoHanaClass) this.tetsuoHana.classList.remove(this.tetsuoHanaClass)
} }
this.tetsuoHanaClass = gaugePercent >= gaugeClear ? "dance" : "failed" this.tetsuoHanaClass = this.controller.game.rules.clearReached(this.results.gauge) ? "dance" : "failed"
this.tetsuoHana.classList.add(this.tetsuoHanaClass) this.tetsuoHana.classList.add(this.tetsuoHanaClass)
} }
} }
@ -589,25 +592,26 @@ class Scoresheet{
results = p2.results results = p2.results
ctx.translate(0, p2Offset) ctx.translate(0, p2Offset)
} }
var gaugePercent = Math.round(results.gauge / 2) / 50 var gaugePercent = Math.round(results.gauge / 200) / 50
var w = 712 var w = 712
this.draw.gauge({ this.draw.gauge({
ctx: ctx, ctx: ctx,
x: 558 + w, x: 558 + w,
y: 116, y: 116,
clear: 25 / 50, clear: gaugeClear[p],
percentage: gaugePercent, percentage: gaugePercent,
font: this.font, font: this.font,
scale: w / 788, scale: w / 788,
scoresheet: true, scoresheet: true,
blue: p === 1 blue: p === 1
}) })
var rules = p === 0 ? this.controller.game.rules : this.controller.syncWith.game.rules
this.draw.soul({ this.draw.soul({
ctx: ctx, ctx: ctx,
x: 1215, x: 1215,
y: 144, y: 144,
scale: 36 / 42, scale: 36 / 42,
cleared: gaugePercent - 1 / 50 >= 25 / 50 cleared: rules.clearReached(results.gauge)
}) })
} }
}) })
@ -625,7 +629,8 @@ class Scoresheet{
results = p2.results results = p2.results
} }
var crownType = null var crownType = null
if(Math.round(results.gauge / 2) - 1 >= 25){ var rules = p === 0 ? this.controller.game.rules : this.controller.syncWith.game.rules
if(rules.clearReached(results.gauge)){
crownType = results.bad === "0" ? "gold" : "silver" crownType = results.bad === "0" ? "gold" : "silver"
} }
if(crownType !== null){ if(crownType !== null){

View File

@ -17,6 +17,7 @@
this.songBg = document.getElementById("songbg") this.songBg = document.getElementById("songbg")
this.songStage = document.getElementById("song-stage") this.songStage = document.getElementById("song-stage")
this.rules = this.controller.game.rules
this.portraitClass = false this.portraitClass = false
this.touchp2Class = false this.touchp2Class = false
this.darkDonBg = false this.darkDonBg = false
@ -347,7 +348,7 @@
} }
var score = this.controller.getGlobalScore() var score = this.controller.getGlobalScore()
var gaugePercent = Math.round(score.gauge / 2) / 50 var gaugePercent = Math.round(score.gauge / 200) / 50
if(this.multiplayer === 2){ if(this.multiplayer === 2){
var scoreImg = "bg_score_p2" var scoreImg = "bg_score_p2"
@ -497,7 +498,7 @@
ctx: ctx, ctx: ctx,
x: winW, x: winW,
y: this.multiplayer === 2 ? 468 : 273, y: this.multiplayer === 2 ? 468 : 273,
clear: 25 / 50, clear: this.rules.gaugeClear,
percentage: gaugePercent, percentage: gaugePercent,
font: this.font, font: this.font,
scale: 0.7, scale: 0.7,
@ -509,7 +510,7 @@
x: winW - 40, x: winW - 40,
y: this.multiplayer === 2 ? 484 : 293, y: this.multiplayer === 2 ? 484 : 293,
scale: 0.75, scale: 0.75,
cleared: gaugePercent - 1 / 50 >= 25 / 50 cleared: this.rules.clearReached(score.gauge)
}) })
// Note bar // Note bar
@ -572,7 +573,7 @@
ctx: ctx, ctx: ctx,
x: winW, x: winW,
y: this.multiplayer === 2 ? 357 : 135, y: this.multiplayer === 2 ? 357 : 135,
clear: 25 / 50, clear: this.rules.gaugeClear,
percentage: gaugePercent, percentage: gaugePercent,
font: this.font, font: this.font,
multiplayer: this.multiplayer === 2, multiplayer: this.multiplayer === 2,
@ -582,7 +583,7 @@
ctx: ctx, ctx: ctx,
x: winW - 57, x: winW - 57,
y: this.multiplayer === 2 ? 378 : 165, y: this.multiplayer === 2 ? 378 : 165,
cleared: gaugePercent - 1 / 50 >= 25 / 50 cleared: this.rules.clearReached(score.gauge)
}) })
// Note bar // Note bar
@ -1881,8 +1882,8 @@
} }
}else{ }else{
var animation = this.assets.don.getAnimation() var animation = this.assets.don.getAnimation()
var gauge = this.controller.getGlobalScore().gauge var score = this.controller.getGlobalScore()
var cleared = Math.round(gauge / 2) - 1 >= 25 var cleared = this.rules.clearReached(score.gauge)
if(animation === "gogo" || cleared && animation === "normal" || !cleared && animation === "clear"){ if(animation === "gogo" || cleared && animation === "normal" || !cleared && animation === "clear"){
this.assets.don.normalAnimation() this.assets.don.normalAnimation()
} }

View File

@ -42,16 +42,20 @@ class ViewAssets{
var length = this.don.getAnimationLength("gogo") var length = this.don.getAnimationLength("gogo")
this.don.setUpdateSpeed(4 / length) this.don.setUpdateSpeed(4 / length)
this.don.setAnimation("gogo") this.don.setAnimation("gogo")
}else if(Math.round(this.controller.getGlobalScore().gauge / 2) - 1 >= 25){
this.don.setAnimationStart(0)
var length = this.don.getAnimationLength("clear")
this.don.setUpdateSpeed(2 / length)
this.don.setAnimation("clear")
}else{ }else{
this.don.setAnimationStart(0) var score = this.controller.getGlobalScore()
var length = this.don.getAnimationLength("normal") var cleared = this.controller.game.rules.clearReached(score.gauge)
this.don.setUpdateSpeed(4 / length) if(cleared){
this.don.setAnimation("normal") this.don.setAnimationStart(0)
var length = this.don.getAnimationLength("clear")
this.don.setUpdateSpeed(2 / length)
this.don.setAnimation("clear")
}else{
this.don.setAnimationStart(0)
var length = this.don.getAnimationLength("normal")
this.don.setUpdateSpeed(4 / length)
this.don.setAnimation("normal")
}
} }
} }
this.don.addFrames("clear", 30, "don_anim_clear") this.don.addFrames("clear", 30, "don_anim_clear")