public void Use(AbilityUseParams useParams)
        {
            print("Power attack used by: " + gameObject.name);
            float damageToDeal = useParams.baseDamage + config.GetExtraDamage();

            useParams.target.TakeDamage(damageToDeal);
        }
 public void Use(AbilityUseParams useParams)
 {
     player.Heal(config.GetExtraHealth());
     audioSource.clip = config.GetAudioClip(); // TODO find way of moving audio to parent class
     audioSource.Play();
     PlayParticleEffect();
 }
Esempio n. 3
0
 public override void Use(AbilityUseParams useParams)
 {
     useParams.target = gameObject;
     HealSelf();
     PlayParticleEffect(useParams);
     PlayAbilitySound();
 }
 public void Use(AbilityUseParams useParams)
 {
     print("Heal Ability Used by: " + gameObject.name);
     ActivateHeal(useParams);
     ActivateSound();
     PlayParticleSystem();
 }
        public void Use(AbilityUseParams useParams)
        {
            print("AoE attack used by: " + gameObject.name);
            // TODO: change origin to useParams.target for a TARGETED AoE (currently AoE encircles player)
            Vector3 origin = gameObject.transform.position;
            float   radius = config.GetRadius();

            float damageAmount = useParams.baseDamage + config.GetAbilityDamage();

// change origin to target ENEMY // Change movement for BLAST attack
            RaycastHit[] targets = Physics.SphereCastAll(origin, radius, origin, radius);

            // print("Number of targets" + targets.Length);
            // for (var thing = 0; thing < targets.Length; thing++)
            // {
            //  print("Raycasts Hit: " + targets[thing].collider.gameObject.name);
            // }

            foreach (RaycastHit hit in targets)
            {
                var target = hit.collider.gameObject.GetComponent <IDamageable>();
                if (target != null)
                {
                    target.TakeDamage(damageAmount);
                    // print("Enemy Hit: " + target);
                }
            }
        }
Esempio n. 6
0
 public void Use(AbilityUseParams useParams)
 {
     print("Power attack used by: " + gameObject.name);
     DealDamage(useParams);
     PlayParticleEffect(); // TODO find way of moving audio to parent class
     audioSource.clip = config.GetAudioClip();
     audioSource.Play();
 }
Esempio n. 7
0
        public void DealDamage(AbilityUseParams useParams)
        {
            abilityUseParams = useParams;
            characterManager = abilityUseParams.ability.Behaviour.Character.GetComponent <Character>();
            var   enemyHealthController = useParams.target.GetComponent <HealthController>();
            float primaryStatDamage     = CalculatePrimaryStatMultiplier();
            float finalDamage           = primaryStatDamage - GetArmourValue(abilityUseParams.target);

            enemyHealthController.TakeDamage(finalDamage);
            UIManager.Instance.TriggerCombatText(enemyHealthController.gameObject.transform.position, finalDamage, CombatTextType.NormalDamage);
        }
Esempio n. 8
0
        protected void PlayAbilityAnimation(AbilityUseParams args)
        {
            var animation = config.GetAbilityAnimation();

            animation = RemoveAnimationEvents(animation);
            var overrideController = args.self.GetComponent <Character>().OverrideAnimator;
            var animator           = args.self.GetComponent <Animator>();

            overrideController[SPECIAIL_ABILITY_ANIM] = animation;
            animator.SetTrigger(SPECIAL_ABILITY_TRIGGER);
        }
 private void ActivateHeal(AbilityUseParams useParams)
 {
     if (player)
     {
         player.Heal(config.GetHealth());
     }
     else if (enemy)
     {
         // TODO: add HEAL to enemy script
         enemy.TakeDamage(-config.GetHealth());
     }
 }
Esempio n. 10
0
        protected void PlayParticleEffect(AbilityUseParams useParams)
        {
            GameObject particleObject = Instantiate(
                config.ParticlePrefab,
                useParams.target.transform.position,
                config.ParticlePrefab.transform.rotation
                );
            ParticleSystem particleSystem = particleObject.GetComponent <ParticleSystem>();

            particleSystem.Play();
            Destroy(particleObject, particleSystem.main.duration);
        }
