// ScoreManager handles all of the scoring
    void ScoreManager(ScoreEvent sEvt)
    {
        List <Vector3> fsPts;

        switch (sEvt)
        {
        // Same things need to happen whether it's a draw, a win, or a loss
        case ScoreEvent.draw:     // Drawing a card
        case ScoreEvent.gameWin:  // Won the round
        case ScoreEvent.gameLoss: // Lost the round
            chain    = 0;         // resets the score chain
            score   += scoreRun;  // add scoreRun to total score
            scoreRun = 0;         // reset scoreRun
            // Add fsRun to the _Scoreboard score
            if (fsRun != null)
            {
                // Create points for the Bezier curve
                fsPts = new List <Vector3>();
                fsPts.Add(fsPosRun);
                fsPts.Add(fsPosMid2);
                fsPts.Add(fsPosEnd);
                fsRun.reportFinishTo = Scoreboard.S.gameObject;
                fsRun.Init(fsPts, 0, 1);
                // Also adjust the fontSize
                fsRun.fontSizes = new List <float>(new float[] { 28, 36, 4 });
                fsRun           = null; // Clear fsRun so it's created again
            }
            break;

        case ScoreEvent.mine:  // Remove a mine card
            chain++;           // increase the score chain
            scoreRun += chain; // add score for this card to run
            // Create a FloatingScore for this score
            FloatingScore fs;
            // Move it from the mousePosition to fsPosRun
            Vector3 p0 = Input.mousePosition;
            p0.x /= Screen.width;
            p0.y /= Screen.height;
            fsPts = new List <Vector3>();
            fsPts.Add(p0);
            fsPts.Add(fsPosMid);
            fsPts.Add(fsPosRun);
            fs           = Scoreboard.S.CreateFloatingScore(chain, fsPts);
            fs.fontSizes = new List <float>(new float[] { 4, 50, 28 });
            if (fsRun == null)
            {
                fsRun = fs;
                fsRun.reportFinishTo = null;
            }
            else
            {
                fs.reportFinishTo = fsRun.gameObject;
            }
            break;
        }

        // This second switch statement handles round wins and losses
        switch (sEvt)
        {
        case ScoreEvent.gameWin:
            GTGameOver.text = "Round Over";
            // If it's a win, add the score to the next round
            // static fields are NOT reset by Application.LoadLevel()
            Prospector.SCORE_FROM_PREV_ROUND = score;
            print("You won this round! Round score: " + score);
            GTRoundResult.text = "You won this round!\nRound Score: " + score;
            ShowResultGTs(true);
            break;

        case ScoreEvent.gameLoss:
            GTGameOver.text = "Game Over";
            // If it's a loss, check against the high score
            if (Prospector.HIGH_SCORE <= score)
            {
                print("You got the high score! High score: " + score);
                string sRR = "You got the high score!\nHigh score: " + score;
                GTRoundResult.text    = sRR;
                Prospector.HIGH_SCORE = score;
                PlayerPrefs.SetInt("ProspectorHighScore", score);
            }
            else
            {
                print("Your final score for the game was: " + score);
                GTRoundResult.text = "Your final score was: " + score;
            }
            ShowResultGTs(true);
            break;

        default:
            print("score: " + score + " scoreRun:" + scoreRun + " chain:" + chain);
            break;
        }
    }
Example #2
0
    void ScoreManager(ScoreEvent sEvt)
    {
        List <Vector3> fsPts;

        switch (sEvt)
        {
        case ScoreEvent.draw:
        case ScoreEvent.gameWin:
        case ScoreEvent.gameLoss:
            GTGameOver.text = "Game Over";
            chain           = 0;
            score          += scoreRun;
            scoreRun        = 0;
            if (fsRun != null)
            {
                fsPts = new List <Vector3>();
                fsPts.Add(fsPosRun);
                fsPts.Add(fsPosMid2);
                fsPts.Add(fsPosEnd);
                fsRun.reportFinishTo = ScoreBoard.S.gameObject;
                fsRun.Init(fsPts, 0, 1);
                fsRun.fontSizes = new List <float>(new float[] { 28, 36, 4 });
                fsRun           = null;
            }
            break;

        case ScoreEvent.mine:
            chain++;
            scoreRun += chain;
            FloatingScore fs;
            Vector3       pO = Input.mousePosition;
            pO.x /= Screen.width;
            pO.y /= Screen.height;
            fsPts = new List <Vector3>();
            fsPts.Add(pO);
            fsPts.Add(fsPosMid);
            fsPts.Add(fsPosRun);
            fs           = ScoreBoard.S.CreateFloatingScore(chain, fsPts);
            fs.fontSizes = new List <float>(new float[] { 4, 50, 28 });
            if (fsRun == null)
            {
                fsRun = fs;
                fsRun.reportFinishTo = null;
            }
            else
            {
                fs.reportFinishTo = fsRun.gameObject;
            }
            break;
        }
        switch (sEvt)
        {
        case ScoreEvent.gameWin:
            Prospector.SCORE_FROM_PREV_ROUND = score;
            GTGameOver.text = "Round Over";
            Prospector.SCORE_FROM_PREV_ROUND = score;
            GTroundResults.text = "You win this round!\nRound Score: " + score;
            ShowResultsGTs(true);
            break;

        case ScoreEvent.gameLoss:
            GTGameOver.text = "Game Over";
            if (Prospector.HIGH_SCORE <= score)
            {
                print("New High Score");
                Prospector.HIGH_SCORE = score;
                string sRR = "You got the high score!\nHigh score: " + score;
                GTroundResults.text = sRR;
                PlayerPrefs.SetInt("ProspectorHighScore", score);
            }
            else
            {
                print("Your final score was" + score);
                GTroundResults.text = "Your final score was: " + score;
            }
            ShowResultsGTs(true);
            break;

        default:
            print("score" + score + " scoreRun" + scoreRun + " chain" + chain);
            break;
        }
    }
