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 UpdateVisual() { int f = Mathf.FloorToInt((_hp / _maxHP) * (float)_actor.TotalFrames) + 1; f = (f <= 0) ? 1 : (f > _actor.TotalFrames) ? _actor.TotalFrames : f; _sprite.enabled = (f == _actor.TotalFrames) ? false : true; _actor.GotoAndStop(f); }
private void Update() { if (_isActive) { // Showing the time to next spawn. var p = _currentInterval / spawnInterval; _actor.GotoAndStop(Mathf.RoundToInt(p * _actor.TotalFrames)); // Spawn new item. _currentInterval += Time.deltaTime; if (_currentInterval >= spawnInterval) { _currentInterval = 0.0f; SpawnTank(); } } }
private void UpdateVisual() { if (_hasGun) { _actor.SwitchAnimation("GunTower"); _actor.GotoAndStop(_ammoCount + 1); } else if (_hasBomb) { _actor.SwitchAnimation("BombTower"); _actor.GotoAndStop(1); } else if (!_hasGun && !_hasBomb) { _actor.SwitchAnimation("None"); _actor.GotoAndStop(1); } }
private void UpdateVisual() { var percent = _tank.Health / _tank.maxHealth; var frame = Mathf.RoundToInt(_actor.TotalFrames * percent) + 1; frame = (frame > _actor.TotalFrames) ? _actor.TotalFrames : frame; _actor.GotoAndStop(frame); _sprite.enabled = (frame != _actor.TotalFrames); }
private void Awake() { _t = GetComponent <Transform>(); _actor = GetComponent <AntActor>(); _actor.GotoAndStop(1); }