public/survivor/survivor.js
/**
 * @param difficulty Number between 1 and 3
 */
@param difficulty Number between 1 and 3
@param difficulty Number between 1 and 3
function initSkillCheck(difficulty = 2) {
    console.log("init Skillcheck ")
    if (difficulty > 3 || difficulty < 1) {
        console.exception("Wrong Skill Check Init Parameter! Read Commentary!");
        difficulty = 1;
    }
    if (skillcheck.active)
        if (skillcheck.progress <= 100)
            return;
    let successAreaSize = 10 + 10 / difficulty;
    skillcheck.progress = -50;
    skillcheck.posOkStart = Math.random() * (100 - successAreaSize);
    skillcheck.posOkEnd = skillcheck.posOkStart + successAreaSize;
    skillcheck.timeStep = 0.5 + 2 / difficulty;
    skillcheck.active = true;
    console.log(skillcheck)
    let c = document.getElementById("skillCheckSucessArea");
    let ctx = c.getContext("2d");
    ctx.clearRect(0, 0, c.width, c.height);
    ctx.beginPath();
    ctx.arc(150, 150, 150, 2 * Math.PI / 100 * skillcheck.posOkStart - Math.PI / 2, 2 * Math.PI / 100 * skillcheck.posOkEnd - Math.PI / 2);
    ctx.strokeStyle = '#CC4400';
    ctx.lineWidth = 10
    ctx.stroke();
    skillCheckPointer.style.visibility = "visible";
    function processSkillcheck() {
        if (!skillcheck.active) clearInterval(activeSkillcheck);
        skillcheck.progress = skillcheck.progress + skillcheck.timeStep;
        console.log("ActiveSkillCheck")
        let rotation = 360 / 100 * skillcheck.progress
        if (skillcheck.progress > 0) {
            skillCheckSucessArea.style.visibility = 'visible';
            skillCheckPointer.style.transform = 'rotate(' + rotation + 'deg)';
        }
        if (skillcheck.progress > 100) {
            stopSkillCheck()
            playSoundSkillCheckFail();
        }
    }
    activeSkillcheck = setInterval(processSkillcheck, 20);
}
function initSkillCheck ( difficulty = 2 ) { console . log ( "init Skillcheck " ) if ( difficulty > 3 || difficulty < 1 ) { console . exception ( "Wrong Skill Check Init Parameter! Read Commentary!" ) ; difficulty = 1 ; } if ( skillcheck . active ) if ( skillcheck . progress <= 100 ) return ; let successAreaSize = 10 + 10 / difficulty ; skillcheck . progress = - 50 ; skillcheck . posOkStart = Math . random ( ) * ( 100 - successAreaSize ) ; skillcheck . posOkEnd = skillcheck . posOkStart + successAreaSize ; skillcheck . timeStep = 0.5 + 2 / difficulty ; skillcheck . active = true ; console . log ( skillcheck ) let c = document . getElementById ( "skillCheckSucessArea" ) ; let ctx = c . getContext ( "2d" ) ; ctx . clearRect ( 0 , 0 , c . width , c . height ) ; ctx . beginPath ( ) ; ctx . arc ( 150 , 150 , 150 , 2 * Math . PI / 100 * skillcheck . posOkStart - Math . PI / 2 , 2 * Math . PI / 100 * skillcheck . posOkEnd - Math . PI / 2 ) ; ctx . strokeStyle = '#CC4400' ; ctx . lineWidth = 10 ctx . stroke ( ) ; skillCheckPointer . style . visibility = "visible" ; function processSkillcheck ( ) { if ( ! skillcheck . active ) clearInterval ( activeSkillcheck ) ; skillcheck . progress = skillcheck . progress + skillcheck . timeStep ; console . log ( "ActiveSkillCheck" ) let rotation = 360 / 100 * skillcheck . progress if ( skillcheck . progress > 0 ) { skillCheckSucessArea . style . visibility = 'visible' ; skillCheckPointer . style . transform = 'rotate(' + rotation + 'deg)' ; } if ( skillcheck . progress > 100 ) { stopSkillCheck ( ) playSoundSkillCheckFail ( ) ; } } activeSkillcheck = setInterval ( processSkillcheck , 20 ) ; }
@param difficulty Number between 1 and 3
@param difficulty Number between 1 and 3
// skillCheckPointer.style.backgroundColor = "green" //Init UI Skill check here //skillCheckSucessArea //Update UI Skill check here // skillCheckPointer.style.backgroundColor = "red"