示例#1
0
    public Rect AnyBackgroundOrForegroundSpriteSize() {
        MadSprite sprite = null;

        if (spriteObjectsBg.Count > 0) {
            sprite = spriteObjectsBg[0];
        }

        if (sprite == null && spriteObjectsFg.Count > 0) {
            sprite = spriteObjectsFg[0];
        }

        if (sprite != null) {
            return sprite.GetTransformedBounds();
        }

        // no sprites, looking for textures
        Texture2D texture = null;
        if (texturesBackground.Length > 0) {
            texture = texturesBackground[0].texture;
        }

        if (texture == null && texturesForeground.Length > 0) {
            texture = texturesForeground[0].texture;
        }

        if (texture != null) {
            Vector2 offset = PivotOffset(pivot);
            float w = texture.width;
            float h = texture.height;
            return new Rect(offset.x * w, (1 - offset.y) * h, w, h);
        }

        return new Rect();
    }
示例#2
0
    void SetIconInvisible(MadSprite sprite) {
        bool wasVisible = sprite.visible;
        sprite.visible = false;

        if (wasVisible && onIconHide != null) {
            onIconHide(sprite);
        }
    }
示例#3
0
    protected override void Rebuild() {
        base.Rebuild();

        // remove all hidden child sprites
        var hidden = MadTransform.FindChildren<MadSprite>(
            transform, (s) => s.gameObject.hideFlags == HideFlags.HideInHierarchy);
        for (int i = 0; i < hidden.Count; ++i) {
            MadGameObject.SafeDestroy(hidden[i].gameObject);
        }
    
        int nextDepth = guiDepth * DepthSpace;
        
        // build background
        nextDepth = BuildBackgroundTextures(nextDepth);

        // build the bar        
        if (textureBar != null) {
            if (effectBurn) {
                spriteBurnBar = CreateHidden<MadSprite>("bar_effect_burn");
                spriteBurnBar.guiDepth = nextDepth++;

                if (TextureValid(effectBurnTextureBar, atlasEffectBurnTextureBarGUID)) {
                    SetTexture(spriteBurnBar, effectBurnTextureBar, atlasEffectBurnTextureBarGUID);
                } else {
                    SetTexture(spriteBurnBar, textureBar, atlasTextureBarGUID);
                }
                
                spriteBurnBar.fillType = ToFillType(growDirection);
                spriteBurnBar.radialFillOffset = radialOffset;
                spriteBurnBar.radialFillLength = radialLength;
            }
        
            spriteBar = CreateHidden<MadSprite>("bar");
            spriteBar.guiDepth = nextDepth++;

            SetTexture(spriteBar, textureBar, atlasTextureBarGUID);
            
            spriteBar.fillType = ToFillType(growDirection);
            spriteBar.radialFillOffset = radialOffset;
            spriteBar.radialFillLength = radialLength;
        }
        
        // build foreground textures
        nextDepth = BuildForegroundTextures(nextDepth);
        
        // follow effect
        if (effectFollow) {
            if (effectFollowObject != null && effectFollowObject is Texture2D) {
                effectFollowSprite = CreateHidden<MadSprite>("bar_effect_follow");
                effectFollowSprite.texture = effectFollowObject as Texture2D;
                effectFollowSprite.guiDepth = nextDepth++;
            }
        }
        
        nextDepth = RebuildLabel(nextDepth);

        UpdateContainer();
    }
    int BuildBar(int nextDepth) {
        spriteBar = CreateHidden<MadSprite>("bar");

        spriteBar.guiDepth = nextDepth++;

        SetTexture(spriteBar, gridTexture, gridAtlasTextureGUID);
        
        return nextDepth;
    }
示例#5
0
    void SetIconVisible(MadSprite sprite) {
        bool wasInvisible = sprite.visible == false;

        sprite.tint = ComputeColor(tintIcon);
        sprite.fillValue = 1;
        MadTransform.SetLocalScale(sprite.transform, 1);
        sprite.visible = true;

        if (wasInvisible && onIconShow != null) {
            onIconShow(sprite);
        }
    }
示例#6
0
    private int BuildObject(int nextDepth) {
        objectSprite = CreateHidden<MadSprite>("object");

        objectSprite.guiDepth = nextDepth++;

        SetTexture(objectSprite, objectTexture, objectAtlasTextureGUID);

        objectSprite.pivotPoint = MadSprite.PivotPoint.Custom;
        objectSprite.customPivotPoint = new Vector2(objectAnchor.x, 1 - objectAnchor.y);

        return nextDepth;
    }
