Пример #1
0
    public void Initialize(RuntimeSpriteDatabase db)
    {
        this.m_charToSpriteSymbol.Clear();
        int count = this.m_symbols.Count;

        for (int i = 0; i < count; i++)
        {
            if (this.m_symbols[i].spriteId != string.Empty)
            {
                SpriteData spriteData = db.Find(this.m_symbols[i].spriteId);
                this.m_symbols[i].spriteData = spriteData;
                if (spriteData == null)
                {
                }
                this.m_charToSpriteSymbol.Add(this.m_symbols[i].symbol[0], this.m_symbols[i]);
                Rect      uv    = spriteData.uv;
                Vector2[] array = new Vector2[4];
                array[0].x           = uv.x;
                array[0].y           = uv.y;
                array[1].x           = uv.x;
                array[1].y           = uv.y + uv.height;
                array[2].x           = uv.x + uv.width;
                array[2].y           = uv.y + uv.height;
                array[3].x           = uv.x + uv.width;
                array[3].y           = uv.y;
                this.m_symbols[i].uv = array;
            }
        }
    }
Пример #2
0
 public void GetPreviewImage(out float aspectRatio, out Rect uvRect)
 {
     if (base.GetComponent <MeshFilter>().sharedMesh != null)
     {
         aspectRatio = (float)this.m_spriteWidth / (float)this.m_spriteHeight;
         uvRect      = this.m_uvRect;
     }
     else
     {
         RuntimeSpriteDatabase component  = Resources.Load <GameObject>("GUISystem/SpriteDatabase").GetComponent <RuntimeSpriteDatabase>();
         SpriteData            spriteData = component.Find(this.m_id);
         if (spriteData != null)
         {
             if ((float)spriteData.height > 0f)
             {
                 aspectRatio = (float)spriteData.width / (float)spriteData.height;
             }
             else
             {
                 aspectRatio = 1f;
             }
             uvRect = spriteData.uv;
         }
         else
         {
             aspectRatio = 1f;
             uvRect      = new Rect(0f, 0f, 1f, 1f);
         }
     }
 }
Пример #3
0
    private void RefreshSpriteLocale(LocalizationReloaded localeChange)
    {
        string currentLanguage         = localeChange.currentLanguage;
        string localizedSprite         = this.GetLocalizedSprite(currentLanguage);
        RuntimeSpriteDatabase instance = Singleton <RuntimeSpriteDatabase> .Instance;
        SpriteData            data     = instance.Find(localizedSprite);

        base.gameObject.GetComponent <Sprite>().SelectSprite(data, false);
    }
Пример #4
0
 public void RebuildIcons()
 {
     if (Singleton <RuntimeSpriteDatabase> .Instance != null)
     {
         RuntimeSpriteDatabase instance   = Singleton <RuntimeSpriteDatabase> .Instance;
         UnlockType            unlockType = this.unlockType;
         if (unlockType != SpecialSandboxUnlockDialog.UnlockType.Skull)
         {
             if (unlockType == SpecialSandboxUnlockDialog.UnlockType.Statue)
             {
                 this.sandboxLogo.SelectSprite(instance.Find(TextDialog.LocalizeSprite.GetLocalizedSprite(this.statueEpisodeIcon, Singleton <Localizer> .Instance.CurrentLocale)), true);
             }
         }
         else
         {
             this.sandboxLogo.SelectSprite(instance.Find(TextDialog.LocalizeSprite.GetLocalizedSprite(this.skullEpisodeIcon, Singleton <Localizer> .Instance.CurrentLocale)), true);
         }
     }
 }
Пример #5
0
    private void Awake()
    {
        if (!Application.isPlaying)
        {
            return;
        }
        RuntimeSpriteDatabase instance = Singleton <RuntimeSpriteDatabase> .Instance;
        SpriteData            data     = instance.Find(this.m_id);

        this.SelectSprite(data, false);
    }
Пример #6
0
    private void Awake()
    {
        if (!Application.isPlaying)
        {
            return;
        }
        RuntimeSpriteDatabase component = Resources.Load <GameObject>("GUISystem/SpriteDatabase").GetComponent <RuntimeSpriteDatabase>();

        this.m_spriteData = component.Find(base.GetComponent <SpriteReference>().Id);
        this.Rebuild(this.m_spriteData);
    }
Пример #7
0
    public void RebuildMesh()
    {
        MeshFilter component = base.GetComponent <MeshFilter>();

        if (component.sharedMesh != null)
        {
            UnityEngine.Object.DestroyImmediate(component.sharedMesh);
        }
        component.sharedMesh = null;
        RuntimeSpriteDatabase component2 = Resources.Load <GameObject>("GUISystem/SpriteDatabase").GetComponent <RuntimeSpriteDatabase>();
        SpriteData            data       = component2.Find(this.m_id);

        this.SelectSprite(data, false);
    }
