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); }
private void Hit() { if (this.TargetingBehavior == TargetingType.Homing && this.HitBehavior == HitType.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 { { EffectManager.LazyCreateEffect(this.EndEffect, this.cachedTransform.position, this.cachedTransform.rotation); } } } ProjectileManager.EndProjectile(this); }
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.Directional: 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.CreateEffect (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; } } }
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); }