// check if player unlocked a character
    string CheckForCharacterUnlock()
    {
        // check if there are any chars that can be unlocked
        if (m_CharactersThatCanBeUnlocked.Count <= 0)
        {
            UIControllerBattle.get.m_UnlockedCharacterIcon.sprite = UIControllerBattle.get.m_CharacterSpritesDict["NotUnlocked"];
            return("You've already unlocked all characters in this Level!");
        }
        // if there are any
        else
        {
            // check if a character is going to be unlocked
            System.Random rand         = new System.Random();
            int           unlockChance = rand.Next(0, 100);

            // player missed chance to unlock character
            if (unlockChance < 50)
            {
                UIControllerBattle.get.m_UnlockedCharacterIcon.sprite = UIControllerBattle.get.m_CharacterSpritesDict["NotUnlocked"];
                return("Nobody joined your team this time. Try again another time!");
            }
            // player hit chance to unlock character
            else
            {
                // calculate which character should be unlocked
                int characterIndex = rand.Next(0, m_CharactersThatCanBeUnlocked.Count);

                // Unlock character for player
                ServerResponse responseDelServer = UserRequestLibrary.UnlockCharacterForUser(m_CharactersThatCanBeUnlocked[characterIndex].m_CharacterName);

                UIControllerBattle.get.m_UnlockedCharacterIcon.sprite = UIControllerBattle.get.m_CharacterSpritesDict[m_CharactersThatCanBeUnlocked[characterIndex].m_CharacterName];
                return($"The {m_CharactersThatCanBeUnlocked[characterIndex].m_CharacterName} joined your team!");
            }
        }
    }
Exemple #2
0
 // unlocks this character in the database so it can be used ingame
 public void UnlockCharacter()
 {
     ServerResponse response = UserRequestLibrary.UnlockCharacterForUser(m_CharacterName);
 }