示例#7
0
 /// <summary>
 /// Assing regular texture or atlas texture based on current settings.
 /// </summary>
 protected void SetTexture(MadSprite sprite, Texture2D tex, string atlasTex) {
     if (useAtlas) {
         sprite.inputType = MadSprite.InputType.TextureAtlas;
         sprite.textureAtlas = atlas;
         sprite.textureAtlasSpriteGUID = atlasTex;
         sprite.texture = null;
     } else {
         sprite.inputType = MadSprite.InputType.SingleTexture;
         sprite.textureAtlas = null;
         sprite.lastTextureAtlasSpriteGUID = null;
         sprite.texture = tex;
     }
 }
示例#8
0
    public Rect AnyBackgroundOrForegroundSpriteSize() {
        MadSprite sprite = null;

        if (spriteObjectsBg.Count > 0) {
            sprite = spriteObjectsBg[0];
        }

        if (sprite == null && spriteObjectsFg.Count > 0) {
            sprite = spriteObjectsFg[0];
        }

        if (sprite != null) {
            return sprite.GetTransformedBounds();
        }

        return new Rect();
    }
 void SetSpriteInvisible(MadSprite sprite) {
     sprite.visible = false;
 }
 void SetSpriteVisible(MadSprite sprite) {
     sprite.tint = tintIcon;
     sprite.fillValue = 1;
     MadTransform.SetLocalScale(sprite.transform, 1);
     sprite.visible = true;
 }
    private int BuildObject(int nextDepth) {
        objectSprite = CreateHidden<MadSprite>("object");

        objectSprite.guiDepth = nextDepth++;

        SetTexture(objectSprite, objectTexture, objectAtlasTextureGUID);

        objectSprite.pivotPoint = MadSprite.PivotPoint.Custom;
        objectSprite.customPivotPoint = new Vector2(objectAnchor.x, 1 - objectAnchor.y);

        return nextDepth;
    }
 void RemoveSprite(MadSprite sprite) {
     if (sprite != null) {
         MadGameObject.SafeDestroy(sprite.gameObject);
     }
 }
    int BuildBar(int nextDepth) {
        spriteBar = CreateHidden<MadSprite>("bar");

        spriteBar.guiDepth = nextDepth++;

        SetTexture(spriteBar, gridTexture, gridAtlasTextureGUID);
        
        return nextDepth;
    }
示例#14
0
 void OnEnable()
 {
     sprite = GetComponent <MadSprite>();
 }
示例#15
0
 void Start()
 {
     loadingLogoSprite = GetComponent <MadSprite>();
     enableLoadingLogo(false);
 }
 void UpdateSlot(MadSprite sprite) {
     if (sprite != null) {
         sprite.tint = ComputeColor(tintSlot);
         MadTransform.SetLocalScale(sprite.transform, 1);
     }
 }
示例#17
0
 void SetSpriteVisible(MadSprite sprite) {
     sprite.tint = tintIcon;
     sprite.fillValue = 1;
     sprite.transform.localScale = new Vector3(1, 1, 1);
     sprite.visible = true;
 }
 void SetSpriteVisible(MadSprite sprite)
 {
     sprite.tint = tintIcon;
     sprite.fillValue = 1;
     sprite.transform.localScale = new Vector3(1, 1, 1);
     sprite.visible = true;
 }
示例#19
0
 void OnEnable() {
     sprite = GetComponent<MadSprite>();
 }
