public static void EndEffect(LSEffect effect)
 {
     if (EffectActive[effect.ID] == false) return;
     effect.Deactivate ();
     EffectPool[effect.MyEffectCode].Add (effect);
     EffectActive[effect.ID] = false;
     Effects[effect.ID] = null;
     OpenSlots.Add (effect.ID);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Eliminates an effect and allows the Garbage Collector to clean it up.
 /// </summary>
 /// <param name="effect">Effect.</param>
 public static void DestroyEffect(LSEffect effect)
 {
     if (EffectActive[effect.ID] == false)
     {
         return;
     }
     EffectActive[effect.ID] = false;
     OpenSlots.Add(effect.ID);
 }
Ejemplo n.º 3
0
        public static void LazyCreateEffect(string effectCode, Transform SpawnPoint)
        {
            if (!IsValid(effectCode))
            {
                return;
            }
            LSEffect effect = CreateEffect(effectCode);

            effect.CachedTransform.position = SpawnPoint.position;
            effect.Initialize();
        }
Ejemplo n.º 4
0
        public static void LazyCreateEffect(EffectCode effectCode, Vector3 position, Quaternion rotation)
        {
            if (effectCode == EffectCode.None)
            {
                return;
            }
            LSEffect effect = CreateEffect(effectCode);

            effect.CachedTransform.position = position;
            effect.Initialize();
        }
Ejemplo n.º 5
0
        public static void LazyCreateEffect(EffectCode effectCode, Transform SpawnPoint)
        {
            if (effectCode == EffectCode.None)
            {
                return;
            }
            LSEffect effect = CreateEffect(effectCode);

            effect.CachedTransform.position = SpawnPoint.position;
            effect.Initialize();
        }
Ejemplo n.º 6
0
        public static void LazyCreateEffect(string effectCode, Vector3 position, Quaternion rotation)
        {
            if (!IsValid(effectCode))
            {
                return;
            }
            LSEffect effect = CreateEffect(effectCode);

            effect.CachedTransform.position = position;
            effect.Initialize();
        }
Ejemplo n.º 7
0
        public static void LazyCreateEffect(string effectCode, Vector3 position)
        {
            if (effectCode == "None")
            {
                return;
            }
            LSEffect effect = CreateEffect(effectCode);

            effect.CachedTransform.position = position;
            effect.Initialize();
        }
Ejemplo n.º 8
0
        public static void LazyCreateEffect(string effectCode, Transform spawnParent)
        {
            if (!IsValid(effectCode))
            {
                return;
            }
            LSEffect effect = CreateEffect(effectCode);

            effect.CachedTransform.parent = spawnParent;
            Fire(effect);
        }
Ejemplo n.º 9
0
        public static void LazyCreateEffect(string effectCode, Vector3 position)
        {
            if (!IsValid(effectCode))
            {
                return;
            }
            LSEffect effect = CreateEffect(effectCode);

            effect.CachedTransform.position = position;
            Fire(effect);
        }
Ejemplo n.º 10
0
 void HitAgent(LSAgent agent)
 {
     if (this.UseEffects && this.AttachEndEffectToTarget)
     {
         LSEffect lSEffect = EffectManager.CreateEffect(this.HitFX);
         lSEffect.CachedTransform.parent        = agent.VisualCenter;
         lSEffect.CachedTransform.localPosition = Vector3.up;
         lSEffect.CachedTransform.rotation      = this.cachedTransform.rotation;
         lSEffect.Initialize();
     }
     this.HitEffect(agent);
 }
Ejemplo n.º 11
0
 public static void EndEffect(LSEffect effect)
 {
     if (EffectActive[effect.ID] == false)
     {
         return;
     }
     effect.Deactivate();
     EffectPool[effect.MyEffectCode].Add(effect);
     EffectActive[effect.ID] = false;
     Effects[effect.ID]      = null;
     OpenSlots.Add(effect.ID);
 }
Ejemplo n.º 12
0
        public static LSEffect CreateEffect(string effectCode)
        {
            if (!IsValid(effectCode))
            {
                return(null);
            }

            LSEffect effect = GenEffect(effectCode, -1);

            EffectActive[effect.ID] = true;
            Effects[effect.ID]      = effect;
            return(effect);
        }
Ejemplo n.º 13
0
        public static LSEffect CreateEffect(string effectCode, Vector3 position, Quaternion rotation)
        {
            if (!IsValid(effectCode))
            {
                return(null);
            }
            LSEffect effect = CreateEffect(effectCode);

            effect.CachedTransform.position = position;
            effect.CachedTransform.rotation = rotation;
            Fire(effect);
            return(effect);
        }
Ejemplo n.º 14
0
 private void Hit()
 {
     if (this.DamageBehavior == DamageType.Single && this.Target.SpawnVersion != this.TargetVersion)
     {
         ProjectileManager.EndProjectile(this);
         return;
     }
     this.OnHit();
     if (this.onHit.IsNotNull())
     {
         this.onHit.Invoke();
     }
     if (this.UseEffects)
     {
         if (this.AttachEndEffectToTarget)
         {
             LSEffect lSEffect = EffectManager.CreateEffect(this.EndEffect);
             lSEffect.CachedTransform.parent        = this.Target.VisualCenter;
             lSEffect.CachedTransform.localPosition = Vector3.up;
             lSEffect.Initialize();
         }
         else
         {
             DamageType damageBehavior = this.DamageBehavior;
             if (damageBehavior != DamageType.Single)
             {
                 if (damageBehavior == DamageType.Area)
                 {
                     EffectManager.LazyCreateEffect(this.EndEffect, base.transform.position, this.cachedTransform.rotation);
                 }
             }
             else
             {
                 EffectManager.LazyCreateEffect(this.EndEffect, this.Target.CachedTransform.position, this.cachedTransform.rotation);
             }
         }
     }
     ProjectileManager.EndProjectile(this);
 }
Ejemplo n.º 15
0
 private void Hit(bool destroy = true)
 {
     this.OnHit();
     if (this.onHit.IsNotNull())
     {
         this.onHit();
     }
     if (this.TargetCurrent)
     {
         if (this.UseEffects)
         {
             if (this.AttachEndEffectToTarget)
             {
                 LSEffect lSEffect = EffectManager.CreateEffect(this.HitFX);
                 lSEffect.CachedTransform.parent        = this.Target.VisualCenter;
                 lSEffect.CachedTransform.localPosition = Vector3.up;
                 lSEffect.CachedTransform.rotation      = this.cachedTransform.rotation;
                 lSEffect.Initialize();
             }
             else
             {
                 //Certain targeting types collide with a target
                 if (this.TargetingBehavior == TargetingType.Homing)
                 {
                     EffectManager.CreateCollisionEffect(this.HitFX, this, Target.Body);
                 }
                 else
                 {
                     EffectManager.CreateEffect(this.HitFX, this.cachedTransform.position, this.cachedTransform.rotation);
                 }
             }
         }
     }
     if (destroy)
     {
         ProjectileManager.EndProjectile(this);
     }
 }
Ejemplo n.º 16
0
        public void LateInit()
        {
            if (this.TargetingBehavior != TargetingType.Timed)
            {
                this.cachedTransform.position = this.Position.ToVector3();
                this.speedPerFrame            = this.Speed / 32L;
            }



            switch (this.TargetingBehavior)
            {
            case TargetingType.Timed:
                this.CountDown = this.Delay;

                break;

            case TargetingType.Positional:
            case TargetingType.Homing:
                long f         = this.Position.ToVector2d().Distance(this.TargetPosition);
                long timeToHit = f.Div(this.Speed);
                if (this._visualArc)
                {
                    this.arcStartHeight = this.Position.z;
                    if (timeToHit > 0)
                    {
                        this.arcStartVerticalSpeed = (this.TargetHeight - this.Position.z).Div(timeToHit) + timeToHit.Mul(Gravity);
                    }
                }
                else
                {
                    if (timeToHit > 0)
                    {
                        this.linearHeightSpeed = (this.TargetHeight - Position.z).Div(timeToHit).Abs() / LockstepManager.FrameRate;
                    }
                }
                Forward = TargetPosition - this.Position.ToVector2d();
                Forward.Normalize();
                break;

            case TargetingType.Free:

                Vector3d vel = this.Direction;
                vel.Mul(speedPerFrame);
                this.Velocity = vel;


                break;
            }
            if (this.CanRotate)
            {
                this.cachedTransform.LookAt(this.Direction.ToVector3());
            }
            this.UpdateVisuals();

            if (this.onInitialize.IsNotNull())
            {
                this.onInitialize.Invoke();
            }

            if (UseEffects)
            {
                LSEffect effect = EffectManager.LazyCreateEffect(this.StartFX, this.Position.ToVector3(), this.cachedTransform.rotation);
                if (effect != null)
                {
                    effect.StartPos = this.Position.ToVector3();
                    effect.EndPos   = this.TargetPosition.ToVector3(this.TargetHeight.ToFloat());
                    if (this.Target != null)
                    {
                        effect.Target = Target.transform;
                    }
                }
            }
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Eliminates an effect and allows the Garbage Collector to clean it up.
 /// </summary>
 /// <param name="effect">Effect.</param>
 public static void DestroyEffect(LSEffect effect)
 {
     if (EffectActive[effect.ID] == false) return;
     EffectActive[effect.ID] = false;
     OpenSlots.Add (effect.ID);
 }
Ejemplo n.º 18
0
 public static void Fire(LSEffect effect)
 {
     effect.Initialize();
 }