Пример #1
0
        protected override IEnumerator ActivateAbility()
        {
            AbilitySystemCharacter target = null;

            var cdSpec   = this.Owner.MakeOutgoingSpec(this.Ability.Cooldown);
            var costSpec = this.Owner.MakeOutgoingSpec(this.Ability.Cost);

            // Find enemy in front using raycast and set that as target
            if (Physics.Raycast(this.CastPointComponent.GetPosition() + new Vector3(0, 0, 1), this.Owner.transform.TransformDirection(Vector3.forward), out var hit, Mathf.Infinity))
            {
                Debug.DrawRay(this.CastPointComponent.GetPosition(), this.Owner.transform.TransformDirection(Vector3.forward) * hit.distance, Color.yellow);
                target = hit.transform.GetComponent <AbilitySystemCharacter>();
                if (!target)
                {
                    EndAbility();
                    yield break;
                }

                var go = Instantiate(this.projectile.gameObject, this.CastPointComponent.GetPosition(), this.CastPointComponent.transform.rotation);
                var projectileInstance = go.GetComponent <Projectile>();
                projectileInstance.Source = Owner;
                projectileInstance.Target = target;
                this.Owner.ApplyGameplayEffectSpecToSelf(cdSpec);
                this.Owner.ApplyGameplayEffectSpecToSelf(costSpec);
                yield return(projectileInstance.TravelToTarget());

                var effectSpec = this.Owner.MakeOutgoingSpec((this.Ability as MyProjectileAbilityScriptableObject).GameplayEffect);
                target.ApplyGameplayEffectSpecToSelf(effectSpec);
                Destroy(go.gameObject);
            }

            EndAbility();

            // Spawn instance of projectile prefab
        }
        /// <summary>
        /// Checks if an Ability System Character has none of the listed tags
        /// </summary>
        /// <param name="asc">Ability System Character</param>
        /// <param name="tags">List of tags to check</param>
        /// <returns>True, if the Ability System Character has none of the tags</returns>
        protected virtual bool AscHasNoneTags(AbilitySystemCharacter asc, GameplayTagScriptableObject[] tags)
        {
            // If the input ASC is not valid, assume check passed
            if (!asc)
            {
                return(true);
            }

            for (var iAbilityTag = 0; iAbilityTag < tags.Length; iAbilityTag++)
            {
                var abilityTag = tags[iAbilityTag];

                bool requirementPassed = true;
                for (var iAsc = 0; iAsc < asc.AppliedGameplayEffects.Count; iAsc++)
                {
                    GameplayTagScriptableObject[] ascGrantedTags = asc.AppliedGameplayEffects[iAsc].spec.GameplayEffect.gameplayEffectTags.GrantedTags;
                    for (var iAscTag = 0; iAscTag < ascGrantedTags.Length; iAscTag++)
                    {
                        if (ascGrantedTags[iAscTag] == abilityTag)
                        {
                            requirementPassed = false;
                        }
                    }
                }
                // If any ability tag wasn't found, requirements failed
                if (!requirementPassed)
                {
                    return(false);
                }
            }
            return(true);
        }
        /// <summary>
        /// Creates the Ability Spec, which is instantiated for each character.
        /// </summary>
        /// <param name="owner"></param>
        /// <returns></returns>
        public override AbstractAbilitySpec CreateSpec(AbilitySystemCharacter owner)
        {
            var spec = new SimpleAbilitySpec(this, owner);

            spec.Level = owner.Level;
            return(spec);
        }
        public override AbstractAbilitySpec CreateSpec(AbilitySystemCharacter owner)
        {
            var spec = new InitialiseStatsAbility(this, owner);

            spec.Level = owner.Level;
            return(spec);
        }
Пример #5
0
    public override AbstractAbilitySpec CreateSpec(AbilitySystemCharacter owner)
    {
        var spec = new MyProjectileAbilitySpec(this, owner);

        spec.Level              = owner.Level;
        spec.projectile         = this.projectile;
        spec.CastPointComponent = owner.GetComponent <CastPointComponent>();
        return(spec);
    }
Пример #6
0
    // Start is called before the first frame update
    void Start()
    {
        this.abilitySystemCharacter = GetComponent <AbilitySystemCharacter>();
        var spec = Abilities[0].CreateSpec(this.abilitySystemCharacter);

        this.abilitySystemCharacter.GrantAbility(spec);
        ActivateInitialisationAbilities();
        GrantCastableAbilities();
    }
 /// <summary>
 /// Creates the Ability Spec (the instantiation of the ability)
 /// </summary>
 /// <param name="owner">Usually the character casting thsi ability</param>
 /// <returns>Ability Spec</returns>
 public abstract AbstractAbilitySpec CreateSpec(AbilitySystemCharacter owner);
 /// <summary>
 /// Default constructor.  Initialises the AbilitySpec from the AbstractAbilityScriptableObject
 /// </summary>
 /// <param name="ability">Ability</param>
 /// <param name="owner">Owner - usually the character activating the ability</param>
 public AbstractAbilitySpec(AbstractAbilityScriptableObject ability, AbilitySystemCharacter owner)
 {
     this.Ability = ability;
     this.Owner   = owner;
 }
Пример #9
0
 public MyProjectileAbilitySpec(AbstractAbilityScriptableObject ability, AbilitySystemCharacter owner) : base(ability, owner)
 {
 }
 public SimpleAbilitySpec(AbstractAbilityScriptableObject abilitySO, AbilitySystemCharacter owner) : base(abilitySO, owner)
 {
 }
 public InitialiseStatsAbility(AbstractAbilityScriptableObject abilitySO, AbilitySystemCharacter owner) : base(abilitySO, owner)
 {
 }