Example #3
0
    void FloatingScoreHandler(eScoreEvent evt)
    {
        List <Vector2> fsPts;

        switch (evt)
        {
        // Same things need to happen whether it's a draw, a win, or a loss

        case eScoreEvent.draw:                     // Drawing a card

        case eScoreEvent.gameWin:                  // Won the round

        case eScoreEvent.gameLoss:                 // Lost the round

            // Add fsRun to the Scoreboard score

            if (fsRun != null)
            {
                // Create points for the Bézier curve1

                fsPts = new List <Vector2>();

                fsPts.Add(fsPosRun);

                fsPts.Add(fsPosMid2);

                fsPts.Add(fsPosEnd);

                fsRun.reportFinishTo = Scoreboard.S.gameObject;

                fsRun.Init(fsPts, 0, 1);

                // Also adjust the fontSize

                fsRun.fontSizes = new List <float>(new float[] { 28, 36, 4 });

                fsRun = null;                         // Clear fsRun so it's created again
            }

            break;



        case eScoreEvent.mine:                 // Remove a mine card

            // Create a FloatingScore for this score

            FloatingScore fs;

            // Move it from the mousePosition to fsPosRun

            Vector2 p0 = Input.mousePosition;

            p0.x /= Screen.width;

            p0.y /= Screen.height;

            fsPts = new List <Vector2>();

            fsPts.Add(p0);

            fsPts.Add(fsPosMid);

            fsPts.Add(fsPosRun);

            fs = Scoreboard.S.CreateFloatingScore(ScoreManager.CHAIN, fsPts);

            fs.fontSizes = new List <float>(new float[] { 4, 50, 28 });

            if (fsRun == null)
            {
                fsRun = fs;

                fsRun.reportFinishTo = null;
            }
            else
            {
                fs.reportFinishTo = fsRun.gameObject;
            }

            break;
        }
    }
    // ScoreManager handles all of the scoring
    void ScoreManager(ScoreEvent sEvt)
    {
        List <Vector3> fsPts;

        switch (sEvt)
        {
        case ScoreEvent.draw:
            // Add the chained score into the total one and reset it to zero;
            score       += chainScore * Mathf.RoundToInt(Mathf.Pow(2, chainGoldNum));
            chainScore   = 0;
            chainNum     = 0;
            chainGoldNum = 0;
            break;

        case ScoreEvent.mine:
            // +1 on the chainNum
            chainNum++;
            // Add score on the chainScore
            chainScore += chainNum;
            break;

        case ScoreEvent.mineGold:
            // raise the multiplier based on the gold card encountered in this chain
            chainGoldNum++;
            chainNum++;
            break;

        case ScoreEvent.gameWin:
            // Clear the total score of this round, add the score to PREV_ROUND for next round
            SCORE_FROM_PREV_ROUND = score;
            break;

        case ScoreEvent.gameLoss:
            // Clear the other ones, add all to the total score
            score += chainScore;
            break;
        }

        // Handle the statements of game win and loss
        switch (sEvt)
        {
        case ScoreEvent.gameWin:
            // if it is a win, add the score to the next round
            // static fields are NOT reset by Application.LoadLevel()
            print("You Won this round! Round score: " + score);

            gameOverUI.text    = "Round Over";
            roundResultUI.text = "You have won this round!\n Round Score: " + score;
            ShowResultUI(true);
            break;

        case ScoreEvent.gameLoss:
            // If it is a loss, check against the high score
            gameOverUI.text = "Game Over";
            if (Prospector.HIGH_SCORE <= score)
            {
                print("You got the new high score! High score: " + score);
                PlayerPrefs.SetInt("ProspectorHighScore", score);
                roundResultUI.text = "You got the high score!\n High Score: " + score;
            }
            else
            {
                print("Your final score is: " + score);
                roundResultUI.text = "Your final score was: " + score;
                ShowResultUI(true);
            }
            break;

        default:
            print("score:" + score + " chainNum:" + chainNum + " chainScore:" + chainScore);
            break;
        }

        // Handle the scoring show to player
        switch (sEvt)
        {
        case ScoreEvent.draw:
        case ScoreEvent.gameWin:
        case ScoreEvent.gameLoss:
            // adding the chain score to the scoreboard
            if (fsRun != null)
            {
                // Check if there is a started run.
                // If there is, make the bezier list for score moving
                fsPts = new List <Vector3>();
                fsPts.Add(fsPosRun);
                fsPts.Add(fsPosMid2);
                fsPts.Add(fsPosEnd);
                fsRun.reportFinishTo = Scoreboard.S.gameObject;
                fsRun.Init(fsPts, 0, 1);

                // Change the font too.
                fsRun.fontSize = new List <float>(new float[] { 28, 36, 4 });
                fsRun          = null; // Clear fsRun so it is created again
            }
            break;

        case ScoreEvent.mine:
        case ScoreEvent.mineGold:
            // When mining, adding up the score in fsRun
            FloatingScore fs;

            // Moving it from the mousePosition to fsPosRun
            fsPts = new List <Vector3>();
            Vector3 p0 = Input.mousePosition;
            //p0.x /= Screen.width;
            //p0.y /= Screen.height;
            fsPts.Add(p0);
            fsPts.Add(fsPosMid);
            fsPts.Add(fsPosRun);

            fs = Scoreboard.S.CreateFloatingScore(chainNum, fsPts);

            fs.fontSize = new List <float>(new float[] { 4, 50, 28 });

            if (fsRun == null)
            {
                fsRun = fs;
                fsRun.reportFinishTo = null;
            }
            else
            {
                fs.reportFinishTo = fsRun.gameObject;
            }
            break;
        }
    }
Example #5
0
    //ScoreManager处理所有得分
    void ScoreManager(ScoreEvent sEvt)
    {
        List <Vector3> fsPts;

        switch (sEvt)
        {
        //无论是抽牌、赢或输,需要有对应的动作
        case ScoreEvent.draw:     //抽一张牌
        case ScoreEvent.gameWin:  //赢得本轮
        case ScoreEvent.gameLoss: //本轮输了
            chain    = 0;         //重置分数变量chain
            score   += scoreRun;  //将scoreRun加入总得分
            scoreRun = 0;         //重置scoreRun
            //将fsRun添加到_Scoreboard分数
            if (fsRun != null)
            {
                //创建贝塞尔曲线的坐标点
                fsPts = new List <Vector3>();
                fsPts.Add(fsPosRun);
                fsPts.Add(fsPosMid2);
                fsPts.Add(fsPosEnd);
                fsRun.reportFinishTo = Scoreboard.Instance.gameObject;
                fsRun.Init(fsPts, 0, 1);
                //同时调整fontSize
                fsRun.fontSizes = new List <float>(new float[] { 28, 36, 4 });
                fsRun           = null;//清除fsRun以再次创建
            }
            break;

        case ScoreEvent.mine:  //删除一张矿井纸牌
            chain++;           //分数变量chain自加
            scoreRun += chain; //添加当前纸牌的分数到这回合
            //为当前分数创建FloatingScore
            FloatingScore fs;
            //从mousePosition移动到fsPosRun
            Vector3 p0 = Input.mousePosition;
            p0.x /= Screen.width;
            p0.y /= Screen.height;
            fsPts = new List <Vector3>();
            fsPts.Add(p0);
            fsPts.Add(fsPosMid);
            fsPts.Add(fsPosRun);
            fs           = Scoreboard.Instance.CreateFloatingScore(chain, fsPts);
            fs.fontSizes = new List <float>(new float[] { 4, 50, 28 });
            if (fsRun == null)
            {
                fsRun = fs;
                fsRun.reportFinishTo = null;
            }
            else
            {
                fs.reportFinishTo = fsRun.gameObject;
            }
            break;
        }

        //第二个switch语句处理本轮的输赢
        switch (sEvt)
        {
        case ScoreEvent.gameWin:
            GTGameOver.text = "Round Over";
            //赢的话,将分数添加到下一轮
            Prospector.SCORE_FROM_PREV_ROUND = score;
            GTRoundResult.text = "You won this round!\nRound Score:" + score;
            ShowResultGTs(true);
            break;

        case ScoreEvent.gameLoss:
            GTGameOver.text = "Game Over";
            //输的话,与最高分进行比较
            if (Prospector.HIGH_SCORE <= score)
            {
                string sRR = "You got the hihg score!\nHigh score:" + score;
                GTRoundResult.text    = sRR;
                Prospector.HIGH_SCORE = score;
                PlayerPrefs.SetInt("ProspectorHighScore", score);
            }
            else
            {
                GTRoundResult.text = "Your final score was:" + score;
            }
            ShowResultGTs(true);
            break;

        default:
            break;
        }
    }