public MeleeAbility(UseableAbility useableAbility, ForwardTriggerCollision forwardTrigger, CharacterBase ownerCharacter) : base(useableAbility, ownerCharacter) { this.forwardTrigger = forwardTrigger; this.forwardTrigger.Initialize(TriggerEnter); this.forwardTrigger.InitializeStay(TriggerEnter); _hasHit = true; }
public ProjectileAbility(UseableAbility useableAbility, CharacterBase ownerCharacter) : base(useableAbility, ownerCharacter) { }
public ModifierAbility(UseableAbility useableAbility, CharacterBase ownerCharacter) : base(useableAbility, ownerCharacter) { }
protected AttackAbility(UseableAbility useableAbility, CharacterBase ownerCharacter) : base(useableAbility, ownerCharacter) { }
public static BaseAbility Create(UseableAbility useableAbility, Item scriptableAbility, CharacterBase ownerCharacter, GameObject worldGameObject, AttackAbility.HitAction hitAction = null, AttackAbility.EndAttackAction endAttackAction = null) { Func <BaseAbility> abilityFunc = () => { switch (scriptableAbility) { case ScriptableMeleeAbility _: { ForwardTriggerCollision forwardTrigger = worldGameObject.GetComponentInChildren <ForwardTriggerCollision>(); MeleeAbility meleeAbility = new MeleeAbility(useableAbility, forwardTrigger, ownerCharacter); if (hitAction != null) { meleeAbility.OnHit += hitAction; } if (endAttackAction != null) { meleeAbility.OnEndAttack += endAttackAction; } return(meleeAbility); } case ScriptableRaycastAbility _: int layerMask = ~0; switch (ownerCharacter) { case AIBase aiBase: layerMask = layerMask &= ~(1 << LayerMask.NameToLayer("Enemy")); break; case PlayerBase playerBase: layerMask = layerMask &= ~(1 << LayerMask.NameToLayer("Player")); layerMask = layerMask &= ~(1 << LayerMask.NameToLayer("Hands")); break; } RaycastAbilitiy raycastAbility = new RaycastAbilitiy(useableAbility, ownerCharacter, layerMask); if (hitAction != null) { raycastAbility.OnHit += hitAction; } if (endAttackAction != null) { raycastAbility.OnEndAttack += endAttackAction; } return(raycastAbility); case ScriptableProjectileAbility _: ProjectileAbility projectileAbility = new ProjectileAbility(useableAbility, ownerCharacter); if (hitAction != null) { projectileAbility.OnHit += hitAction; } if (endAttackAction != null) { projectileAbility.OnEndAttack += endAttackAction; } return(projectileAbility); case ScriptableUseableAbility _: return(new ModifierAbility(useableAbility, ownerCharacter)); } throw new Exception($"{scriptableAbility.GetType()} doesn't exist within the AbilityFactory"); }; //Add base abilities to useable object BaseAbility baseAbility = abilityFunc.Invoke(); useableAbility.Modifiers.AddRange(baseAbility.Ability.StartingModifiers); return(baseAbility); }
protected BaseAbility(UseableAbility useableAbility, CharacterBase ownerCharacter) { this.ability = useableAbility.ScriptableAbility; this.useableAbility = useableAbility; this.ownerCharacter = ownerCharacter; }
public RaycastAbilitiy(UseableAbility useableAbility, CharacterBase ownerCharacter, int layerMask) : base(useableAbility, ownerCharacter) { this.layerMask = layerMask; }