Esempio n. 11
0
        AbilityUseParams GetUseParams(GameObject target)
        {
            var damage           = (ability as DaggerSlashConfig).Damage.Value;
            var animationName    = (ability as DaggerSlashConfig).AnimationName;
            var reliantStat      = (ability as DaggerSlashConfig).ReliantStat;
            var statMultiplier   = (ability as DaggerSlashConfig).StatMultiplier;
            var hitAnimationName = (ability as DaggerSlashConfig).HitAnimationName;

            AbilityUseParams useParams = new AbilityUseParams(target, damage, null, ability, reliantStat, statMultiplier, hitAnimationName);

            return(useParams);
        }
Esempio n. 12
0
        private void AttemptSpecialAbility(int abilityIndex, Enemy enemy)
        {
            var energyComponent = GetComponent <Energy>();
            var energyCost      = abilities[abilityIndex].GetEnergyCost();

            if (energyComponent.IsEnergyAvailable(energyCost))
            {
                energyComponent.ConsumeEnergy(10f);
                var abilityParams = new AbilityUseParams(enemy, baseDamage);
                abilities[abilityIndex].Use(abilityParams);
            }
        }
Esempio n. 13
0
        IEnumerator PerformBasicShot(AbilityUseParams useParams)
        {
            Character.characterAnimationController.StartAbilityAnimation(ability.AnimationName);

            yield return(new WaitForSeconds(ability.AbilitySpeed.Value));

            Projectile attack = Instantiate(useParams.projectilePrefab, Character.ExitPoints[Character.ExitIndex].position, Quaternion.identity).GetComponent <Projectile>();

            attack.Initialize(useParams.target.transform, useParams);
            attack.InvokeOnHitTarget += Character.damageController.DealDamage;
            StopAttack(ability.AnimationName);
            StartCoroutine(UnregisterProjectileEvent(attack, Character.damageController));
        }
Esempio n. 14
0
        AbilityUseParams GetUseParams(GameObject target)
        {
            float         damage           = (ability as FireballConfig).Damage.Value;
            GameObject    projectilePrefab = (ability as FireballConfig).ProjectilePrefab;
            string        animationName    = (ability as FireballConfig).AnimationName;
            CharacterStat reliantStat      = (ability as FireballConfig).ReliantStat;
            float         statMultiplier   = (ability as FireballConfig).StatMultiplier;
            var           hitAnimationName = (ability as FireballConfig).HitAnimationName;

            AbilityUseParams useParams = new AbilityUseParams(target, damage, projectilePrefab, ability, reliantStat, statMultiplier, hitAnimationName);

            return(useParams);
        }
Esempio n. 15
0
        AbilityUseParams GetUseParams(GameObject target)
        {
            var damage           = (ability as PoisonShotConfig).Damage.Value;
            var projectilePrefab = (ability as PoisonShotConfig).ProjectilePrefab;
            var animationName    = (ability as PoisonShotConfig).AnimationName;
            var reliantStat      = (ability as PoisonShotConfig).ReliantStat;
            var statMultiplier   = (ability as PoisonShotConfig).StatMultiplier;
            var hitAnimationName = (ability as PoisonShotConfig).HitAnimationName;

            AbilityUseParams useParams = new AbilityUseParams(target, damage, projectilePrefab, ability, reliantStat, statMultiplier, hitAnimationName);

            return(useParams);
        }
Esempio n. 16
0
        protected IEnumerator PerformDaggerSlash(AbilityUseParams useParams)
        {
            var enemyHealthController = useParams.target.GetComponent <HealthController>();
            var enemyHitboxAnimator   = useParams.target.GetComponentInChildren <HitAnimationController>().GetComponent <Animator>();

            Character.characterAnimationController.StartAbilityAnimation(ability.AnimationName);
            yield return(animationDelayRoutine = StartCoroutine(AnimationDelay(ANIMATION_DELAY, enemyHitboxAnimator, (ability as DaggerSlashConfig).HitAnimationName)));

            Character.damageController.DealDamage(useParams);

            yield return(new WaitForSeconds(ability.AbilitySpeed.Value));

            StopAttack(ability.AnimationName);
        }
Esempio n. 17
0
        public void TryPerformPowerAttack(Health target)
        {
            if (!(currentEnergy >= abilities[0].EnergyCost))
            {
                if (audioSource != null)
                {
                    outOfEnergySound.PlayClip(audioSource);
                }
                return;
            }
            ConsumeEnergy(abilities[0].EnergyCost);
            var abilityParams = new AbilityUseParams(gameObject, target, player.WeaponSystem.BaseDamage);

            abilities[0].Use(abilityParams);
        }
Esempio n. 18
0
        protected void PlayEffect(AbilityUseParams args, bool stickToCaster)
        {
            CompoundParticleSystem vfxSystem = null;

            if (stickToCaster)
            {
                vfxSystem = Instantiate(config.GetCompoundParticleSystem(), args.self.transform).GetComponent <CompoundParticleSystem>();
            }
            else
            {
                vfxSystem = Instantiate(config.GetCompoundParticleSystem()).GetComponent <CompoundParticleSystem>();
                vfxSystem.CopyRotationAndPositon(args.self.transform);
            }

            vfxSystem.InitAndPlay(selfDestruct: true);
        }
Esempio n. 19
0
        private void AttempSpecialAbility(int abilityIndex)
        {
            var           energyComponent = GetComponent <Energy>();
            AbilityConfig specialAbility  = abilities[abilityIndex];

            if (energyComponent.IsEnergyAvailable(specialAbility.GetEnergyCost()))
            {
                energyComponent.ConsumeEnergy(specialAbility.GetEnergyCost());
                var abilityParams = new AbilityUseParams(this.currentEnemy, baseDamage);
                specialAbility.Use(abilityParams);
            }
            else
            {
                print("Not enough mana");
            }
        }
Esempio n. 20
0
        public void TryPerformSpecialAbility(int index)
        {
            var ability = abilities[index];

            if (!(currentEnergy >= ability.EnergyCost))
            {
                if (audioSource != null)
                {
                    outOfEnergySound.PlayClip(audioSource);
                }
                return;
            }
            ConsumeEnergy(ability.EnergyCost);
            AbilityUseParams args = new AbilityUseParams(gameObject, null, player.WeaponSystem.BaseDamage);

            ability.Use(args);
        }
        private void DealRadialDamage(AbilityUseParams args)
        {
            Collider[] colliders = Physics.OverlapSphere(args.self.transform.position, config.GetRadius());
            foreach (Collider collider in colliders)
            {
                if (collider.gameObject == args.self)
                {
                    continue;
                }

                var damageable = collider.GetComponent <Health>();

                if (damageable != null)
                {
                    damageable.TakeDamage(args.baseDamage + config.GetBonusDamage());
                }
            }
        }
Esempio n. 22
0
        private void DealRadialDamage(AbilityUseParams useParams)
        {
            float damageToDeal = useParams.baseDamage + config.GetDamageToEachTarget();

            //static sphere cast for targets around me
            RaycastHit[] hits  = Physics.SphereCastAll(transform.position, config.GetRadius(), Vector3.up, config.GetRadius());
            int          count = 0;

            foreach (RaycastHit hit in hits)
            {
                var damageable = hit.collider.gameObject.GetComponent <IDamageable>();
                var hitPlayer  = hit.collider.gameObject.GetComponent <Player>();
                if ((damageable != null) && (!hitPlayer))
                {
                    damageable.TakeDamage(damageToDeal);
                    count++;
                }
            }
        }
Esempio n. 23
0
 private void UseSpecialAbility(int index)
 {
     if (energy.IsEnergyAvailable(abilities[index].GetEnergyCost()) && IsAbilityAvailable(abilities[index]))
     {
         if (abilities[index].TargetSelf())
         {
             energy.UpdateEnergyPoints(abilities[index].GetEnergyCost());
             var abilityParams = new AbilityUseParams(player, baseDamage, player);
             abilities[index].Use(abilityParams);
             abilities[index].lastHitTime = Time.time;
         }
         else if (WithinAbilityRange(abilities[index]))
         {
             energy.UpdateEnergyPoints(abilities[index].GetEnergyCost());
             var abilityParams = new AbilityUseParams(currentEnemy, baseDamage, player);
             abilities[index].Use(abilityParams);
             abilities[index].lastHitTime = Time.time;
         }
     }
 }
Esempio n. 24
0
        private void DealDamage(AbilityUseParams useParams)
        {
            print("AoE attack used by: " + gameObject.name);
            Vector3 origin = gameObject.transform.position;
            float   radius = (config as AreaOfEffectConfig).GetRadius();

            float damageAmount = useParams.baseDamage + (config as AreaOfEffectConfig).GetAbilityDamage();

            RaycastHit[] targets = Physics.SphereCastAll(origin, radius, origin, radius);
            // print("AoE Hit List: " + targets);

            foreach (RaycastHit hit in targets)
            {
                var target = hit.collider.gameObject.GetComponent <IDamageable>();
                // TODO: consider using Tag or layer, so enemies don't damage each other
                if (target != null && target != useParams.user)
                {
                    target.TakeDamage(damageAmount);
                }
            }
        }
Esempio n. 25
0
        private void DealDamage(AbilityUseParams useParams)
        {
            print("BLAST attack used by: " + gameObject.name);

            float damageAmount = useParams.baseDamage + (config as BlastAttackConfig).GetDamage();

            float radius         = (config as BlastAttackConfig).GetRadius();
            float travelDistance = (config as BlastAttackConfig).GetTravel();
            // TODO: get position of target - send to SphereCastAll
            // Vector3 direction = useParams.target.gameObject.transform.position;
            Vector3 origin = gameObject.transform.position;
            // RaycastHit[] targets = Physics.SphereCastAll(origin, radius, direction, travelDistance);
            // foreach (RaycastHit hit in targets)
            // {
            //  var target = hit.collider.gameObject.GetComponent<IDamageable>();
            //  // TODO: consider using Tag or layer, so enemies don't damage each other
            //  if (target != null && target != useParams.user)
            //  {
            //      target.TakeDamage(damageAmount);
            //  }
            // }
        }
Esempio n. 26
0
        private void DealRadialDamage(AbilityUseParams useParams)
        {
            float damageToDeal = (config as AreaAttackConfig).DamageToEachTarget;

            RaycastHit[] hits = Physics.SphereCastAll(
                useParams.target.transform.position,
                (config as AreaAttackConfig).DamageRadius,
                Vector3.left,
                (config as AreaAttackConfig).DamageRadius
                );

            foreach (RaycastHit hit in hits)
            {
                if (hit.collider && hit.collider.gameObject && hit.collider.gameObject != gameObject)
                {
                    IDamageable damageableComponent = hit.collider.gameObject.GetComponent <IDamageable>();
                    if (damageableComponent != null)
                    {
                        damageableComponent.TakeDamage((config as AreaAttackConfig).DamageToEachTarget);
                    }
                }
            }
        }
Esempio n. 27
0
        private void DealDamage(AbilityUseParams useParams)
        {
            MonoBehaviour newTarget = useParams.target as MonoBehaviour;
            MonoBehaviour newUser   = useParams.user as MonoBehaviour;


            Vector3 destination = newTarget.gameObject.transform.position;
            float   speed       = (config as ChargeAttackConfig).GetSpeed();
            float   damage      = (config as ChargeAttackConfig).GetDamage();
            float   extraDamage = (config as ChargeAttackConfig).GetExtraDamage();
            float   radius      = (config as ChargeAttackConfig).GetRadius();
            var     player      = newUser.gameObject;
            var     target      = newTarget.gameObject;

            print(newTarget.transform.position);
            print(newUser.transform.position);

            // player.transform.position = target.transform.position;

            // print("Charge attack used by: " + gameObject.name);
            // Vector3 origin = gameObject.transform.position;
            // float radius = (config as ChargeAttackConfig).GetRadius();

            // float damageAmount = useParams.baseDamage + (config as ChargeAttackConfig).GetAbilityDamage();
            // RaycastHit[] targets = Physics.SphereCastAll(origin, radius, origin, radius);
            //  // print("AoE Hit List: " + targets);

            // foreach (RaycastHit hit in targets)
            // {
            //  var target = hit.collider.gameObject.GetComponent<IDamageable>();
            //  // TODO: consider using Tag or layer, so enemies don't damage each other
            //  if (target != null && target != useParams.user)
            //  {
            //      target.TakeDamage(damageAmount);
            //  }
            // }
        }
Esempio n. 28
0
 abstract public void Use(AbilityUseParams args);
Esempio n. 29
0
        private void DoSelfHeal(AbilityUseParams useParams)
        {
            float pointsToHeal = config.GetHealingAmount();

            player.Heal(pointsToHeal);
        }
Esempio n. 30
0
 public void Use(AbilityUseParams useParams)
 {
     DoSelfHeal(useParams);
     PlaySound();
     PlayParticleEffect();
 }