Пример #1
0
        private static IEnumerator <Texture2D> RenderHighwayShield(DynamicSpriteFont defaultFont, HighwayShieldDescriptor descriptor, AdrHighwayParameters parameters)
        {
            if (defaultFont is null)
            {
                defaultFont = FontServer.instance[WTSEtcData.Instance.FontSettings.GetTargetFont(FontClass.HighwayShields)];
            }

            UITextureAtlas.SpriteInfo spriteInfo = descriptor.BackgroundImageParameter.GetCurrentSpriteInfo(null);
            if (spriteInfo is null)
            {
                LogUtils.DoWarnLog("HW: Background info is invalid for hw shield descriptor " + descriptor.SaveName);
                yield break;
            }
            else
            {
                int shieldHeight  = WTSAtlasLoadingUtils.MAX_SIZE_IMAGE_IMPORT;
                int shieldWidth   = WTSAtlasLoadingUtils.MAX_SIZE_IMAGE_IMPORT;
                var shieldTexture = new Texture2D(spriteInfo.texture.width, spriteInfo.texture.height);
                var targetColor   = descriptor.BackgroundColorIsFromHighway && parameters.hwColor != default ? parameters.hwColor : descriptor.BackgroundColor;
                shieldTexture.SetPixels(spriteInfo.texture.GetPixels().Select(x => x.MultiplyChannelsButAlpha(targetColor)).ToArray());
                TextureScaler.scale(shieldTexture, shieldWidth, shieldHeight);
                Color[] formTexturePixels = shieldTexture.GetPixels();

                foreach (var textDescriptor in descriptor.TextDescriptors)
                {
                    if (!textDescriptor.GetTargetText(parameters, out string text))
                    {
                        continue;
                    }

                    Texture2D overlayTexture;
                    if (text is null && textDescriptor.m_textType == TextType.GameSprite)
                    {
                        var spriteTexture = textDescriptor.m_spriteParam?.GetCurrentSpriteInfo(null)?.texture;
                        if (spriteTexture is null)
                        {
                            continue;
                        }
                        overlayTexture = new Texture2D(spriteTexture.width, spriteTexture.height);
                        overlayTexture.SetPixels(spriteTexture.GetPixels());
                        overlayTexture.Apply();
                    }
Пример #2
0
        internal static void GetTargetDescriptor(string layoutName, out ConfigurationSource source, out HighwayShieldDescriptor target)
        {
            if (layoutName == null)
            {
                source = ConfigurationSource.NONE;
                target = null;
                return;
            }
            layoutName = layoutName.Trim();

            if (WTSHighwayShieldsData.Instance.CityDescriptors.ContainsKey(layoutName))
            {
                source = ConfigurationSource.CITY;
                target = WTSHighwayShieldsData.Instance.CityDescriptors[layoutName];
                return;
            }
            if (WTSHighwayShieldsData.Instance.GlobalDescriptors.ContainsKey(layoutName))
            {
                source = ConfigurationSource.GLOBAL;
                target = WTSHighwayShieldsData.Instance.GlobalDescriptors[layoutName];
                return;
            }
            source = ConfigurationSource.NONE;
            target = null;
        }