Beispiel #1
0
        /// <summary>
        /// Calculate how an attack interacts with this entity's shields.
        /// Does not change any state, just returns a result!
        /// </summary>
        /// <param name="atk"></param>
        /// <returns></returns>
        public AttackResult.ShieldCheckResult CalculateAttackShieldPenetration(AttackData atk)
        {
            Random rand = new Random();

            //Check against shields
            AttackResult.ShieldCheckResult shieldResult = AttackResult.ShieldCheckResult.SHIELD_BYPASSED;
            if (GetShieldLayers() > 0)
            {
                if (atk.Type == AttackType.ARCANE ||
                    atk.Type == AttackType.BLAST ||
                    atk.Type == AttackType.ENERGY)
                {
                    int shieldRoll = rand.Next(100);
                    if (shieldRoll < GetShieldStrength())
                    {
                        shieldResult = AttackResult.ShieldCheckResult.SHIELD_PROTECTED;
                    }
                    else if (GetShieldLayers() > 1)
                    {
                        shieldResult = AttackResult.ShieldCheckResult.SHIELD_LAYERBROKE;
                    }
                    else
                    {
                        shieldResult = AttackResult.ShieldCheckResult.SHIELD_SHIELDBROKE;
                    }
                }
                else if (atk.Type == AttackType.DARK)
                {
                    shieldResult = AttackResult.ShieldCheckResult.SHIELD_PROTECTED;
                }
            }


            return(shieldResult);
        }
Beispiel #2
0
        /// <summary>
        /// Called on each individual actor in the path of a blast attack.
        /// Takes data from the blast attack, and determines whether it penetrates defenses and affects the target or not.
        /// Evasion is calculated elsewhere, this just takes into account shields and resistances.
        /// This also applies shield damage if necessary.
        /// Currently returns true if the attack penetrates, or false if it does not (or if no actor is present).
        ///
        /// </summary>
        /// <param name="atkData"></param>
        /// <param name="actor"></param>
        /// <returns></returns>
        protected bool CalculateBlastHit(AttackData atkData, int actorID)
        {
            //Get the targeted entity
            if (actorID == -1)
            {
                return(false);
            }
            Actor a = _scene.GetGameObjectPool().GetActor(actorID);

            if (a == null)
            {
                return(false);
            }

            //Find out shield result
            AttackResult.ShieldCheckResult shieldResult = a.CalculateAttackShieldPenetration(atkData);

            //Affect the actor's shields as necessary based on shield result
            if (shieldResult == AttackResult.ShieldCheckResult.SHIELD_LAYERBROKE ||
                shieldResult == AttackResult.ShieldCheckResult.SHIELD_SHIELDBROKE)
            {
                a.BreakShieldLayer();
                return(false);
            }
            else if (shieldResult == AttackResult.ShieldCheckResult.SHIELD_PROTECTED)
            {
                a.TakeShieldDamage(10);
                return(false);
            }

            return(true);
        }