Пример #1
0
        public Life(DungenonTilesetII0x72Loader content)
        {
            this.spriteRenderer = new SpriteRenderer();
            AddComponent(this.spriteRenderer);

            this.texture = content.Texture;
            this.heartFullSpriteCoordinates  = content.TryGetSpriteCoordinates("ui_heart_full")[0];
            this.heartHalfSpriteCoordinates  = content.TryGetSpriteCoordinates("ui_heart_half")[0];
            this.heartEmptySpriteCoordinates = content.TryGetSpriteCoordinates("ui_heart_empty")[0];
            this.UpdateSpriteRenderer();
        }
Пример #2
0
        public Player(DungenonTilesetII0x72Loader content, Texture2D characterShadow)
        {
            var spriteRenderer = new SpriteRenderer();

            this.AddComponent(spriteRenderer);

            var idleCoord = content.TryGetSpriteCoordinates("knight_m_idle_anim");
            var height    = (float)idleCoord[0].Height;
            var width     = (float)idleCoord[0].Width;

            if (height > width)
            {
                height = height / width;
                width  = 1;
            }
            else if (width > height)
            {
                width  = width / height;
                height = 1;
            }


            this.characterAnimator = new SpriteAnimator(this, new[] {
                new SpriteAnimation("idle", content.Texture, idleCoord),
                new SpriteAnimation("run", content.Texture, content.TryGetSpriteCoordinates("knight_m_run_anim")),
                new SpriteAnimation("hit", content.Texture, content.TryGetSpriteCoordinates("knight_m_hit_anim"))
            }, "idle");
            this.characterAnimator.Scale       = new Vector2(width, height);
            this.characterAnimator.RenderPivot = RenderPivot.BottomCenter;

            var shadowSprite = new SpriteStatic(this, characterShadow, null, new Vector2(0, 0f), RenderPivot.Center);

            spriteRenderer.Sprites.Add(shadowSprite);
            spriteRenderer.Sprites.Add(characterAnimator);

            var collider = new BoxCollider(0, new Vector2(1, 0.4f), new Vector2(-0.5f, -0.4f));

            this.AddComponent(collider);
            this.AddComponent(this.rigidbody = new Rigidbody(collider));
        }