public void Reset(AntEmitter aEmitter) { _curColor = Preset.colour.startColor; _endColor = Preset.colour.endColor; _gradient = Preset.colour.gradient; _curve = Preset.colour.curveColor; _useChild = Preset.colour.useChildSprite; _gradientColor = Preset.colour.gradientColor; IsActive = (Preset.colour.animateColor || Preset.colour.gradientColor); if (Preset.colour.effectLifeTime) { _delta = _particle.Effect.Duration / _particle.Effect.TotalDuration; _delta = AntMath.TrimToRange(_delta, 0.0f, 1.0f); _curColor.r = AntMath.Lerp(_curColor.r, _endColor.r, _curve.Evaluate(_delta)); _curColor.g = AntMath.Lerp(_curColor.g, _endColor.g, _curve.Evaluate(_delta)); _curColor.b = AntMath.Lerp(_curColor.b, _endColor.b, _curve.Evaluate(_delta)); _curColor.a = AntMath.Lerp(_curColor.a, _endColor.a, _curve.Evaluate(_delta)); } if (_useChild) { _childSprite.color = _curColor; } else { _sprite.color = _curColor; } }
public void Reset(AntEmitter aEmitter) { IsActive = true; _preset = Preset.trail; _startTime = _preset.startTime + AntMath.RandomRangeFloat(_preset.rndToStartTime); _trail.widthMultiplier = _preset.startWidth + AntMath.RandomRangeFloat(_preset.rndToStartWidth); _trail.widthCurve = _preset.widthCurve; _trail.colorGradient = _preset.gradient; _trail.Clear(); _needToInit = true; }
public void Reset(AntEmitter aEmitter) { _duration = Preset.lifeTime.duration; _duration += AntMath.RandomRangeFloat(Preset.lifeTime.rndToDuration); if (_duration <= 0.0f) { _duration = 0.1f; } _particle.LifeTime = _duration; IsActive = true; }
public void Reset(AntEmitter aEmitter) { var center = _transform.position; var spawn = Preset.position; center.x = spawn.position.x + AntMath.RandomRangeFloat(spawn.rndToPositionX); center.y = spawn.position.y + AntMath.RandomRangeFloat(spawn.rndToPositionY); float lowerAngle = spawn.initialAngle + spawn.lowerAngle; float upperAngle = spawn.initialAngle + spawn.upperAngle; if (spawn.inheritRotation) { center = AntMath.RotatePointDeg(center, Vector2.zero, _particle.Effect.Angle); lowerAngle += _particle.Effect.Angle; upperAngle += _particle.Effect.Angle; } center.x += _particle.Effect.Position.x; center.y += _particle.Effect.Position.y; var pos = Vector2.zero; float curAngle; float dist = spawn.distance + AntMath.RandomRangeFloat(spawn.rndToDistance); if (spawn.strongOrder && spawn.countParticles > 0) { aEmitter.SpawnCount++; float step = Mathf.DeltaAngle(lowerAngle, upperAngle) / (spawn.countParticles - 1); curAngle = (lowerAngle + (step * aEmitter.SpawnCount)) * AntMath.RADIANS; pos.x = center.x + dist * Mathf.Cos(curAngle); pos.y = center.y + dist * Mathf.Sin(curAngle); if (aEmitter.SpawnCount >= spawn.countParticles) { aEmitter.SpawnCount = 0; } } else { curAngle = AntMath.RandomRangeFloat(lowerAngle, upperAngle) * AntMath.RADIANS; pos.x = center.x + dist * Mathf.Cos(curAngle); pos.y = center.y + dist * Mathf.Sin(curAngle); } if (spawn.rotate) { Angle = curAngle * AntMath.DEGREES; } _transform.position = pos; IsActive = false; // Выкл. обработку компонента. }
public void Reset(AntEmitter aEmitter) { IsActive = true; _movement = Preset.movement; _speed = _movement.speed + AntMath.RandomRangeFloat(_movement.rndToSpeed); _startSpeed = _speed; _endSpeed = _movement.endSpeed; _angle = Angle * AntMath.RADIANS; _velocity.x = _speed * Mathf.Cos(_angle); _velocity.y = _speed * Mathf.Sin(_angle); }
public void Activate(AntEffect aEffect, AntEmitter aEmitter) { Effect = aEffect; CurrentLifeTime = 0.0f; IsActive = true; for (int i = 0; i < _componentsCount; i++) { _components[i].Preset = aEmitter.components[i].Preset; if (aEmitter.components[i].IsExists) { _components[i].Reset(aEmitter); } } }
public void Reset(AntEmitter aEmitter) { _sprite = (Preset.actor.useChildActor) ? _particle.GameObject.GetComponentInChildren <SpriteRenderer>() : _particle.GameObject.GetComponent <SpriteRenderer>(); _actor = (Preset.actor.useChildActor) ? _particle.GameObject.GetComponentInChildren <AntActor>() : _particle.GameObject.GetComponent <AntActor>(); _actor.timeScale = Preset.actor.timeScale + AntMath.RandomRangeFloat(Preset.actor.rndToTimeScale); _sprite.flipX = (Preset.actor.rndFlipX) ? (AntMath.RandomRangeInt(0, 1) == 1) : Preset.actor.flipX; _sprite.flipY = (Preset.actor.rndFlipY) ? (AntMath.RandomRangeInt(0, 1) == 1) : Preset.actor.flipY; _actor.reverse = Preset.actor.reverse; _actor.loop = Preset.actor.loop; _actor.loopDelay = Preset.actor.loopDelay + AntMath.RandomRangeFloat(Preset.actor.rndToLoopDelay); if (Preset.actor.playAnimation) { if (Preset.actor.selectRandomFrame) { _actor.PlayRandomFrame(); } else { _actor.GotoAndPlay(Preset.actor.startFrame); } } else { if (Preset.actor.selectRandomFrame) { _actor.GotoAndStop(AntMath.RandomRangeInt(1, _actor.TotalFrames)); } else { _actor.GotoAndStop(Preset.actor.startFrame); } } IsActive = false; // Выкл. обработку компонента. }
public void Reset(AntEmitter aEmitter) { if (_isResetted) { return; } _isResetted = true; _preset = Preset.burst; IsActive = (_preset.list.Length > 0); _currentIndex = 0; _count = 0; if (IsActive) { _delay = _preset.list[_currentIndex].time; } }
protected override void Initialize() { // Инициализация эммитеров. _emitters = new AntEmitter[emitters.Length]; for (int i = 0, n = _emitters.Length; i < n; i++) { A.Assert(emitters[i] == null, "AntEmitter `{0}` has missed preset.", gameObject.name); _emitters[i] = new AntEmitter(emitters[i]); } if (isAutoReturnToPool) { EventComplete += PlaceToPoolHandler; } EventExtractedFromPool += ExtractedFromPoolHandler; }
private void Emission(AntEmitter aEmitter) { IParticle particle; for (int i = 0, n = aEmitter.emissionList.Count; i < n; i++) { particle = aEmitter.emissionList[i].GetObject <IParticle>(); particle.Activate(this, aEmitter); particle.EffectID = aEmitter.ID; particle.BirthTime = _duration; if (aEmitter.IsAllowSorting) { AddParticle(particle); } } aEmitter.emissionList.Clear(); UpdateSorting(aEmitter); }
public void Reset(AntEmitter aEmitter) { IsActive = (Preset.rotation.enableRotation || Preset.rotation.animateAngle); _startAngle = Preset.rotation.startAngle + AntMath.RandomRangeFloat(Preset.rotation.rndToAngle); _endAngle = Preset.rotation.endAngle; _angularSpeed = Preset.rotation.angularSpeed + AntMath.RandomRangeFloat(Preset.rotation.rndToAngularSpeed); _enableRotation = Preset.rotation.enableRotation; _animateAngle = Preset.rotation.animateAngle; _accel = Preset.rotation.accel; _drag = Preset.rotation.drag; _curve = Preset.rotation.curveAngle; if (Preset.rotation.inheritRotation) { _startAngle += _particle.Effect.Angle; _endAngle += _particle.Effect.Angle; } Angle = _startAngle; }
public void Reset(AntEmitter aEmitter) { IsActive = Preset.scale.animateScale; _endScale = Preset.scale.endScale; _startScale = Vector2.zero; _startScale.x = Preset.scale.startScale.x + AntMath.RandomRangeFloat(Preset.scale.rndToScaleX); _startScale.y = Preset.scale.startScale.y + AntMath.RandomRangeFloat(Preset.scale.rndToScaleY); _curveX = Preset.scale.scaleCurveX; _curveY = Preset.scale.scaleCurveY; _useChild = Preset.scale.useChildSprite; _proportional = Preset.scale.proportional; if (Preset.scale.effectLifeTime && !AntMath.Equal(_particle.Effect.lifeTime, 0.0f)) { _delta = _particle.Effect.Duration / _particle.Effect.TotalDuration; _delta = AntMath.TrimToRange(_delta, 0.0f, 1.0f); _startScale.x = AntMath.Lerp(_startScale.x, Preset.scale.endScale.x, _curveX.Evaluate(_delta)); _startScale.y = AntMath.Lerp(_startScale.y, Preset.scale.endScale.y, _curveY.Evaluate(_delta)); } if (Preset.scale.useChildSprite) { _childTransform.localScale = new Vector3( _startScale.x, (Preset.scale.proportional) ? _startScale.x : _startScale.y, 1.0f ); } else { _transform.localScale = new Vector3( _startScale.x, (Preset.scale.proportional) ? _startScale.x : _startScale.y, 1.0f ); } }
private void UpdateSorting(AntEmitter aEmitter) { if (!aEmitter.IsAllowSorting) { return; } IParticle particle; var actor = aEmitter.Actor.Preset.actor; switch (actor.sortingMode) { case ESortingMode.None: for (int i = 0, n = _particles.Count; i < n; i++) { particle = _particles[i]; if (particle != null) { if (particle.IsActive) { if (particle != null && particle.EffectID == aEmitter.ID) { particle.SortingLayer = actor.sortingLayer; particle.SortingOrder = actor.sortingOrder; } } else { _particles[i] = null; } } } break; case ESortingMode.OldestInFront: case ESortingMode.YoungestInFront: _sorter.Clear(); for (int i = 0, n = _particles.Count; i < n; i++) { particle = _particles[i]; if (particle != null) { if (particle.IsActive) { if (particle.EffectID == aEmitter.ID) { _sorter.Add(particle, particle.BirthTime); } } else { _particles[i] = null; } } } _sorter.Sort((actor.sortingMode == ESortingMode.OldestInFront) ? AntSorterOrder.DESC : AntSorterOrder.ASC ); for (int i = 0, n = _sorter.Count; i < n; i++) { _sorter[i].SortingLayer = actor.sortingLayer; _sorter[i].SortingOrder = actor.sortingOrder + i; } break; } }
public void Reset(AntEmitter aEmitter) { _prevIndex = -1; IsActive = false; // Выкл. обработку компонента. }
public void Reset(AntEmitter aEmitter) { IsActive = true; _preset = Preset.emission; _spawnInterval = _preset.spawnInterval + AntMath.RandomRangeFloat(_preset.rndToSpawnInterval); }