refreshLootCreatures() public static method

public static refreshLootCreatures ( Hunt h ) : List
h Hunt
return List
コード例 #1
0
        private void refreshHuntImages(Hunt h)
        {
            int   spacing       = 4;
            int   totalWidth    = spacing + spacing;
            int   maxHeight     = -1;
            float magnification = 1.0f;
            List <TibiaObject> creatureObjects = HuntManager.refreshLootCreatures(h);

            foreach (TibiaObject obj in creatureObjects)
            {
                Creature cc = obj as Creature;
                totalWidth += cc.image.Width + spacing;
                maxHeight   = Math.Max(maxHeight, cc.image.Height);
            }

            if (totalWidth < creatureImagePanel.Width)
            {
                // fits on one line
                magnification = ((float)creatureImagePanel.Width) / totalWidth;
                //also consider the height
                float maxMagnification = ((float)creatureImagePanel.Height) / maxHeight;
                if (magnification > maxMagnification)
                {
                    magnification = maxMagnification;
                }
            }
            else if (totalWidth < creatureImagePanel.Width * 2)
            {
                // make it fit on two lines
                magnification = (creatureImagePanel.Width * 1.7f) / totalWidth;
                //also consider the height
                float maxMagnification = creatureImagePanel.Height / (maxHeight * 2.0f);
                if (magnification > maxMagnification)
                {
                    magnification = maxMagnification;
                }
            }
            else
            {
                // make it fit on three lines
                magnification = (creatureImagePanel.Width * 2.7f) / totalWidth;
                //also consider the height
                float maxMagnification = creatureImagePanel.Height / (maxHeight * 3.0f);
                if (magnification > maxMagnification)
                {
                    magnification = maxMagnification;
                }
            }
            creatureImagePanel.Controls.Clear();
            UIManager.DisplayCreatureList(creatureImagePanel.Controls, creatureObjects, 0, 0, creatureImagePanel.Width, spacing, null, magnification);
        }