isTrue() 개인적인 메소드

private isTrue ( bool condition ) : void
condition bool
리턴 void
예제 #1
0
파일: Batcher.cs 프로젝트: Sabathorn/Nez
        public Batcher(GraphicsDevice graphicsDevice)
        {
            Assert.isTrue(graphicsDevice != null);

            this.graphicsDevice = graphicsDevice;

            _vertexInfo   = new VertexPositionColorTexture4[MAX_SPRITES];
            _textureInfo  = new Texture2D[MAX_SPRITES];
            _vertexBuffer = new DynamicVertexBuffer(graphicsDevice, typeof(VertexPositionColorTexture), MAX_VERTICES, BufferUsage.WriteOnly);
            _indexBuffer  = new IndexBuffer(graphicsDevice, IndexElementSize.SixteenBits, MAX_INDICES, BufferUsage.WriteOnly);
            _indexBuffer.SetData(_indexData);

            _spriteEffect     = new SpriteEffect();
            _spriteEffectPass = _spriteEffect.CurrentTechnique.Passes[0];

            _projectionMatrix = new Matrix(
                0f,                 //(float)( 2.0 / (double)viewport.Width ) is the actual value we will use
                0.0f,
                0.0f,
                0.0f,
                0.0f,
                0f,                 //(float)( -2.0 / (double)viewport.Height ) is the actual value we will use
                0.0f,
                0.0f,
                0.0f,
                0.0f,
                1.0f,
                0.0f,
                -1.0f,
                1.0f,
                0.0f,
                1.0f
                );
        }
예제 #2
0
        public void addVertex(Vector2 vertex, Color color, PrimitiveType primitiveType)
        {
            Assert.isTrue(_hasBegun, "Invalid state. Begin must be called before AddVertex can be called.");
            Assert.isFalse(
                primitiveType == PrimitiveType.LineStrip || primitiveType == PrimitiveType.TriangleStrip,
                "The specified primitiveType is not supported by PrimitiveBatch");

            if (primitiveType == PrimitiveType.TriangleList)
            {
                if (_triangleVertsCount >= _triangleVertices.Length)
                {
                    flushTriangles();
                }

                _triangleVertices[_triangleVertsCount].Position = new Vector3(vertex, 0);
                _triangleVertices[_triangleVertsCount].Color    = color;
                _triangleVertsCount++;
            }

            if (primitiveType == PrimitiveType.LineList)
            {
                if (_lineVertsCount >= _lineVertices.Length)
                {
                    flushLines();
                }

                _lineVertices[_lineVertsCount].Position = new Vector3(vertex, 0);
                _lineVertices[_lineVertsCount].Color    = color;
                _lineVertsCount++;
            }
        }
예제 #3
0
 /// <summary>
 /// sets the triangle indices for rendering
 /// </summary>
 /// <returns>The triangles.</returns>
 /// <param name="triangles">Triangles.</param>
 public Mesh setTriangles(int[] triangles)
 {
     Assert.isTrue(triangles.Length % 3 == 0, "triangles must be a multiple of 3");
     _primitiveCount = triangles.Length / 3;
     _triangles      = triangles;
     return(this);
 }
예제 #4
0
 /// <summary>
 /// Change the rendering primitive type.
 /// If it is PrimitiveType.TriangleStrip then you don't need to setTriangles.
 /// </summary>
 /// <param name="primitiveType">The ordering of the verticies.</param>
 /// <returns>The mesh.</returns>
 public Mesh setPrimitiveType(PrimitiveType primitiveType)
 {
     Assert.isTrue(
         primitiveType == PrimitiveType.TriangleList || primitiveType == PrimitiveType.TriangleStrip,
         "Only triangles are supported.");
     _primitiveType = primitiveType;
     return(this);
 }
예제 #5
0
        /// <summary>
        /// removes the item at the given index from the list but does NOT maintain list order
        /// </summary>
        /// <param name="index">Index.</param>
        public void removeAtWithSwap(int index)
        {
            Assert.isTrue(index < length, "Index out of range!");

            buffer[index]      = buffer[length - 1];
            buffer[length - 1] = default(T);
            --length;
        }
예제 #6
0
 /// <summary>
 /// removes a SceneComponent from the SceneComponents list
 /// </summary>
 public void removeSceneComponent(SceneComponent component)
 {
     Assert.isTrue(
         _sceneComponents.contains(component),
         "SceneComponent {0} is not in the SceneComponents list!",
         component);
     _sceneComponents.remove(component);
     component.onRemovedFromScene();
 }
