Exemplo n.º 1
0
    private static GameObject getEffectForImpact(ProjectileEffect effectType, ImpactType impactType)
    {
        switch (effectType)
        {
        case ProjectileEffect.BULLET: {
            switch (impactType)
            {
            case ImpactType.GROUND:
                return(ProjectileImpactManager.dustImpactPrefabRef);

            case ImpactType.METAL:
                return(ProjectileImpactManager.metalImpactPrefabRef);

            case ImpactType.PROJECTILE:
                return(ProjectileImpactManager.projectileImpactPrefabRef);

            default:
                throw new ArgumentException($"unhandled impact type {impactType}");
            }
        }

        default:
            throw new ArgumentException($"unhandled effect type {effectType}");
        }
    }
Exemplo n.º 2
0
 public EffectInstance(EnemyInstance enemy, ProjectileEffect effect, float waveStartTime)
 {
     Enemy     = enemy;
     Effect    = effect;
     StartTime = waveStartTime;
     LastTime  = waveStartTime;
     Completed = false;
 }
Exemplo n.º 3
0
    protected override void PlayEffect()
    {
        GameObject effect = Instantiate <GameObject>(effectPrefab);

        effect.transform.position = transform.position;
        ProjectileEffect skillEffect = effect.GetComponent <ProjectileEffect>();

        skillEffect.responseList = damageInfo.responseList;
        skillEffect.endPos       = target[0].transform.position;
    }
Exemplo n.º 4
0
    private static void instantiateImpactEffect(
        ProjectileEffect effectType,
        ImpactType impactType,
        float3 position,
        float3 normal
        )
    {
        var effectInstance = objectPools[getEffectForImpact(effectType, impactType)].getObject();

        effectInstance.transform.position = new Vector3(position.x, position.y, position.z);
        effectInstance.transform.rotation = Quaternion.LookRotation(normal);
        effectInstance.SetActive(true);
    }
Exemplo n.º 5
0
        private void NewEffect_Clicked(object sender, EventArgs e)
        {
            ProjectileEffect effect = new ProjectileEffect();

            effect.EffectType     = ProjectileEffectType.Damage;
            effect.EffectDuration = 0.0F;
            effect.EffectImpact   = 1.0F;
            Projectile.Effects.Add(effect);

            WriteChanges();

            PopulateTreeWithEffects();
        }
Exemplo n.º 6
0
    protected override void PlayEffect()
    {
        GameObject effect = Instantiate <GameObject>(effectPrefab);

        effect.transform.position = transform.position;
        ProjectileEffect skillEffect = effect.GetComponent <ProjectileEffect>();

        skillEffect.responseList = damageInfo.responseList;
        skillEffect.endPos       = target[0].transform.position;
        if (isCharge)
        {
            effect.transform.localScale = new Vector3(4.0f, 4.0f);
            isCharge = false;
        }
    }
Exemplo n.º 7
0
    void Start()
    {
        // go through the effects, add each effect's projectiles to the projectile lists
        foreach (Effect e in myEffects)
        {
            if (e is ProjectileEffect)
            {
                ProjectileEffect pe = (ProjectileEffect)e;
                if (pe.GetMuzzleParticles())
                {
                    muzzleParticlesPrefabs.Add(pe.GetMuzzleParticles());
                }
                if (pe.GetProjectileParticles())
                {
                    projectileParticlesPrefabs.Add(pe.GetProjectileParticles());
                }
            }
            else if (e is ImpactEffect)
            {
                ImpactEffect ie = (ImpactEffect)e;
                if (ie.GetImpactParticles())
                {
                    impactParticlesPrefabs.Add(ie.GetImpactParticles());
                }
            }
        }

        // Then create the projectiles for the start
        foreach (GameObject ppp in projectileParticlesPrefabs)
        {
            GameObject particles = Instantiate(ppp, transform.position, transform.rotation);
            particles.transform.parent = transform;
            projectileParticles.Add(particles);
        }
        if (muzzleParticlesPrefabs.Count > 0)
        {
            foreach (GameObject mpp in muzzleParticlesPrefabs)
            {
                GameObject particles = Instantiate(mpp, transform.position, transform.rotation);
                muzzleParticles.Add(particles);
                DestroyMuzzleParticles(1.5f); // destroy the particles after making them
            }
        }
    }
