Beispiel #1
0
    /// <summary>
    /// Use player shield
    /// </summary>
    /// <returns></returns>
    private IEnumerator UserShield(PowerUps.PowerUpData data, Entity entity)
    {
        shieldSprite.SetActive(true);
        entity.CanTakeDamage = false;
        yield return(new WaitForSeconds(data.ExpireTime));

        entity.CanTakeDamage = true;
        shieldSprite.SetActive(false);
    }
Beispiel #2
0
    /// <summary>
    /// Fire the torpedios
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    private IEnumerator FireTorpidoes(PowerUps.PowerUpData data)
    {
        float interval = 0;
        float timer    = 0;

        while (timer <= 1)
        {
            if (interval >= 8)
            {
                InputController.SpecialWeaponFire?.Invoke(1);
                interval = 0;
            }
            interval++;
            timer += Time.deltaTime / data.ExpireTime;
            yield return(null);
        }
    }
 /// <summary>
 /// Set the powerup data
 /// </summary>
 /// <param name="data"></param>
 public void SetUpData(int index, PowerUps.PowerUpData data)
 {
     powerUpText.text = "P" + (index + 1);
     powerUpData      = data;
     StartCoroutine(ChargePowerUp());
 }
Beispiel #4
0
 /// <summary>
 /// Activate torpedos
 /// </summary>
 /// <param name="data"></param>
 /// <param name="entity"></param>
 public override void Activate(PowerUps.PowerUpData data, Entity entity)
 {
     StartCoroutine(FireTorpidoes(data));
 }
 /// <summary>
 /// Fire missile
 /// </summary>
 /// <param name="data"></param>
 /// <param name="entity"></param>
 public override void Activate(PowerUps.PowerUpData data, Entity entity)
 {
     InputController.SpecialWeaponFire?.Invoke(0);
 }
 /// <summary>
 /// Activate the ability
 /// </summary>
 /// <param name="data"></param>
 /// <param name="entity"></param>
 public abstract void Activate(PowerUps.PowerUpData data, Entity entity);
 /// <summary>
 /// Player powerups code
 /// </summary>
 /// <param name="type"></param>
 private void AbilityUsed(PowerUps.PowerUpData data)
 {
     abilities[(int)data.Type].Activate(data, holder.ObjectEntity);
 }
Beispiel #8
0
 /// <summary>
 /// Activate shield
 /// </summary>
 /// <param name="data"></param>
 /// <param name="entity"></param>
 public override void Activate(PowerUps.PowerUpData data, Entity entity)
 {
     StartCoroutine(UserShield(data, entity));
 }