예제 #7
0
        /// <summary>
        /// removes the item at the given index from the list
        /// </summary>
        public void removeAt(int index)
        {
            Assert.isTrue(index < length, "Index out of range!");

            length--;
            if (index < length)
            {
                Array.Copy(buffer, index + 1, buffer, index, length - index);
            }
            buffer[length] = default(T);
        }
예제 #8
0
        /// <summary>
        /// maximum non-scaled value (0 - float.Max) that the camera zoom can be. Defaults to 3
        /// </summary>
        /// <returns>The maximum zoom.</returns>
        /// <param name="maxZoom">Max zoom.</param>
        public Camera setMaximumZoom(float maxZoom)
        {
            Assert.isTrue(maxZoom > 0, "MaximumZoom must be greater than zero");

            if (_zoom > maxZoom)
            {
                _zoom = maxZoom;
            }

            _maximumZoom = maxZoom;
            return(this);
        }
예제 #9
0
        public StateKitLite()
        {
            Assert.isTrue(typeof(TEnum).IsEnum, "[StateKitLite] TEnum generic constraint failed! You must use an enum when declaring your subclass!");

            // cache all of our state methods
            var enumValues = (TEnum[])Enum.GetValues(typeof(TEnum));

            foreach (var e in enumValues)
            {
                configureAndCacheState(e);
            }
        }
예제 #10
0
        /// <summary>
        /// minimum non-scaled value (0 - float.Max) that the camera zoom can be. Defaults to 0.3
        /// </summary>
        /// <returns>The minimum zoom.</returns>
        /// <param name="value">Value.</param>
        public Camera setMinimumZoom(float minZoom)
        {
            Assert.isTrue(minZoom > 0, "minimumZoom must be greater than zero");

            if (_zoom < minZoom)
            {
                _zoom = minimumZoom;
            }

            _minimumZoom = minZoom;
            return(this);
        }
예제 #11
0
파일: Batcher.cs 프로젝트: Sabathorn/Nez
        public void end()
        {
            Assert.isTrue(_beginCalled, "End was called, but Begin has not yet been called. You must call Begin successfully before you can call End.");
            _beginCalled = false;

            if (!_disableBatching)
            {
                flushBatch();
            }

            _customEffect = null;
        }
예제 #12
0
        public override void render()
        {
            var text = getValue <string>();

            Assert.isTrue(text.Length < 1024);

            var len = System.Text.Encoding.UTF8.GetBytes(text, 0, text.Length, _textInputBuffer, 0);

            ImGui.InputText(_name, _textInputBuffer, (uint)_textInputBuffer.Length, InputTextFlags.Default, null);

            text = System.Text.Encoding.UTF8.GetString(_textInputBuffer, 0, len);
            setValue(text);
        }
예제 #13
0
        public override void onAddedToEntity()
        {
            if (_colliderRequiresAutoSizing)
            {
                // we only deal with boxes and circles here
                Assert.isTrue(
                    this is BoxCollider || this is CircleCollider,
                    "Only box and circle colliders can be created automatically");

                var renderable = entity.getComponent <RenderableComponent>();
                Debug.warnIf(
                    renderable == null,
                    "Collider has no shape and no RenderableComponent. Can't figure out how to size it.");
                if (renderable != null)
                {
                    var renderableBounds = renderable.bounds;

                    // we need the size * inverse scale here because when we autosize the Collider it needs to be without a scaled Renderable
                    var width  = renderableBounds.width / entity.transform.scale.X;
                    var height = renderableBounds.height / entity.transform.scale.Y;

                    // circle colliders need special care with the origin
                    if (this is CircleCollider)
                    {
                        var circleCollider = this as CircleCollider;
                        circleCollider.radius = Math.Max(width, height) * 0.5f;

                        // fetch the Renderable's center, transfer it to local coordinates and use that as the localOffset of our collider
                        localOffset = renderableBounds.center - entity.transform.position;
                    }
                    else
                    {
                        var boxCollider = this as BoxCollider;
                        boxCollider.width  = width;
                        boxCollider.height = height;

                        // fetch the Renderable's center, transfer it to local coordinates and use that as the localOffset of our collider
                        localOffset = renderableBounds.center - entity.transform.position;
                    }
                }
            }

            _isParentEntityAddedToScene = true;
            registerColliderWithPhysicsSystem();
        }
