Пример #1
0
    void statAugment(PrayerAugmentTypes type, int percentage)
    {
        switch (type)
        {
        case PrayerAugmentTypes.Defence:
            player.defence.prayer = (percentage / 100f) + 1;
            break;

        case PrayerAugmentTypes.Magic:
            player.magic.prayer = (percentage / 100f) + 1;
            break;

        case PrayerAugmentTypes.Range:
            player.ranged.prayer = (percentage / 100f) + 1;
            break;
        }

        OnPrayerChanged.Invoke();
    }
Пример #2
0
    public void ManagePrayer(Prayer prayerToActivate)
    {
        if (player.CurrentPrayerPoints > 0)
        {
            prayerToActivate.background.enabled = true;
            prayerToActivate.isActive           = !prayerToActivate.isActive;
            List <Prayer> prayersToDesactivate = new List <Prayer>();

            if (activePrayers.Count == 0)
            {
                activePrayers.Add(dummy);
            }

            for (int i = 0; i < activePrayers.Count; i++)
            {
                if (prayerToActivate.isAugment)
                {
                    if (prayerToActivate == activePrayers[i])
                    {
                        statAugment(activePrayers[i].augmentType, 0);
                        prayersToDesactivate.Add(activePrayers[i]);
                    }
                    PrayerAugmentTypes augment = prayerToActivate.augmentType;
                    if (activePrayers[i].isAugment || activePrayers[i].isUltimate)
                    {
                        if (activePrayers[i].isAugment)
                        {
                            if (augment == activePrayers[i].augmentType)
                            {
                                prayersToDesactivate.Add(activePrayers[i]);
                            }

                            else
                            {
                                if (augment == PrayerAugmentTypes.Attack || augment == PrayerAugmentTypes.Strenght)
                                {
                                    if (activePrayers[i].augmentType == PrayerAugmentTypes.Magic || activePrayers[i].augmentType == PrayerAugmentTypes.Range)
                                    {
                                        prayersToDesactivate.Add(activePrayers[i]);
                                        statAugment(activePrayers[i].augmentType, 0);
                                    }
                                }
                                else if (augment == PrayerAugmentTypes.Magic || augment == PrayerAugmentTypes.Range)
                                {
                                    if (activePrayers[i].augmentType != PrayerAugmentTypes.Defence)
                                    {
                                        prayersToDesactivate.Add(activePrayers[i]);
                                        statAugment(activePrayers[i].augmentType, 0);
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (augment == PrayerAugmentTypes.Defence)
                            {
                                disableUltimate(activePrayers[i].ultimateType);
                                prayersToDesactivate.Add(activePrayers[i]);
                            }
                            else if (augment == PrayerAugmentTypes.Attack || augment == PrayerAugmentTypes.Strenght)
                            {
                                if (activePrayers[i].ultimateType == PrayerUltimateTypes.Chivalry || activePrayers[i].ultimateType == PrayerUltimateTypes.Piety)
                                {
                                    disableUltimate(activePrayers[i].ultimateType);
                                    prayersToDesactivate.Add(activePrayers[i]);
                                }
                            }
                            else if (augment == PrayerAugmentTypes.Magic)
                            {
                                if (activePrayers[i].ultimateType == PrayerUltimateTypes.Augury)
                                {
                                    disableUltimate(activePrayers[i].ultimateType);
                                    prayersToDesactivate.Add(activePrayers[i]);
                                }
                            }
                            else
                            {
                                if (activePrayers[i].ultimateType == PrayerUltimateTypes.Rigour)
                                {
                                    disableUltimate(activePrayers[i].ultimateType);
                                    prayersToDesactivate.Add(activePrayers[i]);
                                }
                            }
                        }
                    }
                    if (prayerToActivate.isActive)
                    {
                        statAugment(prayerToActivate.augmentType, prayerToActivate.percentage);
                    }
                }
                else if (prayerToActivate.isProtect)
                {
                    if (prayerToActivate == activePrayers[i])
                    {
                        protect(PrayerProtectTypes.None);
                        prayersToDesactivate.Add(activePrayers[i]);
                    }
                    else if (activePrayers[i].isProtect)
                    {
                        protect(prayerToActivate.protectType);
                        prayersToDesactivate.Add(activePrayers[i]);
                    }
                }
                else if (prayerToActivate.isUltimate)
                {
                    if (prayerToActivate == activePrayers[i])
                    {
                        disableUltimate(activePrayers[i].ultimateType);
                        prayersToDesactivate.Add(activePrayers[i]);
                    }
                    else if (activePrayers[i].isUltimate || activePrayers[i].isAugment)
                    {
                        if (activePrayers[i].isAugment)
                        {
                            statAugment(activePrayers[i].augmentType, 0);
                            prayersToDesactivate.Add(activePrayers[i]);
                        }
                        else
                        {
                            disableUltimate(activePrayers[i].ultimateType);
                            prayersToDesactivate.Add(activePrayers[i]);
                        }
                    }
                    if (prayerToActivate.isActive)
                    {
                        ultimate(prayerToActivate.ultimateType);
                    }
                }
            }

            for (int i = 0; i < prayersToDesactivate.Count; i++)
            {
                prayersToDesactivate[i].background.enabled = false;
                prayersToDesactivate[i].isActive           = false;
                activePrayers.Remove(prayersToDesactivate[i]);
            }

            if (prayerToActivate.isActive)
            {
                //Debug.Log(prayerToActivate.name + " is active?: " + prayerToActivate.isActive);
                activePrayers.Add(prayerToActivate);
            }

            drainHandler();
        }
        else
        {
            foreach (var prayer in activePrayers)
            {
                prayer.isActive           = false;
                prayer.background.enabled = false;
            }
            activePrayers           = new List <Prayer>();
            activePrayersDrainRates = new Dictionary <float, bool>();
        }
    }