Exemplo n.º 1
0
        public SpriteBatch()
        {
            IRenderSystemProvider renderSystem = Engine.Services.GetService <IRenderSystemProvider>();

            _renderer = renderSystem.Renderer;

            _indexBuffer = new IndexBuffer(IndexFormat.SixteenBits, MaxBatchSize * 6, ResourceUsage.Static);

            _vertices     = new VertexPositionColorTexture[MaxBatchSize * 4];
            _vertexBuffer = new VertexBuffer(VertexPositionColorTexture.VertexDeclaration, MaxBatchSize * 4, ResourceUsage.Dynamic);
            _spriteVbPos  = 0;

            _spriteEffect = renderSystem.DefaultContent.Load <Effect>("SpriteEffect.tebo");
            _matrixParam  = _spriteEffect.Parameters["SpriteTransform"];

            _textureComparer     = new TextureComparer(this);
            _frontToBackComparer = new OrthoComparer(this, true);
            _backToFrontComparer = new OrthoComparer(this, false);

            _spriteQueue      = new Sprite[MaxBatchSize];
            _spriteQueueCount = 0;
            _inBeginEnd       = false;
            _sortMode         = SpriteSortMode.Deferred;

            CreateIndexData();
        }
Exemplo n.º 2
0
 private void GradePicture()
 {
     if (drawingPic != null && outlinePic != null)
     {
         Debug.Log("Grading Textures");
         float accuracy = TextureComparer.CompareTexture2Ds(drawingPic.Item2, outlinePic.Item2, TextureComparer.CompareFactor.IfAlpha, 1);
         Debug.Log("Grade : " + accuracy);
         if (accuracy != 0)
         {
             OnPictureGraded?.Invoke(Mathf.FloorToInt((baseReward * accuracy) * (1 + SpeedRewardCurve.Evaluate(timer))));
         }
         else
         {
             OnPictureGraded?.Invoke(0);
         }
         timer      = 0;
         drawingPic = null;
         outlinePic = null;
         controller.ClearStrokes();
     }
 }
Exemplo n.º 3
0
 public void Start(TextureComparer textComparer)
 {
     this.textureComparer = textComparer;
     materialGameObject   = renderer.materials[indexMT];
 }