public RangedAttacks RangedAttack(AttackHandler handler, ref RangedAttacks prefab, RangedAttacks currentAttack, InputAction.CallbackContext ctx)
    {
        if (handler.playerManager.energy.currentEnergy - energyCost > 0 && !prefab.coolingdown)
        {
            if (ctx.started)
            {
                GameObject attack = ObjectPooler.SharedInstance.GetPooledObject(tag);
                attack.transform.position = handler.transform.position;
                attack.transform.rotation = handler.transform.rotation;
                attack.SetActive(true);

                currentAttack           = attack.GetComponent <RangedAttacks>();
                currentAttack.performer = handler.caster;
                return(currentAttack);
            }


            if (currentAttack != null)
            {
                if (ctx.performed)
                {
                    currentAttack.OnTriggered(handler.caster);
                    return(currentAttack);
                }
                if (ctx.canceled)
                {
                    currentAttack.OnReleased();
                }
            }
            return(currentAttack);
        }
        return(null);
    }
Esempio n. 2
0
 protected override void Start()
 {
     base.Start();
     projectileFactory = GameObject.FindGameObjectsWithTag("ProjectileFactory")[0].GetComponent <ProjectileFactory>();
     RangedAttacks.Add(new Delegates.EmptyDel(ShootProjectiles));
     RangedAttacks.Add(new Delegates.EmptyDel(ShootLargerProjectile));
 }
Esempio n. 3
0
 public void _OnTertiaryAbility(InputAction.CallbackContext ctx)
 {
     tertiaryAttack = TertiaryRange.RangedAttack(this, ref TertiaryRange, tertiaryAttack, ctx);;
     if (ctx.canceled)
     {
         StartCoroutine(SecondaryRange.FireRate());
     }
 }
Esempio n. 4
0
 public void _OnPrimaryAbility(InputAction.CallbackContext ctx)
 {
     primaryAttack = PrimaryRange.RangedAttack(this, ref PrimaryRange, primaryAttack, ctx);
     if (ctx.canceled)
     {
         StartCoroutine(PrimaryRange.FireRate());
     }
 }
Esempio n. 5
0
 void OnEnable()
 {
     rotationRange    = Random.Range(-135, 135);
     rangedAttacks    = GetComponent <RangedAttacks>();
     distanceToTarget = Vector3.Distance(rangedAttacks.origin, rangedAttacks.targetPoint);
     currentDistance  = 0.1f;
     flightPercentage = 0.1f;
 }
 void Start()
 {
     cam           = Camera.main;
     rangedAttacks = GetComponent <RangedAttacks>();
 }
Esempio n. 7
0
 void Awake()
 {
     attack     = GetComponent <RangedAttacks>();
     attackMesh = GetComponent <MeshRenderer>();
 }