private void OnTriggerExit(Collider other) { if (other.gameObject.layer == affectorLayer) { affector = other.GetComponent <Affector>(); if (affector.isBoost) { isInBoostZone = false; } if (affector.isJump) { isInJumpZone = false; } if (affector.isWater) { isInWater = false; } if (affector.isOil) { isInOil = false; } } }
public void Generate2() { var script = "E1(=A, +0.01)"; var f = Affector.Generate <EntitySet>(script); var entitySet = CreateTestEntitySet(); var actual = f(entitySet); actual.FieldValue.Is(entitySet.FieldValue); foreach (var i in new[] { 0, 1 }) { Eq(actual.E1[i], new Entity { Key1 = entitySet.E1[i].Key1, Key2 = entitySet.E1[i].Key2, Value1 = entitySet.E1[i].Value1 + 0.01, Value2 = entitySet.E1[i].Value2 + 0.01 }).IsTrue(); } foreach (var i in new[] { 2, 3 }) { Eq(actual.E1[i], new Entity { Key1 = entitySet.E1[i].Key1, Key2 = entitySet.E1[i].Key2, Value1 = entitySet.E1[i].Value1, Value2 = entitySet.E1[i].Value2 }).IsTrue(); } }
public void Reset() { this.Position = Vectors.up * 9999f; this.Velocity = Vectors.zero; this.Acceleration = 0f; this.ElapsedTime = 0f; this.LastWorldPos = (this.CurWorldPos = Vectors.zero); foreach (object obj in this.AffectorList) { Affector affector = (Affector)obj; affector.Reset(); } if (this.Type == 1) { this.Sprite.SetRotation((float)this.OriRotateAngle); this.Sprite.SetPosition(this.Position); this.Sprite.SetColor(Color.clear); this.Sprite.Update(true); this.Scale = Vectors.v2one; } else if (this.Type == 2) { this.Ribbon.SetHeadPosition(this.ClientTrans.position + this.OriDirection.normalized * this.Owner.TailDistance); this.Ribbon.Reset(); this.Ribbon.SetColor(Color.clear); this.Ribbon.UpdateVertices(Vectors.zero); } }
public void Throw(int dir, Transform source) { if (dir > 0) { initialDirection = 1; } else { initialDirection = -1; } curVeloX = startSpeed * initialDirection; curVeloY = 0; accelX = decel * dir * -1; transform.position = source.position + new Vector3(dir * spawnOffset.x, spawnOffset.y, 0); Affector a = TargetFinder.SpawnAffector(transform.position, 2f, HashLookup.EnemiesMask); a.OnTouch += TornadoTouchHandler; a.SetLifetime(lifetime); a.transform.SetParent(transform); affector = a; state = TornadoProjStates.Outgoing; thrower = source; }
void SpawnAffector(bool type, int dur, float x, float y) { Vector3 pos = new Vector3(screenOriginX + screenScaleX * x, screenOriginY + screenScaleY * y, 0f); Affector affec = (Affector)Instantiate(affectorPrefab, pos, Quaternion.identity); affec.type = type; affec.duration = dur; }
private Affector CreateNewAffector(AffectorType type) { GameObject go = new GameObject(); go.name = "Affector_" + (int)type; Affector affector = AddAffectorComp(go, type); _mFreeAffectorList.Add(type, affector); return(affector); }
public void Generate1() { var script = "E1(+0.01)"; var f = Affector.Generate <EntitySet>(script); var entitySet = CreateTestEntitySet(); var actual = f(entitySet); actual.FieldValue.Is(entitySet.FieldValue); actual.E1.Select(_ => _.Value1).Is(entitySet.E1.Select(_ => _.Value1 + 0.01)); actual.E1.Select(_ => _.Value2).Is(entitySet.E1.Select(_ => _.Value2 + 0.01)); }
private Affector AddAffectorComp(GameObject go, AffectorType type) { Affector affector = null; switch (type) { case AffectorType.DELAY_FLY_UP: affector = go.AddComponent <AffectorDelayFlyUp>() as AffectorDelayFlyUp; break; case AffectorType.DELAY_FADE: affector = go.AddComponent <AffectorDelayFade>() as AffectorDelayFade; break; } return(affector); }
public void Update() { this.ElapsedTime += Time.deltaTime; foreach (object obj in this.AffectorList) { Affector affector = (Affector)obj; affector.Update(); } this.Position += this.Velocity * Time.deltaTime; if ((double)Mathf.Abs(this.Acceleration) > 0.0001) { this.Velocity += this.Velocity.normalized * this.Acceleration * Time.deltaTime; } if (this.SyncClient) { this.CurWorldPos = this.ClientTrans.TransformPoint(this.Position); } else { this.CurWorldPos = this.Position; } if (this.Type == 1) { this.UpdateSprite(); } else if (this.Type == 2) { this.UpdateRibbonTrail(); } this.LastWorldPos = this.CurWorldPos; if (this.ElapsedTime > this.LifeTime && this.LifeTime > 0f) { this.Reset(); this.Remove(); } }
// Triggers /// <summary> /// Alters the behavior of the configured affector to trigger at random. /// </summary> /// <param name="affector">The configured affector.</param> public static Affector AtRandom(this Affector affector) { ((IAffector)affector).AddTrigger(new RandomTrigger()); return(affector); }
/// <summary> /// Alters the behavior of the configured affector to trigger in a time slot as defined by the <paramref name="moment"/> and <paramref name="duration"/>. /// </summary> /// <param name="affector">The configured affector.</param> /// <param name="moment">A <see cref="DateTimeOffset"/> indicating the start time of the time slot.</param> /// <param name="duration">A <see cref="TimeSpan"/> indicating the length of the time slot.</param> public static Affector PlannedAt(this Affector affector, DateTimeOffset moment, TimeSpan duration) { ((IAffector)affector).AddTrigger(new AgendaTrigger(moment, duration)); return(affector); }
/// <summary> /// Alters the behavior of the configured affector to trigger every time the affected method has been called N times. /// </summary> /// <param name="affector">The configured affector.</param> /// TODO Might need better wording. /// <param name="calls">The amount of calls needed between calls to activate the trigger.</param> public static Affector EveryNCalls(this Affector affector, int calls) { ((IAffector)affector).AddTrigger(new TimesCalledTrigger(TimesCalledOperation.EveryXCalls, calls)); return(affector); }
/// <summary> /// Alters the behavior of the configured affector to trigger when the affected method is being called for the N-th time. /// </summary> /// <param name="affector">The configured affector.</param> /// <param name="calls">The amount of calls needed to activate the trigger once.</param> public static Affector WhenCalledNTimes(this Affector affector, int calls) { ((IAffector)affector).AddTrigger(new TimesCalledTrigger(TimesCalledOperation.At, calls)); return(affector); }
/// <summary> /// Alters the behavior of the configured affector to trigger until the affected method has been called N times. /// </summary> /// <param name="affector">The configured affector.</param> /// <param name="calls">The amount of calls when the trigger is active. After this amount of calls, the trigger becomes inactive.</param> public static Affector UntilNCalls(this Affector affector, int calls) { ((IAffector)affector).AddTrigger(new TimesCalledTrigger(TimesCalledOperation.Until, calls)); return(affector); }
/// <summary> /// Alters the behavior of the configured affector to trigger between <paramref name="from"/> and <paramref name="until"/>. /// </summary> /// <param name="affector">The configured affector.</param> /// <param name="from">Absolute point in time after which this trigger will become active.</param> /// <param name="until">Absolute point in time after which this trigger will become inactive again.</param> public static Affector Between(this Affector affector, TimeSpan from, TimeSpan until) { ((IAffector)affector).AddTrigger(new TimedTrigger(from, until)); return(affector); }
/// <summary> /// Alters the behavior of the configured affector to trigger before the given <paramref name="moment"/> in time. /// </summary> /// <param name="affector">The configured affector.</param> /// <param name="moment">Absolute point in time before which this trigger will be active.</param> public static Affector Before(this Affector affector, TimeSpan moment) { ((IAffector)affector).AddTrigger(new TimedTrigger(moment, TimedOperation.Before)); return(affector); }
protected ArrayList InitAffectors(EffectNode node) { ArrayList arrayList = new ArrayList(); if (UVAffectorEnable) { UVAnimation uVAnimation = new UVAnimation(); Texture texture = Vertexpool.GetMaterial().GetTexture("_MainTex"); if (UVType == 2) { uVAnimation.BuildFromFile(EanPath, EanIndex, UVTime, texture); OriLowerLeftUV = uVAnimation.frames[0]; OriUVDimensions = uVAnimation.UVDimensions[0]; } else if (UVType == 1) { float num = texture.width / Cols; float num2 = texture.height / Rows; Vector2 vector = new Vector2(num / (float)texture.width, num2 / (float)texture.height); Vector2 vector2 = new Vector2(0f, 1f); uVAnimation.BuildUVAnim(vector2, vector, Cols, Rows, Cols * Rows); OriLowerLeftUV = vector2; OriUVDimensions = vector; OriUVDimensions.y = 0f - OriUVDimensions.y; } if (uVAnimation.frames.Length == 1) { OriLowerLeftUV = uVAnimation.frames[0]; OriUVDimensions = uVAnimation.UVDimensions[0]; } else { uVAnimation.loopCycles = LoopCircles; Affector value = new UVAffector(uVAnimation, UVTime, node); arrayList.Add(value); } } if (RotAffectorEnable && RotateType != 0) { Affector value2 = (RotateType != RSTYPE.CURVE) ? new RotateAffector(DeltaRot, node) : new RotateAffector(RotateCurve, node); arrayList.Add(value2); } if (ScaleAffectorEnable && ScaleType != 0) { Affector value3 = (ScaleType != RSTYPE.CURVE) ? new ScaleAffector(DeltaScaleX, DeltaScaleY, node) : new ScaleAffector(ScaleXCurve, ScaleYCurve, node); arrayList.Add(value3); } if (ColorAffectorEnable && ColorAffectType != 0) { ColorAffector value4 = (ColorAffectType != 2) ? new ColorAffector(new Color[2] { Color1, Color2 }, ColorGradualTimeLength, ColorGradualType, node) : new ColorAffector(new Color[4] { Color1, Color2, Color3, Color4 }, ColorGradualTimeLength, ColorGradualType, node); arrayList.Add(value4); } if (LinearForceAffectorEnable) { Affector value5 = new LinearForceAffector(LinearForce.normalized * LinearMagnitude, node); arrayList.Add(value5); } if (JetAffectorEnable) { Affector value6 = new JetAffector(JetMin, JetMax, node); arrayList.Add(value6); } if (VortexAffectorEnable) { Affector value7 = (!UseVortexCurve) ? new VortexAffector(VortexMag, VortexDirection, node) : new VortexAffector(VortexCurve, VortexDirection, node); arrayList.Add(value7); } if (AttractionAffectorEnable) { Affector value8 = (!UseVortexCurve) ? new AttractionForceAffector(AttractMag, AttractionPosition, node) : new AttractionForceAffector(AttractionCurve, AttractionPosition, node); arrayList.Add(value8); } return(arrayList); }