Exemplo n.º 8
0
        public void AddProjectile()
        {
            Projectile p = new Projectile();

            p.Name     = "New Projectile";
            p.Asset    = "";
            p.AirSpeed = 1.0F;

            ProjectileEffect pe = new ProjectileEffect();

            pe.EffectType     = ProjectileEffectType.Damage;
            pe.EffectDuration = 0.0F;
            pe.EffectImpact   = 1.0F;
            p.Effects.Add(pe);

            Projectiles.Add(p);

            WriteChanges();

            TreeRefreshNeeded?.Invoke();
        }
Exemplo n.º 9
0
    private void PerformProjectileEffect(ProjectileEffect effect, KeyType type, int keyEffect, int projectileEffect)
    {
        // Don't do anything if on cool down
        if (effect.onCoolDown)
        {
            return;
        }

        // Use up energy if we can
        if (partUsesEnergy && !energy.UseEnergy(effect.energyUsage))
        {
            return;
        }

        // Perform cool down
        if (effect.coolDown > 0f && !effect.onCoolDown)
        {
            StartCoroutine(ProjectileEffectCoolDownTime(type, keyEffect, projectileEffect));
        }

        // Play fire animation
        if (anim)
        {
            for (int i = 0; i < effect.animationParameters.Length; i++)
            {
                StartCoroutine(PlayAnimation(effect.animationParameters[i]));
            }
        }

        // Delay effect for specified amount of time
        if (effect.effectDelay > 0)
        {
            StartCoroutine(WaitForProjectileDelay(effect));
            return;
        }

        SpawnProjectile(effect);
    }
Exemplo n.º 10
0
    private void SpawnProjectile(ProjectileEffect effect)
    {
        effect.firePoint.localRotation = Quaternion.Euler(0f, 0f, facingRight ? 0f : 180f);

        Projectile newProjectile = Instantiate(effect.projectile,
                                               effect.firePoint.position,
                                               effect.firePoint.rotation).GetComponent <Projectile>();

        // Failed to create a new projectile
        if (!newProjectile)
        {
            return;
        }

        // Initialize the projectile
        Vector3 rotatedVector = Quaternion.AngleAxis(effect.angleOffset, Vector3.forward) * effect.firePoint.right;

        newProjectile.SetDirection(rotatedVector);
        newProjectile.SetPower(effect.power);
        newProjectile.SetSpeed(effect.speed);
        newProjectile.SetShooter(gameObject);
        newProjectile.SetLifeTime(effect.lifeTime);
        newProjectile.SetIgnoreLayers(effect.ignoreLayers);
    }
Exemplo n.º 11
0
 public void IsHit(int damage, ProjectileEffect projectileEffect)
 {
     ApplyProjectileEffect(projectileEffect);
       Data.CurrentHp -= damage;
       if (Data.CurrentHp <= 0) SetDead();
 }
Exemplo n.º 12
0
 private void ApplyProjectileEffect(ProjectileEffect projectileEffect)
 {
     switch (projectileEffect)
       {
     case ProjectileEffect.Slow:
       Data.Speed /= 2;
       _isDebuffed = true;
       break;
     case ProjectileEffect.AoeSlow:
       break;
     case ProjectileEffect.Heal:
       break;
     case ProjectileEffect.Burn:
       break;
     case ProjectileEffect.Explode:
       break;
     case ProjectileEffect.None:
       break;
     default:
       break;
       }
 }
Exemplo n.º 13
0
 public static ImpactEffect toComponent(this ProjectileEffect effect)
 {
     return(new ImpactEffect {
         value = ProjectileEffect.BULLET
     });
 }
Exemplo n.º 14
0
    IEnumerator WaitForProjectileDelay(ProjectileEffect effect)
    {
        yield return(new WaitForSeconds(effect.effectDelay));

        SpawnProjectile(effect);
    }