private void _ApplyAlterations(IAttackData attackData)
 {
     foreach (IDamageAlteration damageAlteration in _DamageAlterations)
     {
         damageAlteration.Alter(attackData);
     }
 }
        //----------------------------------------------------------------------------
        //            AlterDamage
        //----------------------------------------------------------------------------

        #region AlterDamage

        /// <summary>
        /// Gets all alterations registered to the hasAttack and isVictim. <para/>
        /// It then concantenates them, sorts them by operation order, and applies them.
        /// </summary>
        public void AlterDamage(IHasAttack hasAttack, IIsVictim isVictim, IAttackData attackData)
        {
            _InitialiseDamageAlterationsEnumerable();

            _GetHasAttackAlterations(hasAttack);

            _GetIsVictimAlterations(isVictim);

            _SortAlterations();

            _ApplyAlterations(attackData);
        }
        //----------------------------------------------------------------------------
        //             AttackCoroutine
        //----------------------------------------------------------------------------

        #region AttackCoroutine

        public IEnumerator AttackCoroutine()
        {
            yield return(StartCoroutine(MyBattleCamManager.SwitchToScriptCamera()));

            _RotateCharactersToFaceEachOther();

            Coroutine AttackFocusCoroutine = _StartAttackFocus();


            //get attack data from attacker
            IAttackData attackData = MyHasAttack.GetAttackData();

            attackData.SetIsVictim(MyIsVictim);

            MyAlterationManager.MyAttackDataAlterer.Alter(attackData);

            yield return(StartCoroutine(MyNarrator.AttemptToAttack(attackData)));


            //pass control to rolling for attack
            //to allow it to ask for input from the user if needed
            yield return(StartCoroutine(attackData.RollForAttack()));

            //pass control to checking attack roll against ac
            //to allow it to ask for input from the user if needed
            yield return(MyIsVictim.DoesAttackRollHit(attackData.MyAttackRoll));

            if (attackData.MyAttackRoll.DidHit)
            {
                yield return(StartCoroutine(MyNarrator.AttackHit(attackData.MyAttackRoll)));

                //pass control to rolling damage
                //to allow it to ask for input from the user if needed
                yield return(MyHasAttack.RollDamage(attackData.MyAttackRoll));

                MyAlterationManager.MyDamageDataAlterer.AlterDamage(MyHasAttack, MyIsVictim, attackData);

                //pass control to taking damage
                //to allow it to ask for input from the user if needed
                yield return(MyIsVictim.TakeDamage(attackData.MyAttackRoll));
            }
            else
            {
                yield return(StartCoroutine(MyNarrator.AttackMiss(attackData.MyAttackRoll)));
            }


            StopCoroutine(AttackFocusCoroutine);
            yield return(new WaitForSeconds(0.4f));

            StartCoroutine(EndAttack());
        }
Exemple #4
0
        private void AssignAttackData(IAttackData data)
        {
            entityAttackDamageText.enabled = data != null;
            entityAttackRangeText.enabled  = data != null;
            entityAttackSpeedText.enabled  = data != null;

            if (data == null)
            {
                return;
            }

            entityAttackDamageText.text = "Strength: " + data.AttackDamage;
            entityAttackRangeText.text  = "Range: " + data.UnitRange;
            entityAttackSpeedText.text  = "Attack Speed: " + data.AttackSpeed;
        }
Exemple #5
0
        //----------------------------------------------------------------------------
        //                    Alter
        //----------------------------------------------------------------------------

        #region Alter

        public void Alter(IAttackData attackData)
        {
            if (HasAttackAlterationsDict.ContainsKey(attackData.MyHasAttack))
            {
                foreach (IAttackDataAlteration attackDataAlteration in HasAttackAlterationsDict[attackData.MyHasAttack])
                {
                    attackDataAlteration.Alter(attackData);
                }
            }

            if (IsVictimAlterationsDict.ContainsKey(attackData.MyIsVictim))
            {
                foreach (IAttackDataAlteration attackDataAlteration in IsVictimAlterationsDict[attackData.MyIsVictim])
                {
                    attackDataAlteration.Alter(attackData);
                }
            }
        }
        //----------------------------------------------------------------------------
        //                    AttemptToAttack
        //----------------------------------------------------------------------------

        #region AttemptToAttack

        public IEnumerator AttemptToAttack(IAttackData attackData)
        {
            MyAttackData = attackData;
            yield return(new WaitForSeconds(1f));;

            MyTextMesh.text = attackData.MyHasAttack.MyName + " turns to look at " + attackData.MyIsVictim.Name
                              + ", before bringing their " + attackData.MyHasAttack.MyWeapon.MyWeaponType +
                              " down on them.";

            yield return(StartCoroutine(ShowCanvas()));

            while (!Input.GetMouseButton(0))
            {
                yield return(null);
            }

            yield return(new WaitForSeconds(0.2f));
        }
Exemple #7
0
        public void Alter(IAttackData attackData)
        {
            WeaponObject weapon = attackData.MyHasAttack.MyWeapon;

            attackData.MyAttackRoll.MyDamageData.AddDamage(Mod, weapon.MyDamageType, DamageSource.Mod);
        }
Exemple #8
0
 public void Alter(IAttackData attackData)
 {
     attackData.AddModifier(Bonus);
 }