Beispiel #1
0
    void CalculateToHit(Being attacker, Ability ability, List <Being> defenders)
    {
        Debug.Log(attacker.beingName + " uses " + ability.abilityName);
        //any looking for passives etc would come here. //this would include effects like 'Goblin punch gets +5 to hit against Goblins' <-- that would be a separate passive ability to Goblin Punch

        for (int i = 0; i < defenders.Count; i++)
        {
            //Debug.Log("for target " + (i+1) + "...");
            //check to see if any effect of this ability will change the toHit values (eg it adds +5 to hit or similar)
            for (int ii = 0; ii < ability.effects.Count; ii++)
            {
                if (ability.effects[ii] is ModulateToHitSelf_Effect) //here I'm literally only looking for one type of effect, I couldnt think of another way of doing it but it seems a but ugly.
                {
                    ability.effects[ii].Use(attacker);               //This should add any relevent statmodulations into the beings statmodulation list
                }
            }


            if (effectQueue.Count > 0)                                        //if we have some effects in the effect queue...
            {
                List <StatModulation> tempList = new List <StatModulation>(); //create a temporary list of stat modulatons

                for (int iii = 0; iii < effectQueue.Count; iii++)
                {
                    if (effectQueue[iii] is StatModulation)
                    {
                        StatModulation sm = effectQueue[iii] as StatModulation;
                        if (sm.targetStat.statName == "TOHIT")                //if it's a TOHIT modulator
                        {
                            tempList.Add(effectQueue[iii] as StatModulation); //Add it to our temporary list
                        }
                    }
                }

                //now we run through our temporary list of stat modulations and fire them in BODMAS order

                for (int iiii = 0; iiii < tempList.Count; iiii++) //first +
                {
                    if (tempList[iiii].modifier == "+")
                    {
                        tempList[iiii].Use();
                    }
                }
                for (int iiii = 0; iiii < tempList.Count; iiii++) //then for -
                {
                    if (tempList[iiii].modifier == "-")
                    {
                        tempList[iiii].Use();
                    }
                }
                //If we need to remove those used Stat Modulations from the beings statMOdulations list then here is where we would do it.
                //It's not in yet because we might have statmods that last for X turns or count themselves down to death etc.
            }


            //actually calculate the toHit value

            //Debug.Log("Calculating to hit...");
            float tohit  = attacker.GetStatValue("TOHIT", 2);
            float dex    = attacker.GetStatValue("DEXTERITY", 2);
            float random = Random.Range(1, 101);
            float pl     = attacker.GetResourceValue("POWERLEVEL", 1);
            float final  = pl + ((dex / 100) * ability.ranks) + random + tohit;
            Debug.Log(pl + " + (" + (dex / 100) + " * " + ability.ranks + ") + " + random + " + " + tohit + " = " + final);

            //Debug.Log("To Hit value is " + final);

            CalculateDefence(attacker, ability, final, defenders[i]);
        }


        //yield return new WaitForSeconds(textSpeed);
    }