示例#20
0
    void Rebuild() {
#if MAD_DEBUG
        Debug.Log("rebuilding " + this, this);
#endif
    
        if (spriteObjectsBg.Count == 0 && spriteObjectsFg.Count == 0) {
            // in previous version sprites were created without reference in spriteObjects
            // is spriteObjects is empty it's better to assume, that references are not created yet
            // and background objects may exist
            var children = MadTransform.FindChildren<MadSprite>(transform,
                (s) => s.name.StartsWith("bg_") || s.name.StartsWith("fg_") || s.name == "label",
                0);
            foreach (var child in children) {
                MadGameObject.SafeDestroy(child.gameObject);
            }
        } else {
            foreach (var sprite in spriteObjectsBg) {
                if (sprite != null) {
                    MadGameObject.SafeDestroy(sprite.gameObject);
                }
            }
            
            foreach (var sprite in spriteObjectsFg) {
                if (sprite != null) {
                    MadGameObject.SafeDestroy(sprite.gameObject);
                }
            }
            
            spriteObjectsBg.Clear();
            spriteObjectsFg.Clear();
        }
        
        if (spriteBar != null) {
            MadGameObject.SafeDestroy(spriteBar.gameObject);
        }
        
        if (spriteBurnBar != null) {
            MadGameObject.SafeDestroy(spriteBurnBar.gameObject);
        }
        
        if (effectFollowSprite != null) {
            MadGameObject.SafeDestroy(effectFollowSprite.gameObject);
        }
        
        int nextDepth = BuildTextures(texturesBackground, "bg_", guiDepth * DepthSpace, ref spriteObjectsBg);
        
        if (textureBar != null) {
        
            if (effectBurn) {
                spriteBurnBar = MadTransform.CreateChild<MadSprite>(transform, "bar_effect_burn");
#if !MAD_DEBUG
                spriteBurnBar.gameObject.hideFlags = HideFlags.HideInHierarchy;
#endif
                spriteBurnBar.guiDepth = nextDepth++;
                spriteBurnBar.texture = textureBar;
                
                spriteBurnBar.fillType = ToFillType(growDirection);
            }
        
            spriteBar = MadTransform.CreateChild<MadSprite>(transform, "bar");
#if !MAD_DEBUG
            spriteBar.gameObject.hideFlags = HideFlags.HideInHierarchy;
#endif
            spriteBar.guiDepth = nextDepth++;
            spriteBar.texture = textureBar;
            
            spriteBar.fillType = ToFillType(growDirection);
        }
        
        nextDepth = BuildTextures(texturesForeground, "fg_", nextDepth, ref spriteObjectsFg);
        
        if (effectFollow) {
            if (effectFollowObject != null && effectFollowObject is Texture2D) {
                effectFollowSprite = MadTransform.CreateChild<MadSprite>(transform, "bar_effect_follow");
                effectFollowSprite.texture = effectFollowObject as Texture2D;
                effectFollowSprite.guiDepth = nextDepth++;
                #if !MAD_DEBUG
                effectFollowSprite.gameObject.hideFlags = HideFlags.HideInHierarchy;
                #endif
            }
        }
        
        nextDepth = RebuildLabel(nextDepth);
    }
示例#21
0
        void Rebuild()
        {
            #if MAD_DEBUG
            Debug.Log("rebuilding " + this, this);
            #endif

            if (spriteObjectsBg.Count == 0 && spriteObjectsFg.Count == 0) {
            // in previous version sprites were created without reference in spriteObjects
            // is spriteObjects is empty it's better to assume, that references are not created yet
            // and background objects may exist
            var children = MadTransform.FindChildren<MadSprite>(transform,
                (s) => s.name.StartsWith("bg_") || s.name.StartsWith("fg_") || s.name == "label",
                0);
            foreach (var child in children) {
                MadGameObject.SafeDestroy(child.gameObject);
            }
            } else {
            foreach (var sprite in spriteObjectsBg) {
                if (sprite != null) {
                    MadGameObject.SafeDestroy(sprite.gameObject);
                }
            }

            foreach (var sprite in spriteObjectsFg) {
                if (sprite != null) {
                    MadGameObject.SafeDestroy(sprite.gameObject);
                }
            }

            spriteObjectsBg.Clear();
            spriteObjectsFg.Clear();
            }

            if (spriteBar != null) {
            MadGameObject.SafeDestroy(spriteBar.gameObject);
            }

            if (spriteBurnBar != null) {
            MadGameObject.SafeDestroy(spriteBurnBar.gameObject);
            }

            if (effectFollowSprite != null) {
            MadGameObject.SafeDestroy(effectFollowSprite.gameObject);
            }

            int nextDepth = BuildTextures(texturesBackground, "bg_", guiDepth * DepthSpace, ref spriteObjectsBg);

            if (textureBar != null) {

            if (effectBurn) {
                spriteBurnBar = MadTransform.CreateChild<MadSprite>(transform, "bar_effect_burn");
            #if !MAD_DEBUG
                spriteBurnBar.gameObject.hideFlags = HideFlags.HideInHierarchy;
            #endif
                spriteBurnBar.guiDepth = nextDepth++;
                spriteBurnBar.texture = textureBar;

                spriteBurnBar.fillType = ToFillType(growDirection);
            }

            spriteBar = MadTransform.CreateChild<MadSprite>(transform, "bar");
            #if !MAD_DEBUG
            spriteBar.gameObject.hideFlags = HideFlags.HideInHierarchy;
            #endif
            spriteBar.guiDepth = nextDepth++;
            spriteBar.texture = textureBar;

            spriteBar.fillType = ToFillType(growDirection);
            }

            nextDepth = BuildTextures(texturesForeground, "fg_", nextDepth, ref spriteObjectsFg);

            if (effectFollow) {
            if (effectFollowObject != null && effectFollowObject is Texture2D) {
                effectFollowSprite = MadTransform.CreateChild<MadSprite>(transform, "bar_effect_follow");
                effectFollowSprite.texture = effectFollowObject as Texture2D;
                effectFollowSprite.guiDepth = nextDepth++;
                #if !MAD_DEBUG
                effectFollowSprite.gameObject.hideFlags = HideFlags.HideInHierarchy;
                #endif
            }
            }

            nextDepth = RebuildLabel(nextDepth);
        }
