public override void merge(CardDefine newVersion) { if (newVersion.type != type) { UberDebug.LogWarning(newVersion + "的类型与" + this + "不同,可能是一次非法的数据合并!"); } life = newVersion.getProp <int>(nameof(life)); skillID = newVersion.getProp <int>(nameof(skillID)); }
public static bool hasTag(this CardDefine define, string tag) { string[] tags = define.getProp <string[]>(nameof(ServantCardDefine.tags)); if (tags == null) { return(false); } return(tags.Contains(tag)); }
public static int getAttack(this CardDefine card) { int result = card.getProp <int>(nameof(ServantCardDefine.attack)); if (result < 0) { result = 0; } return(result); }
void saveCardToXml(CardDefine card, XmlDocument xml) { xml["Card"]["ID"].InnerText = card.id.ToString(); if (card is ServantCardDefine) { xml["Card"]["Type"].InnerText = "Servant"; } else if (card is MasterCardDefine) { xml["Card"]["Type"].InnerText = "Master"; } else if (card is SkillCardDefine) { xml["Card"]["Type"].InnerText = "Skill"; } xml["Card"]["Cost"].InnerText = card.getProp <int>("cost").ToString(); xml["Card"]["Attack"].InnerText = card.getProp <int>("attack").ToString(); xml["Card"]["Life"].InnerText = card.getProp <int>("life").ToString(); if (card.getProp <string[]>("tags") is string[] tags) { xml["Card"]["Tags"].InnerText = string.Join(",", tags); } else { xml["Card"]["Tags"].InnerText = null; } if (card.getProp <string[]>("keywords") is string[] keywords) { xml["Card"]["Keywords"].InnerText = string.Join(",", keywords); } else { xml["Card"]["Keywords"].InnerText = null; } if (_manager != null) { var skin = _manager.getSkin(card.id); xml["Card"]["Skin"]["Image"].InnerText = skin == null ? null : skin.image != null ? skin.image.name + ".png" : null; xml["Card"]["Skin"]["Name"].InnerText = skin == null?card.GetType().Name : skin.name; xml["Card"]["Skin"]["Desc"].InnerText = skin == null ? null : skin.desc; } }
public override void merge(CardDefine newVersion) { if (newVersion.type != type) { UberDebug.LogWarning(newVersion + "的类型与" + this + "不同,可能是一次非法的数据合并!"); } cost = newVersion.getProp <int>(nameof(cost)); attack = newVersion.getProp <int>(nameof(attack)); life = newVersion.getProp <int>(nameof(life)); spellDamage = newVersion.getProp <int>(nameof(spellDamage)); isToken = newVersion.getProp <bool>(nameof(isToken)); tags = newVersion.getProp <string[]>(nameof(tags)); keywords = newVersion.getProp <string[]>(nameof(keywords)); }
public override void merge(CardDefine newVersion) { if (newVersion.type != type) { UberDebug.LogWarning(newVersion + "的类型与" + this + "不同,可能是一次非法的数据合并!"); } if (newVersion is GeneratedCardDefine generated) { if (generated.hasProp(nameof(cost))) { cost = newVersion.getProp <int>(nameof(cost)); } if (generated.hasProp(nameof(attack))) { attack = newVersion.getProp <int>(nameof(attack)); } if (generated.hasProp(nameof(life))) { life = newVersion.getProp <int>(nameof(life)); } if (generated.hasProp(nameof(spellDamage))) { spellDamage = newVersion.getProp <int>(nameof(spellDamage)); } if (generated.hasProp(nameof(isToken))) { isToken = newVersion.getProp <bool>(nameof(isToken)); } if (generated.hasProp(nameof(tags))) { tags = newVersion.getProp <string[]>(nameof(tags)); } if (generated.hasProp(nameof(keywords))) { keywords = newVersion.getProp <string[]>(nameof(keywords)); } } }
public static int getLife(this CardDefine card) { return(card.getProp <int>(nameof(ServantCardDefine.life))); }
public static int getCost(this CardDefine card) { return(card.getProp <int>(nameof(ServantCardDefine.cost))); }
void saveCardToExcel(CardDefine card, Worksheet sheet) { int idIndex = findColIndex(sheet, "ID"); int classIndex = findColIndex(sheet, "Class"); int cardRow = sheet.Cells.Rows.Count;//如果表里没有这张卡,那么就新增 foreach (var pRow in sheet.Cells.Rows) { if (numberToInt(pRow.Value.GetCell(idIndex).Value) == card.id) { cardRow = pRow.Key;//如果有相同ID的卡,复写 sheet.Cells[cardRow, classIndex] = new Cell(card.GetType().Name); } else if (pRow.Value.GetCell(classIndex).StringValue == card.GetType().Name) { cardRow = pRow.Key;//如果有相同类型的卡,复写 sheet.Cells[cardRow, idIndex] = new Cell(card.id); } } sheet.Cells[cardRow, idIndex] = new Cell(card.id); int typeIndex = findColIndex(sheet, "Type"); if (card is ServantCardDefine) { sheet.Cells[cardRow, typeIndex] = new Cell("Servant"); } else if (card is MasterCardDefine) { sheet.Cells[cardRow, typeIndex] = new Cell("Master"); } else if (card is SkillCardDefine) { sheet.Cells[cardRow, typeIndex] = new Cell("Skill"); } else if (card is SpellCardDefine) { sheet.Cells[cardRow, typeIndex] = new Cell("Spell"); } else if (card is ItemCardDefine) { sheet.Cells[cardRow, typeIndex] = new Cell("Item"); } int costIndex = findColIndex(sheet, "Cost"); sheet.Cells[cardRow, costIndex] = new Cell(card.getProp <int>("cost")); int attackIndex = findColIndex(sheet, "Attack"); sheet.Cells[cardRow, attackIndex] = new Cell(card.getProp <int>("attack")); int lifeIndex = findColIndex(sheet, "Life"); sheet.Cells[cardRow, lifeIndex] = new Cell(card.getProp <int>("life")); int tagsIndex = findColIndex(sheet, "Tags"); if (card.getProp <string[]>("tags") is string[] tags) { sheet.Cells[cardRow, tagsIndex] = new Cell(string.Join(",", tags)); } else { sheet.Cells[cardRow, tagsIndex] = new Cell(null); } int keywordsIndex = findColIndex(sheet, "Keywords"); if (card.getProp <string[]>("keywords") is string[] keywords) { sheet.Cells[cardRow, keywordsIndex] = new Cell(string.Join(",", keywords)); } else { sheet.Cells[cardRow, keywordsIndex] = new Cell(null); } if (_manager != null) { var skin = _manager.getSkin(card.id); int imageIndex = findColIndex(sheet, "Image"); if (skin == null) { sheet.Cells[cardRow, imageIndex] = new Cell(sheet.Cells[cardRow, imageIndex].StringValue); } else { if (skin.image != null && !string.IsNullOrEmpty(skin.image.name)) { string path = AssetDatabase.GetAssetPath(skin.image); if (path.Contains("Resources/")) { path = path.removeHead("Resources/").removeRear("."); sheet.Cells[cardRow, imageIndex] = new Cell("res:" + path); } else { sheet.Cells[cardRow, imageIndex] = new Cell(skin.image.name + ".png"); } } else { sheet.Cells[cardRow, imageIndex] = new Cell(sheet.Cells[cardRow, imageIndex].StringValue); } } int nameIndex = findColIndex(sheet, "Name"); sheet.Cells[cardRow, nameIndex] = new Cell(skin == null ? (!string.IsNullOrEmpty(sheet.Cells[cardRow, nameIndex].StringValue) ? sheet.Cells[cardRow, nameIndex].StringValue : card.GetType().Name) : skin.name); int descIndex = findColIndex(sheet, "Desc"); sheet.Cells[cardRow, descIndex] = new Cell(skin == null ? sheet.Cells[cardRow, descIndex].StringValue : skin.desc); } }
void saveCardToExcel(CardDefine card, Worksheet sheet) { int idIndex = findColIndex(sheet, "ID"); int rowIndex = sheet.Cells.Rows.Count; foreach (var pRow in sheet.Cells.Rows) { if (numberToInt(pRow.Value.GetCell(idIndex).Value) == card.id) { rowIndex = pRow.Key; } } sheet.Cells[rowIndex, idIndex] = new Cell(card.id); int typeIndex = findColIndex(sheet, "Type"); if (card is ServantCardDefine) { sheet.Cells[rowIndex, typeIndex] = new Cell("Servant"); } else if (card is MasterCardDefine) { sheet.Cells[rowIndex, typeIndex] = new Cell("Master"); } else if (card is SkillCardDefine) { sheet.Cells[rowIndex, typeIndex] = new Cell("Skill"); } else if (card is SpellCardDefine) { sheet.Cells[rowIndex, typeIndex] = new Cell("Spell"); } int costIndex = findColIndex(sheet, "Cost"); sheet.Cells[rowIndex, costIndex] = new Cell(card.getProp <int>("cost")); int attackIndex = findColIndex(sheet, "Attack"); sheet.Cells[rowIndex, attackIndex] = new Cell(card.getProp <int>("attack")); int lifeIndex = findColIndex(sheet, "Life"); sheet.Cells[rowIndex, lifeIndex] = new Cell(card.getProp <int>("life")); int tagsIndex = findColIndex(sheet, "Tags"); if (card.getProp <string[]>("tags") is string[] tags) { sheet.Cells[rowIndex, tagsIndex] = new Cell(string.Join(",", tags)); } else { sheet.Cells[rowIndex, tagsIndex] = new Cell(null); } int keywordsIndex = findColIndex(sheet, "Keywords"); if (card.getProp <string[]>("keywords") is string[] keywords) { sheet.Cells[rowIndex, keywordsIndex] = new Cell(string.Join(",", keywords)); } else { sheet.Cells[rowIndex, keywordsIndex] = new Cell(null); } if (_manager != null) { var skin = _manager.GetCardSkin(card.id); int imageIndex = findColIndex(sheet, "Image"); sheet.Cells[rowIndex, imageIndex] = new Cell(skin == null ? null : skin.image != null ? skin.image.name + ".png" : null); int nameIndex = findColIndex(sheet, "Name"); sheet.Cells[rowIndex, nameIndex] = new Cell(skin == null ? card.GetType().Name : skin.name); int descIndex = findColIndex(sheet, "Desc"); sheet.Cells[rowIndex, descIndex] = new Cell(skin == null ? null : skin.desc); } }