Пример #1
0
    public float GetDamage(float damage, ManaDistribution damageDist)
    {
        List <float> percents = damageDist.GetAsPercentages();

        if (percents.Count == 0)
        {
            return(damage);
        }
        float structureDiff = damageDist.structure - structure;
        float essenceDiff   = damageDist.essence - essence;
        float natureDiff    = damageDist.nature - nature;

        percents[0] = percents[0] * damage * (1f - (structureDiff < 0 ? structureDiff : Mathf.Abs(structure * 0.75f)));
        percents[1] = percents[1] * damage * (1f - (essenceDiff < 0 ? essenceDiff : Mathf.Abs(essence * 0.75f)));
        percents[2] = percents[2] * damage * (1f - (fire * 0.75f));
        percents[3] = percents[3] * damage * (1f - (water * 0.75f));
        percents[4] = percents[4] * damage * (1f - (earth * 0.75f));
        percents[5] = percents[5] * damage * (1f - (air * 0.75f));
        percents[6] = percents[6] * damage * (1f - (natureDiff < 0 ? natureDiff : Mathf.Abs(damageDist.nature * 0.75f)));

        float sum = 0;

        foreach (var element in percents)
        {
            sum += element;
        }

        return(sum);
    }
Пример #2
0
    public void AddComponent(AuricaSpellComponent newComponent)
    {
        if (currentComponents.Count >= 10)
        {
            currentManaCost += 10f;
        }
        else if (currentComponents.Count > 12)
        {
            currentManaCost += 20f;
        }
        currentComponents.Add(newComponent);
        currentManaCost += newComponent.GetManaCost(aura.GetAura());
        ManaDistribution oldMd = currentDistribution;

        currentDistribution = newComponent.CalculateDistributionChange(currentDistribution, aura.GetAura());

        //Debug.Log("Added component: " + newComponent.c_name + "    Current Mana Cost: " + currentManaCost);
        //Debug.Log("Old Distribution: " + oldMd.ToString() + "    New Distribution: " + currentDistribution.ToString());

        if (distDisplay != null)
        {
            distDisplay.SetDistribution(currentDistribution);
        }
        if (cpUI != null)
        {
            cpUI.AddComponent(newComponent);
        }
    }
Пример #3
0
 public void SendAura(ManaDistribution a)
 {
     aura = a;
     componentUIDisplay.SendAura(a);
     BindingUIPanel.LocalInstance.Startup();
     gameObject.SetActive(false);
 }
Пример #4
0
    IEnumerator SetTargetDist(ManaDistribution target)
    {
        yield return(new WaitForSeconds(0.2f));

        targetDistDisplay.SetDistribution(target);
        targetDistDisplayValues.SetDistribution(target);
    }
Пример #5
0
    //  Damage to the caster is calculated as follows:
    //  -    The damage distribution is calculated as percentages of the aggregate, so if the distribution is 60% fire mana, 60% of the damage is dealt as fire damage
    //  -    The aura distribution is calculated as percentages as well, and used to reduce the damage dealt
    //          This means that if the casters aura is 70% fire mana, they will take 70% reduced fire damage
    //              Aligned mana percentages are absolute, so if the casters aura is 20% structured mana of either order or chaos,
    //              they will take 20% reduced structured damage instead of taking more damage if the alignments are opposing
    public float GetDamage(float damage, ManaDistribution damageDist)
    {
        List <float> percents     = damageDist.GetAsPercentages();
        List <float> auraPercents = AuraDistribution.GetAsPercentages();

        if (percents.Count == 0)
        {
            return(damage);
        }
        for (var i = 0; i < 7; i++)
        {
            percents[i] = percents[i] * damage * (1f - auraPercents[i]);
        }
        // Log Damages
        // foreach (var x in percents) Debug.Log(x.ToString());

        float sum = 0;

        foreach (var element in percents)
        {
            sum += element;
        }

        return(sum);
    }
