コード例 #1
0
ファイル: HUD.cs プロジェクト: jnguyen4103/CSE-3902-Project
        public void Draw()
        {
            Vector2 loc = new Vector2(Game.Camera.Position.X / Game.ScreenScale, (Game.Camera.Position.Y - 176 * Game.ScreenScale) / Game.ScreenScale);

            MainHUD.UpdatePosition(loc);
            MainHUD.DrawSprite();

            miniMapPosition = new Vector2(Game.Camera.Position.X / Game.ScreenScale + 16, ((Game.Camera.Position.Y - Game.ScreenScale * 176f) / Game.ScreenScale) + 192);
            miniMap.UpdatePosition(miniMapPosition);
            miniMap.DrawSprite();


            WeaponA.UpdatePosition(new Vector2(loc.X + 152f, loc.Y + 208f));
            WeaponA.DrawSprite();

            LevelNumber.UpdatePosition(new Vector2(miniMapPosition.X + 48, miniMapPosition.Y - 8));
            LevelNumber.DrawSprite();

            // Item Draw and Update loop
            for (int i = 0; i < Rupees.Length; i++)
            {
                Rupees[i].UpdatePosition(new Vector2(loc.X + 104 + 8 * i, loc.Y + 200));
                Keys[i].UpdatePosition(new Vector2(loc.X + 104 + 8 * i, loc.Y + 216));
                Bombs[i].UpdatePosition(new Vector2(loc.X + 104 + 8 * i, loc.Y + 224));
                Rupees[i].DrawSprite();
                Keys[i].DrawSprite();
                Bombs[i].DrawSprite();
            }

            // Health Draw and Update loop
            for (int i = 0; i < LifeBar.Length; i++)
            {
                if (i < 8)
                {
                    LifeBar[i].UpdatePosition(new Vector2(loc.X + 176 + 8 * i, loc.Y + 216));
                    CurrentLife[i].UpdatePosition(new Vector2(loc.X + 176 + 8 * i, loc.Y + 216));
                }
                else
                {
                    LifeBar[i].UpdatePosition(new Vector2(loc.X + 176 + 8 * (i - 8), loc.Y + 224));
                    CurrentLife[i].UpdatePosition(new Vector2(loc.X + 176 + 8 * (i - 8), loc.Y + 224));
                }
                LifeBar[i].DrawSprite();
                if (!LifeBar[i].Colour.Equals(Color.Black))
                {
                    CurrentLife[i].DrawSprite();
                }
            }

            linkRoomLocation = int.Parse(Game.CurrDungeon.ActiveRoom.Name.Substring(Game.CurrDungeon.ActiveRoom.Name.Length - 1)) - 1;
            if (linkRoomLocation >= 0)
            {
                LinkLocationIndicator.UpdatePosition(new Vector2(miniMapPosition.X + miniMapRoomPositions[linkRoomLocation].X, miniMapPosition.Y + (miniMapRoomPositions[linkRoomLocation].Y - miniMapYOffset)));
                LinkLocationIndicator.Colour = Color.White;
                LinkLocationIndicator.DrawSprite();
            }
        }
コード例 #2
0
        public void Draw()
        {
            initialCameraPosition = Game.Camera.Position;
            Vector2 location = new Vector2(initialCameraPosition.X / Game.ScreenScale, (initialCameraPosition.Y - offset) / Game.ScreenScale);

            MainInventory.UpdatePosition(location);
            MainInventory.DrawSprite();

            MiniMap.UpdatePosition(new Vector2((initialCameraPosition.X + miniMapOffsetX) / Game.ScreenScale, ((initialCameraPosition.Y + (miniMapOffsetY * Game.ScreenScale)) / Game.ScreenScale)));
            MiniMap.DrawSprite();
            MiniMap.Colour = Color.White;

            UpdateInventoryCounters();

            LevelNumber.UpdatePosition(new Vector2(location.X + 64, location.Y + 184));
            LevelNumber.DrawSprite();

            // Item Draw and Update loop
            for (int i = 0; i < Rupees.Length; i++)
            {
                Rupees[i].UpdatePosition(new Vector2(location.X + 104 + 8 * i, location.Y + 200));
                Keys[i].UpdatePosition(new Vector2(location.X + 104 + 8 * i, location.Y + 216));
                Bombs[i].UpdatePosition(new Vector2(location.X + 104 + 8 * i, location.Y + 224));
                Rupees[i].DrawSprite();
                Keys[i].DrawSprite();
                Bombs[i].DrawSprite();
            }

            // Health Draw and Update loop
            for (int i = 0; i < LifeBar.Length; i++)
            {
                if (i < 8)
                {
                    LifeBar[i].UpdatePosition(new Vector2(location.X + 176 + 8 * i, location.Y + 216));
                    CurrentLife[i].UpdatePosition(new Vector2(location.X + 176 + 8 * i, location.Y + 216));
                }
                else
                {
                    LifeBar[i].UpdatePosition(new Vector2(location.X + 176 + 8 * (i - 8), location.Y + 224));
                    CurrentLife[i].UpdatePosition(new Vector2(location.X + 176 + 8 * (i - 8), location.Y + 224));
                }
                LifeBar[i].DrawSprite();
                if (!LifeBar[i].Colour.Equals(Color.Black))
                {
                    CurrentLife[i].DrawSprite();
                }
            }

            // Inventory Map Draw and Update loop
            for (int i = 0; i < Game.roomsExplored.Length; i++)
            {
                mainMapRoomOffset = MapRoomPositions[i];
                updatedMapRoomPos = new Vector2((initialCameraPosition.X + (mainMapRoomOffset.X * Game.ScreenScale)) / Game.ScreenScale, (initialCameraPosition.Y + (mainMapRoomOffset.Y * Game.ScreenScale)) / Game.ScreenScale);
                MapRooms[i].UpdatePosition(updatedMapRoomPos);
                MapRooms[i].Colour = Color.White;

                if (Game.roomsExplored[i] == 1)
                {
                    MapRooms[i].DrawSprite();
                }
            }
            linkRoomLocation = int.Parse(Game.CurrDungeon.ActiveRoom.Name.Substring(Game.CurrDungeon.ActiveRoom.Name.Length - 1));
            if (linkRoomLocation == 0)
            {
                linkRoomLocation = -1;
            }
            if (linkRoomLocation == 17)
            {
                linkRoomLocation = 0;
            }
            if (linkRoomLocation >= 0)
            {
                LinkLocationIndicator.UpdatePosition(new Vector2(MapRooms[linkRoomLocation].Position.X + linkLocationIndicatorOffsetFromMapRoom, MapRooms[linkRoomLocation].Position.Y + linkLocationIndicatorOffsetFromMapRoom));
                LinkLocationIndicator.Colour = Color.White;
                LinkLocationIndicator.DrawSprite();
            }
        }