Exemple #1
0
    private void AddConsumableDrops(BattleEndWindow battleEndWindow)
    {
        // Get Consumables
        int consumableDrops = Random.Range(stageInfo.consumableDropCountMin, stageInfo.consumableDropCountMax + 1);
        Dictionary <ConsumableType, int> consumablesCount = new Dictionary <ConsumableType, int>();

        for (int i = 0; i < consumableDrops; i++)
        {
            ConsumableType consumable = GameManager.Instance.GetRandomConsumable();
            GameManager.Instance.PlayerStats.consumables[consumable]++;
            if (!consumablesCount.ContainsKey(consumable))
            {
                consumablesCount.Add(consumable, 0);
            }
            consumablesCount[consumable]++;
        }

        foreach (KeyValuePair <ConsumableType, int> keyValue in consumablesCount)
        {
            battleEndWindow.AddToBodyText(keyValue.Key.ToString() + " +" + keyValue.Value + "\n");
        }
    }
Exemple #2
0
    public void EndBattle(bool victory)
    {
        StageManager.Instance.BattleManager.ProjectilePool.ReturnAll();
        foreach (EnemyActor enemy in currentEnemyList)
        {
            enemy.DisableActor();
            EnemyPool.ReturnToPool(enemy);
        }
        enemiesSpawned = 0;
        currentEnemyList.Clear();
        StopAllCoroutines();
        battleEnded = true;
        GameManager.Instance.isInBattle = false;
        BattleEndWindow battleEndWindow = UIManager.Instance.BattleUICanvas.GetComponentInChildren <BattleEndWindow>(true);

        battleEndWindow.isVictory = victory;

        if (victory)
        {
            if (survivalLoopCount == 0)
            {
                GameManager.Instance.PlayerStats.AddToStageClearCount(stageInfo.idName);
                if (playerHealth == STARTING_LIFE)
                {
                    perfectBonus = true;
                }
            }
            else
            {
                perfectBonus = false;
            }

            battleEndWindow.ShowVictoryWindow();

            CalculateExpGain(battleEndWindow);
            CalculateItemFragmentDrops(battleEndWindow);

            //AddConsumableDrops(battleEndWindow);
            AddEquipmentDrops(battleEndWindow);
            AddArchetypeDrops(battleEndWindow);
        }
        else
        {
            battleEndWindow.ShowLoseWindow();

            gainedExpThisLoop       = gainedExp / -2;
            gainedExp              /= 2;
            gainedFragmentsThisLoop = gainedFragments / -2;
            gainedFragments        /= 2;

            if (gainedArchetypeItems.Count > 0)
            {
                int numToRemove = System.Math.Max(gainedArchetypeItems.Count / 2, 1);
                for (int i = 0; i < numToRemove; i++)
                {
                    gainedArchetypeItems.RemoveAt(Random.Range(0, gainedArchetypeItems.Count));
                }
            }

            if (gainedEquipment.Count > 0)
            {
                int numToRemove = System.Math.Max(gainedEquipment.Count / 2, 1);
                for (int i = 0; i < numToRemove; i++)
                {
                    gainedEquipment.RemoveAt(Random.Range(0, gainedEquipment.Count));
                }
            }
        }

        battleEndWindow.SetExpGainValues(gainedExp, gainedExpThisLoop);
        battleEndWindow.SetFragGainValues(gainedFragments, gainedFragmentsThisLoop);
        battleEndWindow.UpdateExpString();
        battleEndWindow.UpdateFragString();

        if (gainedArchetypeItems.Count > 0)
        {
            string gainedArchetypesString           = "Archetypes:\n";
            Dictionary <string, int> archetypeCount = new Dictionary <string, int>();
            foreach (ArchetypeItem archetypeItem in gainedArchetypeItems)
            {
                if (!archetypeCount.ContainsKey(archetypeItem.Name))
                {
                    archetypeCount.Add(archetypeItem.Name, 0);
                }
                archetypeCount[archetypeItem.Name]++;
            }

            foreach (KeyValuePair <string, int> archetypeEntry in archetypeCount)
            {
                gainedArchetypesString += "<indent=10%>" + archetypeEntry.Key + " x" + archetypeEntry.Value + "</indent>\n";
            }

            gainedArchetypesString += '\n';

            battleEndWindow.AddToBodyText(gainedArchetypesString);
        }

        if (gainedEquipment.Count > 0)
        {
            string gainEquipString = "Equipment:\n";
            Dictionary <EquipmentBase, int> equipmentCount = new Dictionary <EquipmentBase, int>();
            foreach (Equipment equipment in gainedEquipment)
            {
                if (!equipmentCount.ContainsKey(equipment.Base))
                {
                    equipmentCount.Add(equipment.Base, 0);
                }
                equipmentCount[equipment.Base]++;
            }

            foreach (KeyValuePair <EquipmentBase, int> equipEntry in equipmentCount)
            {
                if (equipEntry.Key is UniqueBase)
                {
                    gainEquipString += "<indent=10%><color=#ff7d28>" + equipEntry.Key.LocalizedName + "</color> x" + equipEntry.Value + "</indent>\n";
                }
                else
                {
                    gainEquipString += "<indent=10%>" + equipEntry.Key.LocalizedName + " x" + equipEntry.Value + "</indent>\n";
                }
            }

            battleEndWindow.AddToBodyText(gainEquipString);
        }
    }