Commit 2fd76323 authored by SherryChaos's avatar SherryChaos

add attribute ruby for card renderer

parent fb478906
This diff is collapsed.
......@@ -66,6 +66,7 @@ MonoBehaviour:
cardNormal: {fileID: 2800000, guid: b552f9fd55ddc7443bfe07c7dbc13b1f, type: 3}
cardNormalLink: {fileID: 2800000, guid: 875fa980a3eb990419e51879fe12b281, type: 3}
cardNormalPendulum: {fileID: 2800000, guid: 71402236982fddd41ada1cc6a44e94bd, type: 3}
CardKiraNormal03_Millennium: {fileID: 2800000, guid: 71d6974fbeeed2c41901e87746fda0cb, type: 3}
attributeLight: {fileID: 21300000, guid: 157f899e40b269e4bb70d867aa084278, type: 3}
attributeDark: {fileID: 21300000, guid: 7976b559931f6e840863f07ea92c278a, type: 3}
attributeWater: {fileID: 21300000, guid: e639e2cab68115f499825b099bd456d5, type: 3}
......@@ -75,6 +76,15 @@ MonoBehaviour:
attributeDivine: {fileID: 21300000, guid: 435cb54b358980b42b0fabd5dbbce75a, type: 3}
attributeSpell: {fileID: 21300000, guid: 40e45967f7e2236429d838e90c3a19b3, type: 3}
attributeTrap: {fileID: 21300000, guid: be55c7575bca71b42b9f373fc0aecd01, type: 3}
attributeLight_Ruby: {fileID: 21300000, guid: b39796ee8b82c2c4fa0d8f4e3065221c, type: 3}
attributeDark_Ruby: {fileID: 21300000, guid: 7703e75c871bc1942b4f343bf9f81025, type: 3}
attributeWater_Ruby: {fileID: 21300000, guid: 042e2122887c9e449bc62ffc1b6c0e56, type: 3}
attributeFire_Ruby: {fileID: 21300000, guid: 44744a2e861f2c440a1ec28c0a3e6ea4, type: 3}
attributeEarth_Ruby: {fileID: 21300000, guid: 03a7053d66a52524e89c74cd6dea449c, type: 3}
attributeWind_Ruby: {fileID: 21300000, guid: f3a0375556492314e8e0b0c6c1ff51f4, type: 3}
attributeDivine_Ruby: {fileID: 21300000, guid: 8119e73337b1ae743ad4fdfc47eef220, type: 3}
attributeSpell_Ruby: {fileID: 21300000, guid: f7b330234c47da548ab1565d2dcf861c, type: 3}
attributeTrap_Ruby: {fileID: 21300000, guid: f2b244ed9403f0a4e88cea7e1d9f8487, type: 3}
typeNone: {fileID: 21300000, guid: cfdad45f88fa7a14eb79e8bbc3307670, type: 3}
typeCounter: {fileID: 21300000, guid: e8877c146699bad498e5c7c3e7d5c22f, type: 3}
typeField: {fileID: 21300000, guid: 29814486051bdaa4ebf24d6c941f462c, type: 3}
......@@ -490,10 +500,3 @@ MonoBehaviour:
gamepad_Start_PlayStation: {fileID: 21300000, guid: 114b48f9b41b6a542b167960a7d9ee17, type: 3}
gamepad_Select_Nintendo: {fileID: 21300000, guid: 0308e5cde23a96b4bbfaf28d59ec7835, type: 3}
gamepad_Start_Nintendo: {fileID: 21300000, guid: 86feb6744b88c6946a73edb7b90b2b1a, type: 3}
fxt_Arrow: {fileID: 2800000, guid: f7b877a77c7530543815b9cd571203ee, type: 3}
fxt_Arrow_002: {fileID: 2800000, guid: cc77cec8332acc04eb877183efcec954, type: 3}
fxt_Arrow_003: {fileID: 2800000, guid: 89ee305204be7844abd1fc33fd0e8db7, type: 3}
fxt_Arrow_004: {fileID: 2800000, guid: 4c88d66a9e295ce49afb8c45c5fd54e9, type: 3}
fxt_msk_005: {fileID: 2800000, guid: fc78254fef4709843a3b17422a6bf171, type: 3}
CardKiraNormal03_Millennium: {fileID: 2800000, guid: 71d6974fbeeed2c41901e87746fda0cb, type: 3}
CardMask001: {fileID: 2800000, guid: 90c6e35ef4304f289c279037152a03b7, type: 3}
......@@ -4,6 +4,7 @@ using MDPro3.Utility;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
......@@ -46,7 +47,8 @@ namespace MDPro3
public RawImage cardArtPendulumSquare;
public RawImage cardArtPendulumWidth;
public Image cardFrame;
public Image cardAttribute;
public Image attrIcon;
public TextMeshProUGUI attrRuby;
public TextMeshProUGUI cardName;
public Text cardDescription;
public Text cardDescriptionPendulum;
......@@ -75,7 +77,8 @@ namespace MDPro3
public RawImage cardArtPendulumRD;
public RawImage cardArtPendulumWidthRD;
public Image cardFrameRD;
public Image cardAttributeRD;
public Image attrIconRD;
public TextMeshProUGUI attrRubyRD;
public GameObject cardLegendRD;
public RectTransform movePartsRD;
public TextMeshProUGUI cardNameRD;
......@@ -164,6 +167,8 @@ namespace MDPro3
cardNameRD.font = tmpFont;
spellType.font = tmpFont;
cardTypeRD.font = tmpFont;
attrRuby.font = tmpFont;
attrRubyRD.font = tmpFont;
}
#endregion
......@@ -184,6 +189,8 @@ namespace MDPro3
if (currentFontLanguage == language)
return;
currentFontLanguage = language;
LoadText(language);
if (language == Language.SimplifiedChinese)
{
cardName.fontSize = 50f;
......@@ -279,12 +286,13 @@ namespace MDPro3
cardNameRD.GetComponent<RectTransform>().localScale = new Vector3(cardNameLabelWidthRushDuel / nameWidth, 1f, 1f);
cardNameRD.color = Color.white;
attrRubyRD.text = GetAttributeText(data);
cardArtRD.gameObject.SetActive(false);
cardArtPendulumRD.gameObject.SetActive(false);
cardArtPendulumWidthRD.gameObject.SetActive(false);
cardFrameRD.gameObject.SetActive(false);
cardAttributeRD.gameObject.SetActive(false);
attrIconRD.gameObject.SetActive(false);
cardLegendRD.SetActive(false);
}
......@@ -301,6 +309,7 @@ namespace MDPro3
cardName.GetComponent<RectTransform>().localScale = new Vector3(cardNameLabelWidthOCG / nameWidth, 1, 1);
cardName.color = Color.white;
attrRuby.text = GetAttributeText(data);
cardFrame.gameObject.SetActive(false);
cardArt.gameObject.SetActive(false);
......@@ -310,7 +319,7 @@ namespace MDPro3
levels.SetActive(false);
ranks.SetActive(false);
rank13.SetActive(false);
cardAttribute.gameObject.SetActive(false);
attrIcon.gameObject.SetActive(false);
levelsMask.SetActive(false);
ranksMask.SetActive(false);
rank13Mask.SetActive(false);
......@@ -393,7 +402,7 @@ namespace MDPro3
cardArtPendulumWidthRD.gameObject.SetActive(false);
cardFrameRD.gameObject.SetActive(true);
cardAttributeRD.gameObject.SetActive(true);
attrIconRD.gameObject.SetActive(true);
cardDescriptionPendulumRD.text = string.Empty;
lScaleRD.text = string.Empty;
rScaleRD.text = string.Empty;
......@@ -409,7 +418,8 @@ namespace MDPro3
movePartsRD.gameObject.SetActive(true);
movePartsRD.anchoredPosition = Vector2.zero;
cardAttributeRD.sprite = CardDescription.GetCardAttribute(data, true).sprite;
attrIconRD.sprite = TextureManager.container.GetCardAttributeIcon(data, true);
attrRubyRD.text = GetAttributeText(data);
cardTypeRD.text = data.GetTypeForRushDuelRender();
if (data.HasType(CardType.Pendulum))
......@@ -571,7 +581,7 @@ namespace MDPro3
cardArtPendulumWidth.gameObject.SetActive(false);
cardFrame.gameObject.SetActive(true);
cardAttribute.gameObject.SetActive(true);
attrIcon.gameObject.SetActive(true);
cardDescriptionPendulum.text = string.Empty;
lScale.text = string.Empty;
rScale.text = string.Empty;
......@@ -590,7 +600,8 @@ namespace MDPro3
linkCount.gameObject.SetActive(false);
spellType.text = string.Empty;
cardDescription.GetComponent<RectTransform>().sizeDelta = new Vector2(590f, 160f);
cardAttribute.sprite = CardDescription.GetCardAttribute(data, true).sprite;
attrIcon.sprite = TextureManager.container.GetCardAttributeIcon(data, true);
attrRuby.text = GetAttributeText(data);
if (data.HasType(CardType.Pendulum))
{
......@@ -987,5 +998,71 @@ namespace MDPro3
#endregion
#region IDS_SYS
private readonly Dictionary<string, string> idsSysText = new();
private void LoadText(string language)
{
idsSysText.Clear();
var path = $"{Program.PATH_LOCALES}{language}/IDS/IDS_SYS.txt";
if (!File.Exists(path))
return;
var text = File.ReadAllText(path);
var lines = text.Replace("\r", string.Empty).Split('\n');
string currentKey = null;
string currentValue = null;
foreach (var line in lines)
{
var match = Regex.Match(line, @"(?<=\[IDS_SYS\.).*?(?=\])");
if (match.Success)
{
if (currentValue != null)
idsSysText[currentKey] = currentValue;
currentKey = match.Value;
}
else
currentValue = line;
}
if(currentKey != null && currentValue != null)
idsSysText[currentKey] = currentValue;
}
private string GetIdsSysText(string key)
{
if (idsSysText.TryGetValue(key, out var value))
return value;
return string.Empty;
}
private string GetAttributeText(Card data)
{
if (data.HasType(CardType.Spell))
return GetIdsSysText("ATTR_MAGIC_RUBY");
else if (data.HasType(CardType.Trap))
return GetIdsSysText("ATTR_TRAP_RUBY");
else if (data.IsAttribute(CardAttribute.Light))
return GetIdsSysText("ATTR_LIGHT_RUBY");
else if(data.IsAttribute(CardAttribute.Dark))
return GetIdsSysText("ATTR_DARK_RUBY");
else if (data.IsAttribute(CardAttribute.Water))
return GetIdsSysText("ATTR_WATER_RUBY");
else if (data.IsAttribute(CardAttribute.Fire))
return GetIdsSysText("ATTR_FIRE_RUBY");
else if (data.IsAttribute(CardAttribute.Earth))
return GetIdsSysText("ATTR_EARTH_RUBY");
else if (data.IsAttribute(CardAttribute.Wind))
return GetIdsSysText("ATTR_WIND_RUBY");
else if (data.IsAttribute(CardAttribute.Divine))
return GetIdsSysText("ATTR_GOD_RUBY");
else
return string.Empty;
}
#endregion
}
}
......@@ -149,7 +149,7 @@ namespace MDPro3
manager.GetElement<TextMeshProUGUI>("TextDescription").fontSize = 25f * Config.GetUIScale(1.35f);
bool isMonster = WhetherCardIsMonster(data);
bool isMonster = CardIsMonster(data);
if (isMonster)
{
manager.GetElement("PropertyMonster").SetActive(true);
......@@ -270,7 +270,7 @@ namespace MDPro3
manager.GetElement<Image>("Limit").sprite = TextureManager.container.banned;
}
public static bool WhetherCardIsMonster(Card data)
public static bool CardIsMonster(Card data)
{
var origin = CardsManager.Get(data.Id);
if (!origin.HasType(CardType.Monster))
......@@ -297,33 +297,41 @@ namespace MDPro3
public bool notOriginal;
}
public static AttributeSprite GetCardAttribute(Card data, bool render = false)
private static AttributeSprite GetCardAttribute(Card data)
{
var origin = CardsManager.Get(data.Id);
var returnValue = new AttributeSprite();
bool isMonster = WhetherCardIsMonster(data);
bool isMonster = CardIsMonster(data);
if (isMonster)
{
if (!origin.HasType(CardType.Monster))
{
returnValue.sprite = TextureManager.GetCardAttributeIcon(data.Attribute, data.Id, render);
returnValue.notOriginal = true;
returnValue.sprite = TextureManager.container.GetCardAttributeIcon(data);
}
else
{
if ((data.Attribute ^ origin.Attribute) == 0)
if (origin.HasType(CardType.Trap))
{
returnValue.sprite = TextureManager.GetCardAttributeIcon(data.Attribute, data.Id, render);
returnValue.notOriginal = false;
returnValue.notOriginal = true;
returnValue.sprite = TextureManager.container.GetCardAttributeIcon(data);
}
else
{
returnValue.notOriginal = true;
if (data.Attribute != origin.Attribute)
returnValue.sprite = TextureManager.GetCardAttributeIcon(data.Attribute, data.Id, render);
if (data.Attribute == origin.Attribute)
{
returnValue.notOriginal = false;
returnValue.sprite = TextureManager.container.GetCardAttributeIcon(data);
}
else
returnValue.sprite = TextureManager.GetCardAttributeIcon(data.Attribute - origin.Attribute, data.Id, render);
{
returnValue.notOriginal = true;
var newData = data.Clone();
newData.Attribute = data.Attribute ^ origin.Attribute;
returnValue.sprite = TextureManager.container.GetCardAttributeIcon(newData);
}
}
}
}
......@@ -352,25 +360,13 @@ namespace MDPro3
}
else
{
returnValue.notOriginal = true;
if (data.HasType(CardType.Spell))
{
returnValue.sprite = TextureManager.container.attributeSpell;
returnValue.notOriginal = true;
}
else
{
returnValue.sprite = TextureManager.container.attributeTrap;
returnValue.notOriginal = true;
}
}
}
if (NeedRushDuelStyle(data.Id) && render)
{
if (returnValue.sprite == TextureManager.container.attributeSpell)
returnValue.sprite = TextureManager.container.rd_Attribute_Spell;
else if (returnValue.sprite == TextureManager.container.attributeTrap)
returnValue.sprite = TextureManager.container.rd_Attribute_Trap;
}
return returnValue;
}
......
......@@ -409,7 +409,7 @@ namespace MDPro3
var origin = render ? CardsManager.GetRenderCard(data.Id) : CardsManager.Get(data.Id);
try
{
if (CardDescription.WhetherCardIsMonster(data))
if (CardDescription.CardIsMonster(data))
{
if (data.Race != origin.Race)
re = bracketLeft + "<color=#FD3E08>" + InterString.Get("[?]族", Race(data.Race)) + "</color>" + Program.STRING_SLASH + SecondType(data.Type) + bracketRight;
......
......@@ -206,25 +206,6 @@ namespace MDPro3
return container.typeNone;
}
public static Sprite GetCardAttributeIcon(int attribute, int code, bool render = false)
{
bool rushDuel = CardRenderer.NeedRushDuelStyle(code);
if ((attribute & (uint)CardAttribute.Light) > 0)
return rushDuel && render ? container.rd_Attribute_Light : container.attributeLight;
else if ((attribute & (uint)CardAttribute.Dark) > 0)
return rushDuel && render ? container.rd_Attribute_Dark : container.attributeDark;
else if ((attribute & (uint)CardAttribute.Water) > 0)
return rushDuel && render ? container.rd_Attribute_Water : container.attributeWater;
else if ((attribute & (uint)CardAttribute.Fire) > 0)
return rushDuel && render ? container.rd_Attribute_Fire : container.attributeFire;
else if ((attribute & (uint)CardAttribute.Earth) > 0)
return rushDuel && render ? container.rd_Attribute_Earth : container.attributeEarth;
else if ((attribute & (uint)CardAttribute.Wind) > 0)
return rushDuel && render ? container.rd_Attribute_Wind : container.attributeWind;
else
return rushDuel && render ? container.rd_Attribute_Divine : container.attributeDivine;
}
public static Sprite GetCardRaceIcon(int race)
{
if ((race & (uint)CardRace.Warrior) > 0)
......
using MDPro3;
using MDPro3.Duel.YGOSharp;
using MDPro3.UI;
using MDPro3.Utility;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MDPro3.UI;
namespace MDPro3
{
......@@ -82,6 +83,15 @@ namespace MDPro3
public Sprite attributeDivine;
public Sprite attributeSpell;
public Sprite attributeTrap;
public Sprite attributeLight_Ruby;
public Sprite attributeDark_Ruby;
public Sprite attributeWater_Ruby;
public Sprite attributeFire_Ruby;
public Sprite attributeEarth_Ruby;
public Sprite attributeWind_Ruby;
public Sprite attributeDivine_Ruby;
public Sprite attributeSpell_Ruby;
public Sprite attributeTrap_Ruby;
[Header("CardType")]
public Sprite typeNone;
......@@ -787,27 +797,29 @@ namespace MDPro3
public Sprite GetCardAttributeIcon(Card data, bool render = false)
{
bool rushDuel = CardRenderer.NeedRushDuelStyle(data.Id);
bool needRuby = render && !rushDuel && Language.AttributeNeedRuby();
if (data.HasType(CardType.Monster))
{
if ((data.Attribute & (uint)CardAttribute.Light) > 0)
return rushDuel && render ? rd_Attribute_Light : attributeLight;
return rushDuel && render ? rd_Attribute_Light : needRuby ? attributeLight_Ruby : attributeLight;
else if ((data.Attribute & (uint)CardAttribute.Dark) > 0)
return rushDuel && render ? rd_Attribute_Dark : attributeDark;
return rushDuel && render ? rd_Attribute_Dark : needRuby ? attributeDark_Ruby : attributeDark;
else if ((data.Attribute & (uint)CardAttribute.Water) > 0)
return rushDuel && render ? rd_Attribute_Water : attributeWater;
return rushDuel && render ? rd_Attribute_Water : needRuby ? attributeWater_Ruby : attributeWater;
else if ((data.Attribute & (uint)CardAttribute.Fire) > 0)
return rushDuel && render ? rd_Attribute_Fire : attributeFire;
return rushDuel && render ? rd_Attribute_Fire : needRuby ? attributeFire_Ruby : attributeFire;
else if ((data.Attribute & (uint)CardAttribute.Earth) > 0)
return rushDuel && render ? rd_Attribute_Earth : attributeEarth;
return rushDuel && render ? rd_Attribute_Earth : needRuby ? attributeEarth_Ruby : attributeEarth;
else if ((data.Attribute & (uint)CardAttribute.Wind) > 0)
return rushDuel && render ? rd_Attribute_Wind : attributeWind;
return rushDuel && render ? rd_Attribute_Wind : needRuby ? attributeWind_Ruby : attributeWind;
else
return rushDuel && render ? rd_Attribute_Divine : attributeDivine;
return rushDuel && render ? rd_Attribute_Divine : needRuby ? attributeDivine_Ruby : attributeDivine;
}
else if (data.HasType(CardType.Spell))
return attributeSpell;
return rushDuel && render ? rd_Attribute_Spell : needRuby ? attributeSpell_Ruby : attributeSpell;
else
return attributeTrap;
return rushDuel && render ? rd_Attribute_Trap : needRuby ? attributeTrap_Ruby : attributeTrap;
}
public Sprite GetCardSpellTrapTypeIcon(Card data)
......
......@@ -48,7 +48,6 @@ namespace MDPro3
public static void CallVideoCardConfigChangeEvent()
{
Debug.Log("CallVideoCardConfigChangeEvent");
OnVideoCardConfigChange?.Invoke();
}
}
......
using System.Collections;
using Cysharp.Threading.Tasks;
using MDPro3.Duel.YGOSharp;
using MDPro3.Utility;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MDPro3.Utility;
using MDPro3.Duel.YGOSharp;
using UnityEngine;
using UnityEngine.AddressableAssets;
using Cysharp.Threading.Tasks;
using System.Threading;
namespace MDPro3
{
......@@ -240,6 +238,9 @@ namespace MDPro3
mat.SetTexture("_KiraMask", TextureManager.container.cardKiraMaskPendulum);
mat.SetTexture("_MainNormal", TextureManager.container.cardNormalPendulum);
}
if (Language.AttributeNeedRuby())
mat.SetVector("_AttributeSize_Pos", new Vector4(9.85f, 13.96f, -3.7f, -5.81f));
}
if (rarity == CardRarity.Rarity.Millennium)
......
......@@ -118,5 +118,13 @@ namespace MDPro3.Utility
return MasterDuelPortuguese;
return language;
}
public static bool AttributeNeedRuby()
{
var language = GetCardConfig();
if (language == SimplifiedChinese || language == TraditionalChinese)
return false;
return true;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment