// Use this for initialization
    void Start()
    {
        pView = pc.GetComponent <PhotonView>();
        if (!pView.IsMine)
        {
            return;
        }
        correctStreak  = 0;
        gameOver       = true;
        questionMode   = false;
        Cursor.visible = false;
        paused         = false;

        imageHolder.SetActive(false);
        pauseMenu.SetActive(false);

        gameSparksHandler = GameObject.FindWithTag("gsh").GetComponent <GameSparksHandler>();
        words             = gameSparksHandler.getWords();
        defs      = gameSparksHandler.getDefs();
        defs2     = gameSparksHandler.getDefs2();
        misspell1 = gameSparksHandler.getMisspell();
        misspell2 = gameSparksHandler.getMisspell2();
        misspell3 = gameSparksHandler.getMisspell3();
        listID    = gameSparksHandler.getIDS();
        type      = gameSparksHandler.getTypes();
        listEmpty = gameSparksHandler.getListEmptys();
        studyXP   = gameSparksHandler.getStudyXPS();



        settings = gameSparksHandler.getSettings();

        numSets = 0;
        for (int i = 0; i < listID.Length; i++)
        {
//            Debug.Log("List Empty " + i + " val " + listEmpty[i]);
            if (!listEmpty[i])
            {
                indexes.Add(i);
                Debug.Log("id: " + listID[i]);
                numSets++;
            }
        }
        for (int i = 0; i < 10; i++)
        {
            if (!listEmpty[i])
            {
                donePhrases[i] = new bool[words[i].Length];
            }
        }
        //numSets = words.Length;
        //Debug.Log("sets: " + numSets);
    }
示例#2
0
    //holds the player at the screen then allows them to push a button to exit
    private IEnumerator waitThenShowXP(bool victory)
    {
        //show game text for 1 sec
        yield return(new WaitForSeconds(1.7f));

        victoryText.gameObject.SetActive(false);
        defeatText.gameObject.SetActive(false);

        //show blast bonus
        if (blasts > 0)
        {
            xpEarned        += (blasts * 75 + 100);
            victoryText.text = "Blast Bonus " + xpEarned + " XP";
        }
        else
        {
            victoryText.text = "Blast Bonus 0 XP";
            victoryText.gameObject.SetActive(true);
        }

        victoryText.gameObject.SetActive(true);
        //show blast bonus text for 1 sec
        yield return(new WaitForSeconds(1.5f));

        //no deaths bonus
        if (deaths == 0)
        {
            xpEarned        += 500;
            victoryText.text = "Invincible Bonus 500 XP";
            yield return(new WaitForSeconds(1.5f));
        }

        //victory bonus
        if (victory)
        {
            oldWins++;
            xpEarned        += 250;
            victoryText.text = "Victory Bonus 250 XP";
            yield return(new WaitForSeconds(1.5f));
        }
        else
        {
            oldLosses++;
            xpEarned        += 100;
            victoryText.text = "Gameplay Bonus 100 XP";
            yield return(new WaitForSeconds(1.5f));
        }

        //kd bonus
        if (blasts > deaths)
        {
            if (deaths == 0)
            {
                xpEarned        += 50 * blasts;
                victoryText.text = "B/K Bonus " + (50 * blasts) + " XP";
            }
            else
            {
                xpEarned        += 50 * Mathf.RoundToInt((float)(blasts) / (float)deaths);
                victoryText.text = "B/K Bonus " +
                                   50 * Mathf.RoundToInt((float)(blasts) / (float)deaths) +
                                   " XP";
            }
            yield return(new WaitForSeconds(1.5f));
        }

        if (questionScore >= 20)
        {
            xpEarned        += 1000;
            victoryText.text = "Question Emperor Bonus 1000 XP";
            yield return(new WaitForSeconds(1.5f));
        }

        string[] ids      = handler.getIDS();
        int[]    correctQ = gc.getCorrectAnswers();
        for (int i = 0; i < correctQ.Length; i++)
        {
            //if(correctQ[i] != null){
            correctQuestions += correctQ[i];
            // }
        }
        int[] inCorrectQ = gc.getIncorrectAnswers();
        for (int i = 0; i < inCorrectQ.Length; i++)
        {
            //if(correctQ[i] != null){
            incorrectQuestions += inCorrectQ[i];
            // }
        }
        int[] prevXPs = handler.getPopLearnXP();

        for (int i = 0; i < 10; i++)
        {
            if (ids[i] != null)
            {
                int totXP = prevXPs[i];
                Debug.Log("correct: " + correctQ[i]);
                if (totXP < 20)
                {
                    totXP += correctQ[i];
                }
                else
                {
                    totXP += correctQ[i];
                    Debug.Log("penalty: " + (totXP % 20) * inCorrectQ[i]);
                    totXP -= ((totXP % 20) * inCorrectQ[i]);
                    if (totXP <= 0)
                    {
                        totXP = 0;
                    }
                }
                Debug.Log("new total: " + totXP);
                new LogEventRequest()
                .SetEventKey("setStudyListXP")
                .SetEventAttribute("name", ids[i])
                .SetEventAttribute("xpAmount", totXP)
                .Send((response) =>
                {
                    if (!response.HasErrors)
                    {
                    }
                    else
                    {
                        Debug.Log("problem with entry " + i);
                    }
                });
            }
        }
        int[][] studyXP = gc.getStudyXP();

        for (int i = 0; i < ids.Length; i++)
        {
            if (ids[i] != null)
            {
                List <int> tempData = new List <int>(studyXP[i]);
                new LogEventRequest().SetEventKey("setScoreArray")
                .SetEventAttribute("listName", ids[i])
                .SetEventAttribute("data", tempData)
                .Send((response) =>
                {
                    if (!response.HasErrors)
                    {
                    }

                    else
                    {
                        Debug.Log("Problem setting array data on server!");
                    }
                });
            }
        }

        new LogEventRequest()
        .SetEventKey("updateStats")
        .SetEventAttribute("wins", oldWins)
        .SetEventAttribute("losses", oldLosses)
        .SetEventAttribute("blasts", oldBlasts + blasts)
        .SetEventAttribute("deaths", oldDeaths + deaths)
        .SetEventAttribute("xp", oldXP + xpEarned)
        .SetEventAttribute("time", (long)elapsedTime)
        .SetEventAttribute("correctQuestions", correctQuestions)
        .SetEventAttribute("incorrectQuestions", incorrectQuestions)
        //Sets the game value to a non zero number
        .SetEventAttribute("games", 1)
        .SetEventAttribute("shotsFired", shotsFired)
        .SetEventAttribute("shotsLanded", shotsLanded)
        .SetEventAttribute("tutorialNum", tutorialNum)
        .Send((response) =>
        {
            if (!response.HasErrors)
            {
                Debug.Log("Player Saved To GameSparks...");
                StartCoroutine(endEndGame());
            }
            else
            {
                Debug.Log("Error Saving Player Data...");
            }
        });


        //canExit = true;
    }