Пример #8
0
    public void InitializeAnimations(RuntimeSpriteDatabase db)
    {
        this.m_timer      = 0f;
        this.m_frame      = 0;
        this.m_sprite     = base.GetComponent <global::Sprite>();
        this.m_meshFilter = base.GetComponent <MeshFilter>();
        string id = this.m_sprite.Id;

        foreach (Animation animation in this.m_animations)
        {
            float num = 0f;
            foreach (FrameTiming frameTiming in animation.frames)
            {
                num += frameTiming.time;
                frameTiming.endTime = num;
                SpriteData data = db.Find(frameTiming.id);
                this.m_sprite.SelectSprite(data, true);
                frameTiming.mesh = this.m_sprite.GetComponent <MeshFilter>().sharedMesh;
            }
        }
        this.m_sprite.SelectSprite(db.Find(id), true);
        this.m_initialized = true;
    }
Пример #9
0
        private void CreatePowerupIcon(LootCrateRewards.Powerup powerup)
        {
            if (this.m_collectableIcon == null)
            {
                return;
            }
            Sprite component = this.m_collectableIcon.GetComponent <Sprite>();

            if (component == null)
            {
                return;
            }
            string text = string.Empty;

            switch (this.m_rewards[0].PowerupReward)
            {
            case LootCrateRewards.Powerup.Magnet:
                text = WPFMonoBehaviour.gameData.m_superMagnetIcon.GetComponent <Sprite>().Id;
                break;

            case LootCrateRewards.Powerup.Superglue:
                text = WPFMonoBehaviour.gameData.m_superGlueIcon.GetComponent <Sprite>().Id;
                break;

            case LootCrateRewards.Powerup.Turbo:
                text = WPFMonoBehaviour.gameData.m_turboChargeIcon.GetComponent <Sprite>().Id;
                break;

            case LootCrateRewards.Powerup.Supermechanic:
                text = WPFMonoBehaviour.gameData.m_superMechanicIcon.GetComponent <Sprite>().Id;
                break;

            case LootCrateRewards.Powerup.NightVision:
                text = WPFMonoBehaviour.gameData.m_nightVisionIcon.GetComponent <Sprite>().Id;
                break;
            }
            if (!string.IsNullOrEmpty(text))
            {
                RuntimeSpriteDatabase instance = Singleton <RuntimeSpriteDatabase> .Instance;
                component.SelectSprite(instance.Find(text), true);
            }
        }
Пример #10
0
    public void UpdateIcons()
    {
        this.Initialize();
        if (this.textMesh == null || string.IsNullOrEmpty(this.originalText))
        {
            return;
        }
        if (string.IsNullOrEmpty(this.originalText = this.textMesh.text))
        {
            return;
        }
        if (!this.ContainsTag())
        {
            return;
        }
        Renderer component = this.textMesh.GetComponent <Renderer>();

        this.textMesh.text = string.Empty;
        bool enabled = component.enabled;

        component.enabled = false;
        string text = this.originalText;
        RuntimeSpriteDatabase instance = Singleton <RuntimeSpriteDatabase> .Instance;
        List <Material>       list     = new List <Material>();

        foreach (string text2 in SpriteIconData.Instance.GetTags())
        {
            if (this.originalText.Contains(text2))
            {
                SpriteIconData.SpriteIcon spriteIcon = SpriteIconData.Instance.GetSpriteIcon(text2);
                SpriteData spriteData     = instance.Find(spriteIcon.spriteId);
                Material   atlasReference = spriteIcon.atlasReference;
                if (spriteData != null && atlasReference != null)
                {
                    int num = -1;
                    for (int i = 0; i < list.Count; i++)
                    {
                        if (list[i] == atlasReference)
                        {
                            num = i + 1;
                        }
                    }
                    if (num < 0)
                    {
                        list.Add(atlasReference);
                        num = list.Count;
                    }
                    int num2 = Mathf.FloorToInt(spriteIcon.scale * (float)this.textMesh.font.fontSize);
                    spriteIcon.quad = string.Format("<quad material={5} size={0} x={1:0.000} y={2:0.000} width={3:0.000} height={4:0.000} />", new object[]
                    {
                        num2,
                        spriteData.uv.x,
                        spriteData.uv.y,
                        spriteData.uv.width,
                        spriteData.uv.height,
                        num
                    });
                    text = text.Replace(spriteIcon.tag, spriteIcon.quad);
                }
            }
        }
        if (list.Count > 0)
        {
            Material[] array = new Material[list.Count + 1];
            array[0] = component.sharedMaterials[0];
            int num3 = 1;
            foreach (Material material in list)
            {
                array[num3] = material;
                num3++;
            }
            component.sharedMaterials = array;
        }
        component.enabled = enabled;
        text = " " + text + " ";
        text = text.Replace("  ", " ");
        this.textMesh.text = text;
    }