Пример #6
0
    public void ApplySiphon(ManaDistribution siphonDist)
    {
        // Find the minimum of the siphon and current distribution, so that you arent reducing mana by more than what exists
        ManaDistribution siphon = new ManaDistribution(
            siphonDist.structure >= 0f ? Mathf.Min(Mathf.Max(0f, structure), siphonDist.structure) : Mathf.Max(Mathf.Min(0f, structure), siphonDist.structure),
            siphonDist.essence >= 0f ? Mathf.Min(Mathf.Max(0f, essence), siphonDist.essence) : Mathf.Max(Mathf.Min(0f, essence), siphonDist.essence),
            Mathf.Min(fire, siphonDist.fire),
            Mathf.Min(water, siphonDist.water),
            Mathf.Min(earth, siphonDist.earth),
            Mathf.Min(air, siphonDist.air),
            siphonDist.nature >= 0f ? Mathf.Min(Mathf.Max(0f, nature), siphonDist.nature) : Mathf.Max(Mathf.Min(0f, nature), siphonDist.nature)
            );

        Debug.Log("Siphon Distribution " + siphon.ToString());
        // Water, Earth and Divine add structure, Fire, Earth and Demonic reduce it
        structure += (0.3f * siphon.water) + (0.3f * siphon.earth) - (0.3f * siphon.fire) - (0.3f * siphon.air) + (0.5f * siphon.nature) - siphon.structure;
        // Water and Air add essence, Earth and Fire reduce it
        essence += (0.1f * siphon.water) - (0.1f * siphon.earth) - (0.1f * siphon.fire) + (0.1f * siphon.air) - siphon.essence;
        // Demonic increases fire
        fire += (0.5f * Mathf.Max(0f, -siphon.nature)) - siphon.fire;
        // Divine increases air
        air += (0.5f * Mathf.Max(0f, siphon.nature)) - siphon.air;

        // No siphon interactions
        water  -= siphon.water;
        earth  -= siphon.earth;
        nature -= siphon.nature;
        Debug.Log("Post-Siphon Distribution " + this.ToString());
    }
Пример #7
0
    void Start()
    {
        player     = GetComponent <PlayerManager>();
        playerName = player.photonView.Owner.NickName;
        Debug.Log("Trying to load aura file: " + playerName + "-aura");
        TextAsset auraFile = Resources.Load <TextAsset>("Auras/" + playerName + "-aura");

        // No personal aura was found, use default
        if (auraFile == null)
        {
            auraFile = Resources.Load <TextAsset>("Auras/default-aura");
        }

        if (auraFile != null)
        {
            AuraDistribution = JsonUtility.FromJson <ManaDistribution>(auraFile.text);
        }

        InnateStrength = CalculateInnateStrengths();

        Debug.Log("AURA:  " + AuraDistribution.ToString());
        player.SetMaxMana(AuraDistribution.GetAggregate() * 100f);
        player.ConfirmAura();

        if (photonView.IsMine)
        {
            foreach (var item in FindObjectsOfType <AuraUIPanel>())
            {
                item.SetAura(this);
            }
        }
    }
 public void SetDistribution(ManaDistribution mana)
 {
     structure.text = (mana.structure * multiplier).ToString("F2") + suffix;
     essence.text   = (mana.essence * multiplier).ToString("F2") + suffix;
     fire.text      = (mana.fire * multiplier).ToString("F2") + suffix;
     water.text     = (mana.water * multiplier).ToString("F2") + suffix;
     earth.text     = (mana.earth * multiplier).ToString("F2") + suffix;
     air.text       = (mana.air * multiplier).ToString("F2") + suffix;
     nature.text    = (mana.nature * multiplier).ToString("F2") + suffix;
 }
Пример #9
0
 public void AddAuricDist(ManaDistribution auricDist, ManaDistribution aura)
 {
     structure += auricDist.structure * aura.structure;
     essence   += auricDist.essence * aura.essence;
     fire      += auricDist.fire * aura.fire;
     water     += auricDist.water * aura.water;
     earth     += auricDist.earth * aura.earth;
     air       += auricDist.air * aura.air;
     nature    += auricDist.nature * aura.nature;
 }
Пример #10
0
 public void AddBasicDist(ManaDistribution other)
 {
     structure += other.structure;
     essence   += other.essence;
     fire      += other.fire;
     water     += other.water;
     earth     += other.earth;
     air       += other.air;
     nature    += other.nature;
 }
Пример #11
0
    public float GetManaCost(ManaDistribution aura)
    {
        if (!hasAuricDistribution && !hasBasicDistribution && !hasSiphonDistribution)
        {
            return(0);
        }
        float auricContribution  = hasAuricDistribution ? (auricDistribution * aura).GetAggregate() : 0f;
        float basicContribution  = hasBasicDistribution ? basicDistribution.GetAggregate() * 0.25f : 0f;
        float siphonContribution = hasSiphonDistribution ? 0.05f : 0f;

        return((auricContribution + basicContribution + siphonContribution) * 100f * manaCostMultiplier);
    }
Пример #12
0
 void Awake()
 {
     if (photonView.IsMine)
     {
         AuricaCaster.LocalCaster = this;
     }
     allComponents       = Resources.LoadAll <AuricaSpellComponent>("AuricaSpellComponents");
     allSpells           = Resources.LoadAll <AuricaSpell>("AuricaSpells");
     currentComponents   = new List <AuricaSpellComponent>();
     currentDistribution = new ManaDistribution();
     cachedSpells        = new Dictionary <string, CachedSpell>();
 }
