Пример #1
0
    // gets this character values from the database
    public void GetStats()
    {
        ServerResponse response = UserRequestLibrary.GetCurrentCharStats(m_CharacterName);

        m_AttackDamage = response.Characters[0].AttackDamage;
        m_Defense      = response.Characters[0].Defense;
        m_Health       = response.Characters[0].HP;
        m_UnlockStatus = response.Characters[0].UnlockStatus;
        m_Level        = response.Characters[0].Level;
    }
Пример #2
0
    void SpawnEnemyTeam()
    {
        ServerResponse response = UserRequestLibrary.GetLevelData(PlayerData.LastSelectedLevel);

        // spawn enemies that are deposited in the database
        for (int i = 0; i < response.LevelData.Enemies.Count; i++)
        {
            // spawn enemy at the correct enemy spawnpoint
            GameObject go = Instantiate(m_CharacterDict[response.LevelData.Enemies[i].Name], m_EnemySpawnpoints[i]);

            Character EnemyReference = go.GetComponent <Character>();

            // if it is the first spawned, set as last selected enemy
            if (i == 0)
            {
                m_LastSelectedEnemy = EnemyReference;
            }

            // set character spawned to enemy team
            EnemyReference.m_TeamStatus = "Enemy";

            // set character values got from database
            EnemyReference.m_AttackDamage = response.LevelData.Enemies[i].AttackDamage;
            EnemyReference.m_Defense      = response.LevelData.Enemies[i].Defense;
            EnemyReference.m_Health       = response.LevelData.Enemies[i].HP;

            // save enemy in enemy list
            m_Enemies.Add(EnemyReference);

            // bottom chars should overlap top chars
            if (i > 0 && i % 2 != 0)
            {
                go.GetComponent <SpriteRenderer>().sortingOrder = 11;
            }
            else
            {
                go.GetComponent <SpriteRenderer>().sortingOrder = 10;
            }
        }

        // check which characters the player can unlock
        foreach (var charToBeUnlocked in m_Enemies)
        {
            // get current status character in database
            ServerResponse sr = UserRequestLibrary.GetCurrentCharStats(charToBeUnlocked.m_CharacterName);

            // if character has not unlocked the character yet
            if (sr.Characters[0].UnlockStatus == 0)
            {
                // add it to the list of characters that can be unlocked
                m_CharactersThatCanBeUnlocked.Add(charToBeUnlocked);
            }
        }
    }