Пример #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
        protected override void LoadContent()
        {
            this.camera             = new Camera(GraphicsDeviceManager, GraphicsDevice);
            this.camera.Zoom        = 10;
            this.camera.RenderPivot = RenderPivot.Center;

            var tiledTileSet = new TiledTileset(global::CraftEnd.CoreGame.Content.Content.FilePathTiled0x72DungenTileset, Content);
            var devLevelMap  = new TiledMap(global::CraftEnd.CoreGame.Content.Content.FilePathTiledLevelDev, tiledTileSet);
            var devLevel     = new Level(devLevelMap);

            this.camera.AddEntity(devLevel);

            foreach (var child in devLevel)
            {
                this.camera.AddEntity(child);
            }

            var dungeonTileSet0x72Loader = new DungenonTilesetII0x72Loader();

            dungeonTileSet0x72Loader.LoadContent(Content);

            this.player = new Player(
                dungeonTileSet0x72Loader,
                Content.Load <Texture2D>(global::CraftEnd.CoreGame.Content.Content.Texture2DCharacterShadow));
            this.player.Position = new Vector3(2, 2, 0);
            this.camera.AddEntity(this.player);

            var guiCamera = new Camera(GraphicsDeviceManager, GraphicsDevice);

            guiCamera.Zoom = 8;

            var uiLife = new Life(dungeonTileSet0x72Loader);

            guiCamera.AddEntity(uiLife);
            uiLife.NumberOfHearts = 5;
            uiLife.Position       = new Vector3(0.1f, 0, 0);

            var inventory = new Inventory(Content.Load <Texture2D>(global::CraftEnd.CoreGame.Content.Content.Texture2DInventoryTile), 10, 6);

            guiCamera.AddEntity(inventory);

            this.cursor = new Cursor(Content.Load <Texture2D>(global::CraftEnd.CoreGame.Content.Content.Texture2DCursor), guiCamera);
            guiCamera.AddEntity(this.cursor);
        }
Пример #3
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));
        }