Пример #13
0
    //public List<float> basicDistribution = new List<float>(7), auricDistribution = new List<float>(7), fluxDistribution = new List<float>(7);

    public ManaDistribution CalculateDistributionChange(ManaDistribution givenDistribution, ManaDistribution aura)
    {
        ManaDistribution calculatedDistribution = new ManaDistribution(givenDistribution.ToString());

        if (hasBasicDistribution)
        {
            calculatedDistribution.AddBasicDist(basicDistribution);
        }
        // TODO: For now, there is no aura system or flux calculations
        // if (hasAuricDistribution) calculatedDistribution.AddAuricDist(auricDistribution, aura);
        // if (hasFluxDistribution) calculatedDistribution.ApplyFluxDist(fluxDistribution);
        return(calculatedDistribution);
    }
Пример #14
0
 public void SetDistribution(ManaDistribution mana)
 {
     order.SetHealth(mana.structure > 0f ? mana.structure : 0f);
     chaos.SetHealth(mana.structure < 0f ? -mana.structure : 0f);
     life.SetHealth(mana.essence > 0f ? mana.essence : 0f);
     death.SetHealth(mana.essence < 0f ? -mana.essence : 0f);
     fire.SetHealth(mana.fire);
     water.SetHealth(mana.water);
     earth.SetHealth(mana.earth);
     air.SetHealth(mana.air);
     divine.SetHealth(mana.nature > 0f ? mana.nature : 0f);
     demonic.SetHealth(mana.nature < 0f ? -mana.nature : 0f);
 }
Пример #15
0
 public void ResetCast()
 {
     Debug.Log("Resetting Aurica Cast");
     currentComponents.Clear();
     currentManaCost     = 0f;
     currentDistribution = new ManaDistribution();
     if (cpUI != null)
     {
         cpUI.HideAllComponents();
     }
     if (distDisplay != null)
     {
         distDisplay.SetDistribution(currentDistribution);
     }
 }
Пример #16
0
    public float CheckDistError(ManaDistribution dist)
    {
        float error = 0f;

        error += GetAlignedErrorFunc(structure, dist.structure);
        error += GetAlignedErrorFunc(essence, dist.essence);
        error += GetAlignedErrorFunc(nature, dist.nature);

        error += Mathf.Abs(fire - dist.fire);
        error += Mathf.Abs(water - dist.water);
        error += Mathf.Abs(earth - dist.earth);
        error += Mathf.Abs(air - dist.air);

        return(error);
    }
Пример #17
0
    public void ApplyFluxDist(ManaDistribution fluxDist)
    {
        // Aligned mana moves towards the midpoint of 0
        structure -= structure * fluxDist.structure;
        essence   -= essence * fluxDist.essence;
        nature    -= nature * fluxDist.nature;

        // Elemental mana moves towards the average of the elements
        float midpoint = GetElementalAverage();

        // Fire
        if (fire > midpoint)
        {
            fire -= (fire - midpoint) * fluxDist.fire;
        }
        else if (fire < midpoint)
        {
            fire += (midpoint - fire) * fluxDist.fire;
        }
        // Water
        if (water > midpoint)
        {
            water -= (water - midpoint) * fluxDist.water;
        }
        else if (water < midpoint)
        {
            water += (midpoint - water) * fluxDist.water;
        }
        // Earth
        if (earth > midpoint)
        {
            earth -= (earth - midpoint) * fluxDist.earth;
        }
        else if (earth < midpoint)
        {
            earth += (midpoint - earth) * fluxDist.earth;
        }
        // Air
        if (air > midpoint)
        {
            air -= (air - midpoint) * fluxDist.air;
        }
        else if (air < midpoint)
        {
            air += (midpoint - air) * fluxDist.air;
        }
    }
Пример #18
0
    public float GetSpellDamageModifier(ManaDistribution damageMod)
    {
        float        sum         = 0f;
        List <float> percents    = targetDistribution.GetAsPercentages();
        List <float> modPercents = damageMod.ToList();

        if (percents.Count == 0 || modPercents.Count == 0)
        {
            Debug.Log("Could not find percentages, or modifier percentages");
            return(1f);
        }

        for (int i = 0; i < 7; i++)
        {
            sum += percents[i] * (1 + modPercents[i]);
            // Debug.Log("Percent "+i+"  "+ percents[i]+" * "+ (1+modPercents[i]));
        }

        Debug.Log("Spell damage modifier by: x" + sum);
        return(sum);
    }
