예제 #1
0
 public bool CheckFrameUpdate()
 {
     if (!_playing || _frameTimer.IsActive)
     {
         return(false);
     }
     _currentFrameIndex++;
     if (CurrentFrame != null)
     {
         _frameTimer.StartNewTime(_animation.FrameTime * CurrentFrame.Length);
         return(true);
     }
     if (!_animation.IsComplete(_currentFrameIndex))
     {
         return(true);
     }
     if (_animation.Looping)
     {
         _currentFrameIndex = 0;
         _frameTimer.StartNewTime(_animation.FrameTime * CurrentFrame.Length);
         return(true);
     }
     _playing = false;
     return(false);
 }
예제 #2
0
        private IEnumerator TestAnimationRunner()
        {
            _updateFrame = 0;
            UpdateSprite(_updateFrame);
            UnscaledTimer timer = new UnscaledTimer();

            timer.StartNewTime(_animation.FrameTime * _animation.GetFrame(0).Length);
            while (_looping)
            {
                if (!_looping)
                {
                    break;
                }
                if (timer.IsActive)
                {
                    yield return(null);
                }
                _updateFrame++;
                var frame = _animation.GetFrame(_updateFrame);
                if (frame == null)
                {
                    _updateFrame = 0;
                    frame        = _animation.GetFrame(_updateFrame);
                }
                timer.StartNewTime(_animation.FrameTime * frame.Length);
                UpdateSprite(_updateFrame);
                yield return(null);
            }
        }
예제 #3
0
 public void HideTooltip()
 {
     if (UITooltipReplacer.Current != null)
     {
         UITooltipReplacer.Current.HideTooltip();
         return;
     }
     if (_state != State.Showing)
     {
         return;
     }
     _state = State.WaitingToDisable;
     _waitTimer.StartNewTime(_waitLength);
 }
예제 #4
0
 public static bool Use()
 {
     if (_clickTimeout.IsActive || _main == null)
     {
         return(false);
     }
     _clickTimeout.StartNewTime(_main._clickTimeoutTime);
     if (_main._current != null)
     {
         _main._current.OnControlUse();
         return(true);
     }
     if (AlternativeUse != null)
     {
         AlternativeUse();
         return(true);
     }
     return(false);
 }
예제 #5
0
        private void DrawWithCamera(Camera cam)
        {
            if (!cam)
            {
                return;
            }
            if (_animation == null || _sprite == null)
            {
                return;
            }
            if (_mesh == null)
            {
                _mesh = ProceduralMeshUtility.GenerateQuad(new Vector2(20.48f, 10.24f), new Vector2(0.5f, 0));
            }
            if (_sprite != null)
            {
                DrawSprite();
                return;
            }
            if (!_drawTimer.IsActive)
            {
                _frame++;
                if (_frame >= _animation.Frames.Length)
                {
                    _frame = 0;
                }
                _drawTimer.StartNewTime(_animation.FrameTime * _animation.GetFrame(_frame).Length);
            }
            var sprite   = _animation.GetSprite(_frame);
            var matBlock = new MaterialPropertyBlock();

            matBlock.SetTexture(_shaderPropertyTexture, sprite.texture);
            matBlock.SetTexture(_shaderPropertyNormal, _animation.NormalMap);
            matBlock.SetFloat(_shaderPropertyEmissivePower, _animation.EmissiveMap != null ? 1 : 0);
            if (_animation.EmissiveMap != null)
            {
                matBlock.SetTexture(_shaderPropertyEmissive, _animation.EmissiveMap);
            }
            matBlock.SetColor(_shaderPropertyColor, Color.white);
            matBlock.SetVector(_shaderPropertyUv, SpriteRenderingSystem.GetUv(sprite));
            Graphics.DrawMesh(_mesh, GetMatrix(), _mat, 0, null, 0, matBlock, ShadowCastingMode.On);
        }