예제 #14
0
        /// <summary>
        /// direct access to setting vert positions, UVs and colors. The order of elements is top-left, top-right, bottom-left, bottom-right
        /// </summary>
        /// <returns>The raw.</returns>
        /// <param name="texture">Texture.</param>
        /// <param name="verts">Verts.</param>
        /// <param name="textureCoords">Texture coords.</param>
        /// <param name="colors">Colors.</param>
        public void drawRaw(Texture2D texture, Vector3[] verts, Vector2[] textureCoords, Color[] colors)
        {
            Assert.isTrue(verts.Length == 4, "there must be only 4 verts");
            Assert.isTrue(textureCoords.Length == 4, "there must be only 4 texture coordinates");
            Assert.isTrue(colors.Length == 4, "there must be only 4 colors");

            // we're out of space, flush
            if (_numSprites >= MAX_SPRITES)
            {
                flushBatch();
            }

            _vertexInfo[_numSprites].position0 = verts[0];
            _vertexInfo[_numSprites].position1 = verts[1];
            _vertexInfo[_numSprites].position2 = verts[2];
            _vertexInfo[_numSprites].position3 = verts[3];

            _vertexInfo[_numSprites].textureCoordinate0 = textureCoords[0];
            _vertexInfo[_numSprites].textureCoordinate1 = textureCoords[1];
            _vertexInfo[_numSprites].textureCoordinate2 = textureCoords[2];
            _vertexInfo[_numSprites].textureCoordinate3 = textureCoords[3];

            _vertexInfo[_numSprites].color0 = colors[0];
            _vertexInfo[_numSprites].color1 = colors[1];
            _vertexInfo[_numSprites].color2 = colors[2];
            _vertexInfo[_numSprites].color3 = colors[3];

            if (_disableBatching)
            {
                _vertexBuffer.SetData(
                    0,
                    _vertexInfo,
                    0,
                    1,
                    VertexPositionColorTexture4.realStride,
                    SetDataOptions.None);
                drawPrimitives(texture, 0, 1);
            }
            else
            {
                _textureInfo[_numSprites] = texture;
                _numSprites += 1;
            }
        }
예제 #15
0
파일: Collider.cs 프로젝트: Pyxlre/Nez
        /// <summary>
        /// Called when the parent entity is added to a scene
        /// </summary>
        public virtual void onEntityAddedToScene()
        {
            if (shape == null)
            {
                // we only deal with boxes and circles here
                Assert.isTrue(this is BoxCollider || this is CircleCollider, "Only box and circle colliders can be created automatically");

                var renderable = entity.getComponent <RenderableComponent>();
                Debug.warnIf(renderable == null, "Collider has no shape and no RenderableComponent. Can't figure out how to size it.");
                if (renderable != null)
                {
                    var renderableBounds = renderable.bounds;

                    var width  = renderableBounds.width;
                    var height = renderableBounds.height;

                    // circle colliders need special care with the origin
                    if (this is CircleCollider)
                    {
                        var circle = this as CircleCollider;
                        circle.shape  = new Circle(width * 0.5f);
                        circle.radius = width * 0.5f;

                        // fetch the Renderable's center, transfer it to local coordinates and use that as the origin of our collider
                        var localCenter = renderableBounds.center - entity.transform.position;
                        origin = localCenter;
                    }
                    else
                    {
                        var box = this as BoxCollider;
                        box.shape        = new Box(width, height);
                        box.width        = width;
                        box.height       = height;
                        originNormalized = renderable.originNormalized;
                    }

                    shape.position = entity.transform.position;
                }
            }
            _isParentEntityAddedToScene = true;
            registerColliderWithPhysicsSystem();
        }
예제 #16
0
 /// <summary>
 /// removes the Collider and unregisters it from the Pysics system
 /// </summary>
 /// <param name="collider">Collider.</param>
 public void remove(Collider collider)
 {
     Assert.isTrue(_colliders.Contains(collider), "Collider {0} is not in the ColliderList", collider);
     removeAt(_colliders.IndexOf(collider));
 }
예제 #17
0
 /// <summary>
 /// sets the number of degrees between each subdivision for use with EndCapType.Smooth
 /// </summary>
 /// <returns>The per subdivision.</returns>
 /// <param name="degreesPerSubdivision">Degrees per subdivision.</param>
 public LineRenderer setDegreesPerSubdivision(float degreesPerSubdivision)
 {
     Assert.isTrue(degreesPerSubdivision > 0, "degreesPerSubdivision must be greater than 0");
     this.degreesPerSubdivision = degreesPerSubdivision;
     return(this);
 }