Пример #19
0
    public AuricaSpell GetSpellMatch(List <AuricaSpellComponent> components, ManaDistribution distribution)
    {
        int         bestMatchCorrectComponents = 0;
        AuricaSpell spellMatch = null;

        foreach (AuricaSpell s in allSpells)
        {
            // Debug.Log("Check Spell: " + s.c_name + "   IsMatch: " + s.CheckComponents(components) + "     Error:  " + s.GetError(distribution)+"  Num matching components: "+s.GetNumberOfMatchingComponents(components));
            if (s.CheckComponents(components) && s.GetNumberOfMatchingComponents(components) > bestMatchCorrectComponents)
            {
                spellMatch = s;
                bestMatchCorrectComponents = s.GetNumberOfMatchingComponents(components);
                spellStrength = (spellMatch.errorThreshold - s.GetError(distribution)) / spellMatch.errorThreshold + 0.3f;
                if (spellStrength < 0.25f)
                {
                    spellStrength = 0.25f;
                }
            }
        }

        return(spellMatch);
    }
Пример #20
0
 ManaDistribution CalculateInnateStrengths()
 {
     if (usePercentStrength)
     {
         // Making sure that the sign (+/-) of the aligned mana is preserved
         ManaDistribution strengths = new ManaDistribution();
         List <float>     percents  = AuraDistribution.GetAsPercentages();
         strengths.structure = percents[0]; // * (AuraDistribution.structure / Mathf.Abs(AuraDistribution.structure));
         strengths.essence   = percents[1]; // * (AuraDistribution.essence / Mathf.Abs(AuraDistribution.essence));
         strengths.fire      = percents[2];
         strengths.water     = percents[3];
         strengths.earth     = percents[4];
         strengths.air       = percents[5];
         strengths.nature    = percents[6];// * (AuraDistribution.nature / Mathf.Abs(AuraDistribution.nature));
         // Debug.Log("Innate Strengths: "+strengths.ToString());
         return(strengths);
     }
     else
     {
         return(new ManaDistribution(AuraDistribution.ToString()));
     }
 }
Пример #21
0
    //public List<float> basicDistribution = new List<float>(7), auricDistribution = new List<float>(7), fluxDistribution = new List<float>(7);

    public ManaDistribution CalculateDistributionChange(ManaDistribution givenDistribution, ManaDistribution aura)
    {
        ManaDistribution calculatedDistribution = new ManaDistribution(givenDistribution.ToString());

        if (hasBasicDistribution)
        {
            calculatedDistribution.AddBasicDist(basicDistribution);
        }
        if (hasAuricDistribution)
        {
            calculatedDistribution.AddAuricDist(auricDistribution, aura);
        }
        if (hasFluxDistribution)
        {
            calculatedDistribution.ApplyFluxDist(fluxDistribution);
        }
        if (hasSiphonDistribution)
        {
            calculatedDistribution.ApplySiphon(siphonDistribution);
        }
        calculatedDistribution.ClampElementalValues();
        return(calculatedDistribution);
    }
Пример #22
0
    public ManaDistribution IdealAuraCalculation()
    {
        // List<float> basicDist = new List<float>();
        // List<float> auricDist = new List<float>();
        ManaDistribution basicDist = new ManaDistribution();
        ManaDistribution auricDist = new ManaDistribution();

        foreach (AuricaSpellComponent component in keyComponents)
        {
            basicDist += component.basicDistribution;
            auricDist += component.auricDistribution;
        }

        float structure = auricDist.structure != 0 ? (targetDistribution.structure - basicDist.structure) / auricDist.structure : 0;
        float essence   = auricDist.essence != 0 ? (targetDistribution.essence - basicDist.essence) / auricDist.essence : 0;
        float fire      = auricDist.fire != 0 ? (targetDistribution.fire - basicDist.fire) / auricDist.fire : 0;
        float water     = auricDist.water != 0 ? (targetDistribution.water - basicDist.water) / auricDist.water : 0;
        float earth     = auricDist.earth != 0 ? (targetDistribution.earth - basicDist.earth) / auricDist.earth : 0;
        float air       = auricDist.air != 0 ? (targetDistribution.air - basicDist.air) / auricDist.air : 0;
        float nature    = auricDist.nature != 0 ? (targetDistribution.nature - basicDist.nature) / auricDist.nature : 0;

        return(new ManaDistribution(structure, essence, fire, water, earth, air, nature));
    }
Пример #23
0
 public float GetError(ManaDistribution targetDist)
 {
     return(!isAuric?targetDistribution.CheckDistError(targetDist) : 0f);
 }