Exemple #1
0
        private Rect TexCoordsForEnergyBar(Rect energyBounds)
        {
            var pos = screenPositionReal;
            var s   = sizeReal;

            switch (growDirection)
            {
            case GrowDirection.LeftToRight: {
                return(new Rect(0, 0, (energyBounds.xMax - pos.x) / s.x, 1));
            }

            case GrowDirection.RightToLeft: {
                float x = (energyBounds.xMin - pos.x) / s.x;
                float w = 1 - x;
                return(new Rect(x, 0, w, 1));
            }

            case GrowDirection.BottomToTop: {
                float y = (energyBounds.yMin - pos.y) / (s.y);
                float h = 1 - y;
                return(new Rect(0, 0, 1, h));
            }

            case GrowDirection.TopToBottom: {
                float y = (energyBounds.yMax - pos.y) / s.y;
                return(new Rect(0, 1 - y, 1, y));
            }

            default:
                MadDebug.Assert(false, "Unknown grow direction " + growDirection);
                return(new Rect()); // won't get here
            }
        }
Exemple #2
0
 MadSprite.FillType ToFillType(GrowDirection growDirection) {
     switch (growDirection) {
         case GrowDirection.LeftToRight:
             return MadSprite.FillType.LeftToRight;
         case GrowDirection.RightToLeft:
             return MadSprite.FillType.RightToLeft;
         case GrowDirection.TopToBottom:
             return MadSprite.FillType.TopToBottom;
         case GrowDirection.BottomToTop:
             return MadSprite.FillType.BottomToTop;
         case GrowDirection.ExpandHorizontal:
             return MadSprite.FillType.ExpandHorizontal;
         case GrowDirection.ExpandVertical:
             return MadSprite.FillType.ExpandVertical;
         case GrowDirection.RadialCW:
             return MadSprite.FillType.RadialCW;
         case GrowDirection.RadialCCW:
             return MadSprite.FillType.RadialCCW;
         case GrowDirection.ColorChange:
             return MadSprite.FillType.None;
         default:
             MadDebug.Assert(false, "Unkwnown grow direction: " + growDirection);
             return MadSprite.FillType.None;
     }
 }
Exemple #3
0
        private Color ComputeBarColor()
        {
            Color outColor = Color.white;

            if (growDirection == GrowDirection.ColorChange)
            {
                outColor = spriteBarGradient.Evaluate(energyBar.ValueF);
            }
            else
            {
                switch (spriteBarColorType)
                {
                case ColorType.Solid:
                    outColor = spriteBarColor;
                    break;

                case ColorType.Gradient:
                    outColor = spriteBarGradient.Evaluate(energyBar.ValueF);
                    break;

                default:
                    MadDebug.Assert(false, "Unkwnown option: " + spriteBarColorType);
                    break;
                }
            }

            if (Blink)
            {
                outColor = effectBlinkColor;
            }

            return(ComputeColor(outColor));
        }
        public Texture2D GetTexture(out Rect texCoords)
        {
            switch (method)
            {
            case Method.Grid:
                return(GetTextureGrid(out texCoords));

            case Method.Sequence:
                return(GetTextureSequence(out texCoords));

            default:
                MadDebug.Assert(false, "unknown method: " + method);
                texCoords = new Rect();
                return(null); // won't get here
            }
        }
        public bool IsValid()
        {
            if (energyBar == null)
            {
                return(false);
            }

            switch (method)
            {
            case Method.Grid:
                return(gridWidth > 0 && gridHeight > 0 && gridTexture != null);

            case Method.Sequence:
                return(sequence.Length > 0 && sequence[0] != null);

            default:
                MadDebug.Assert(false, "unknown method: " + method);
                return(false); // won't get here
            }
        }