示例#22
0
    // ===========================================================
    // Methods for/from SuperClass/Interfaces
    // ===========================================================

    // ===========================================================
    // Methods
    // ===========================================================

    void Start()
    {
        loadingScreen = FindObjectOfType(typeof(MadLevelLoadingScreen)) as MadLevelLoadingScreen;
        bar           = GetComponent <MadSprite>();
    }
 void SetSpriteVisible(MadSprite sprite) {
     sprite.tint = tintIcon;
     sprite.fillValue = 1;
     MadTransform.SetLocalScale(sprite.transform, 1);
     sprite.visible = true;
 }
    void SetIconVisible(MadSprite sprite) {
        bool wasInvisible = sprite.visible == false;

        sprite.tint = ComputeColor(tintIcon);
        sprite.fillValue = 1;
        MadTransform.SetLocalScale(sprite.transform, 1);
        sprite.visible = true;

        if (wasInvisible && onIconShow != null) {
            onIconShow(sprite);
        }
    }
 void SetSpriteInvisible(MadSprite sprite) {
     sprite.visible = false;
 }
    void SetIconInvisible(MadSprite sprite) {
        bool wasVisible = sprite.visible;
        sprite.visible = false;

        if (wasVisible && onIconHide != null) {
            onIconHide(sprite);
        }
    }
 void RemoveSprite(MadSprite sprite) {
     if (sprite != null) {
         MadGameObject.SafeDestroy(sprite.gameObject);
     }
 }
示例#28
0
    protected override void Rebuild() {
        base.Rebuild();

        // remove all hidden child sprites
        var hidden = MadTransform.FindChildren<MadSprite>(
            transform, (s) => s.gameObject.hideFlags == HideFlags.HideInHierarchy);
        for (int i = 0; i < hidden.Count; ++i) {
            MadGameObject.SafeDestroy(hidden[i].gameObject);
        }
    
        int nextDepth = guiDepth * DepthSpace;
        
        // build background
        nextDepth = BuildBackgroundTextures(nextDepth);

        // build the bar        
        if (textureBar != null) {
            if (effectBurn) {
                spriteBurnBar = CreateHidden<MadSprite>("bar_effect_burn");
                spriteBurnBar.guiDepth = nextDepth++;

                if (TextureValid(effectBurnTextureBar, atlasEffectBurnTextureBarGUID)) {
                    SetTexture(spriteBurnBar, effectBurnTextureBar, atlasEffectBurnTextureBarGUID);
                } else {
                    SetTexture(spriteBurnBar, textureBar, atlasTextureBarGUID);
                }
                
                spriteBurnBar.fillType = ToFillType(growDirection);
                spriteBurnBar.radialFillOffset = radialOffset;
                spriteBurnBar.radialFillLength = radialLength;
            }
        
            spriteBar = CreateHidden<MadSprite>("bar");
            spriteBar.guiDepth = nextDepth++;

            SetTexture(spriteBar, textureBar, atlasTextureBarGUID);
            
            spriteBar.fillType = ToFillType(growDirection);
            spriteBar.radialFillOffset = radialOffset;
            spriteBar.radialFillLength = radialLength;
        }
        
        // build foreground textures
        nextDepth = BuildForegroundTextures(nextDepth);
        
        // follow effect
        if (effectFollow) {
            if (effectFollowObject != null && effectFollowObject is Texture2D) {
                effectFollowSprite = CreateHidden<MadSprite>("bar_effect_follow");
                effectFollowSprite.texture = effectFollowObject as Texture2D;
                effectFollowSprite.guiDepth = nextDepth++;
            }
        }
        
        nextDepth = RebuildLabel(nextDepth);

        UpdateContainer();
    }
示例#29
0
 void UpdateSlot(MadSprite sprite) {
     if (sprite != null) {
         sprite.tint = ComputeColor(tintSlot);
         MadTransform.SetLocalScale(sprite.transform, 1);
     }
 }