Beispiel #1
0
        public override bool PerTick(Effectable eff)
        {
            var dt = Time.deltaTime;

            foreach (Effect e in eff.effects)
            {
                e.ChangeTime(eff, ref dt);
            }

            time += dt;

            if (time > fireTime)
            {
                time = 0;
                var spawned = GameObject.Instantiate(firePrefab);
                spawned.transform.position = eff.transform.position;
                spawned.transform.parent   = GameManager.Instance.holder.transform;
                var proj = spawned.GetComponent <Effectable>();
                if (proj != null)
                {
                    var effectsToTransfer = eff.GetEffectSublist(1);
                    for (int i = effectsToTransfer.Count - 1; i >= 0; i--)
                    {
                        if (effectsToTransfer[i] is FireOnTick)
                        {
                            effectsToTransfer.RemoveAt(i);
                        }
                    }

                    proj.AddEffects(eff.GetEffectSublist(1));
                    proj.doNotHit = eff.GetComponent <Resources>();
                }

                return(true);
            }

            return(false);
        }
        public override bool PerTick(Effectable eff)
        {
            var dt = Time.deltaTime;

            foreach (Effect e in eff.effects)
            {
                e.ChangeTime(eff, ref dt);
            }

            time += dt;

            if (time < delayBetween)
            {
                return(false);
            }
            time = 0;

            var effectsToTransfer = eff.GetEffectSublist(1);

            effectsToTransfer.Remove(this);
            for (int i = effectsToTransfer.Count - 1; i >= 0; i--)
            {
                if (effectsToTransfer[i] is SpawnProjectileConstant)
                {
                    effectsToTransfer.RemoveAt(i);
                }
            }

            for (int i = 0; i < number; i++)
            {
                var angle    = Mathf.PI / 4 + (i / (float)number) * 2 * Mathf.PI;
                var velocity = new Vector2(Mathf.Cos(angle), Mathf.Sin(angle));

                var spawned = Instantiate(spawnOnHit);
                var newProj = spawned.GetComponent <Projectile>();
                if (newProj != null)
                {
                    newProj.AddEffects(effectsToTransfer);
                    newProj.doNotHit       = eff.GetComponent <Resources>();
                    newProj.doNotHitLayers = eff.gameObject.layer;
                    newProj.SetVelocity(velocity * speed);
                }

                spawned.transform.parent   = GameManager.Instance.holder.transform;
                newProj.transform.position = eff.transform.position + new Vector3(velocity.x, velocity.y, 0) * 0.1f;
            }

            return(true);
        }
Beispiel #3
0
        public void Hit(Effectable eff)
        {
            var effectsToTransfer = eff.GetEffectSublist(1);

            effectsToTransfer.Remove(this);

            var spawned = GameObject.Instantiate(spawnOnHit);
            var newEff  = spawned.GetComponent <Effectable>();

            if (newEff != null)
            {
                newEff.AddEffects(effectsToTransfer);
                newEff.doNotHit = eff.GetComponent <Resources>();
            }

            spawned.transform.position = eff.transform.position;
            spawned.transform.parent   = GameManager.Instance.holder.transform;
        }