protected override void Refresh() { var board = Manager.CurrentGame.Boards[Manager.CurrentDisplayingBoardNo]; var colonyPrefab = Resources.Load <GameObject>("Dynamic-PC/Colony"); foreach (Transform child in ColonyFrame.transform) { Destroy(child.gameObject); } for (int i = 0; i < board.Colonies.Count; i++) { var colonyCard = board.Colonies[i]; GameObject cardGo = Instantiate(colonyPrefab); var sp = UnityResources.GetSprite(colonyCard.SpecialImage); if (sp != null) { cardGo.GetComponent <SpriteRenderer>().sprite = sp; } cardGo.transform.SetParent(ColonyFrame.transform); cardGo.transform.localPosition = new Vector3(0, -0.205f * i); cardGo.GetComponent <PCBoardCardDisplayBehaviour>().Bind(colonyCard); } }
private void DisplayColony() { var sp = UnityResources.GetSprite("pc-board-card-" + ChooseParam("small", "normal") + "-event-background"); EventColonyPactCardFrame.SetActive(true); EventColonyPactCardFrame.GetComponent <SpriteRenderer>().sprite = sp; EventColonyPactCardFrame.FindObject("AgeText").GetComponent <TextMesh>().text = Card.CardAge.ToString(); EventColonyPactCardFrame.FindObject("NameText").GetComponent <TextMesh>().text = Card.CardName.WordWrap(ChooseParam(4, 7)); if (!SmallCard) { EventColonyPactCardFrame.FindObject("Description").SetActive(false); EventColonyPactCardFrame.FindObject("InstantEffects").SetActive(true); DisplaySustainedEffects(EventColonyPactCardFrame.FindObject("InstantEffects"), Card.ImmediateEffects, 2f); EventColonyPactCardFrame.FindObject("ProductionFrame").SetActive(true); DisplaySustainedEffects(EventColonyPactCardFrame.FindObject("ProductionFrame"), Card.SustainedEffects, 1.3f); } var imageSp = UnityResources.GetSprite(Card.NormalImage); if (imageSp != null) { EventColonyPactCardFrame.FindObject("NormalImage").GetComponent <SpriteRenderer>().sprite = imageSp; } }
private void DisplayEventAndPact() { var sp = UnityResources.GetSprite("pc-board-card-" + ChooseParam("small", "normal") + "-" + (Card.CardType == CardType.Event ? "event" : "pact") + "-background"); EventColonyPactCardFrame.SetActive(true); EventColonyPactCardFrame.GetComponent <SpriteRenderer>().sprite = sp; EventColonyPactCardFrame.FindObject("AgeText").GetComponent <TextMesh>().text = Card.CardAge.ToString(); EventColonyPactCardFrame.FindObject("NameText").GetComponent <TextMesh>().text = Card.CardName.WordWrap(ChooseParam(4, 7)); if (!SmallCard) { EventColonyPactCardFrame.FindObject("Description").SetActive(true); EventColonyPactCardFrame.FindObject("Description").GetComponent <TextMesh>().text = Card.Description.WordWrap(10); EventColonyPactCardFrame.FindObject("InstantEffects").SetActive(false); EventColonyPactCardFrame.FindObject("ProductionFrame").SetActive(false); } var imageSp = UnityResources.GetSprite(Card.NormalImage); if (imageSp != null) { EventColonyPactCardFrame.FindObject("NormalImage").GetComponent <SpriteRenderer>().sprite = imageSp; } }
protected override void Refresh() { var board = Manager.CurrentGame.Boards[Manager.CurrentDisplayingBoardNo]; this.GetComponent <SpriteRenderer>().sprite = UnityResources.GetSprite("SpriteTile/PCBoard/pc-board-player-background-" + _playerColor[Manager.CurrentDisplayingBoardNo]); }
public void DisplayTactic() { var sp = UnityResources.GetSprite("pc-board-card-" + ChooseParam("small", "normal") + "-tactic-background"); TacticCardFrame.SetActive(true); TacticCardFrame.GetComponent <SpriteRenderer>().sprite = sp; TacticCardFrame.FindObject("AgeText").GetComponent <TextMesh>().text = Card.CardAge.ToString(); TacticCardFrame.FindObject("NameText").GetComponent <TextMesh>().text = Card.CardName.WordWrap(ChooseParam(4, 5)); if (!SmallCard) { var frame = TacticCardFrame.FindObject("TacticContent"); foreach (Transform child in frame.transform) { Destroy(child.gameObject); } float start = Card.TacticComposition.Count * -0.18f + 0.18f; for (int i = 0; i < Card.TacticComposition.Count; i++) { var type = new[] { "infantry", "cavalry", "artillery" }[10 - Card.TacticComposition[i]]; var icon = new GameObject("Image", typeof(SpriteRenderer)); icon.transform.parent = frame.transform; icon.GetComponent <SpriteRenderer>().sprite = UnityResources.GetSprite("pc-board-card-tactic-icon-" + type); icon.transform.localScale = new Vector3(0.6f, 0.6f, 1f); icon.transform.localPosition = new Vector3(start + 0.36f * i, 0f, -0.01f); } TacticCardFrame.FindObject("TacticValue").GetComponent <TextMesh>().text = Card.TacticValue[0].ToString(); if (Card.TacticValue.Count > 1) { TacticCardFrame.FindObject("OutdatedTacticValue").SetActive(true); TacticCardFrame.FindObject("OutdatedTacticValueBackground").SetActive(true); TacticCardFrame.FindObject("OutdatedTacticValue").GetComponent <TextMesh>().text = Card.TacticValue[1].ToString(); } else { TacticCardFrame.FindObject("OutdatedTacticValue").SetActive(false); TacticCardFrame.FindObject("OutdatedTacticValueBackground").SetActive(false); } var imageSp = UnityResources.GetSprite(Card.NormalImage); if (imageSp != null) { TacticCardFrame.FindObject("NormalImage").GetComponent <SpriteRenderer>().sprite = imageSp; } } }
private void DisplayDefend() { var sp = UnityResources.GetSprite("pc-board-card-" + ChooseParam("small", "normal") + "-defend-background"); DefendCardFrame.SetActive(true); DefendCardFrame.GetComponent <SpriteRenderer>().sprite = sp; DefendCardFrame.FindObject("AgeText").GetComponent <TextMesh>().text = Card.CardAge.ToString(); DefendCardFrame.FindObject("Defend").GetComponent <TextMesh>().text = (((int)Card.CardAge) * 2).ToString(); DefendCardFrame.FindObject("Exploration").GetComponent <TextMesh>().text = (((int)Card.CardAge)).ToString(); }
public void Update() { if (_frame == null) { _frame = new GameObject(); _frame.transform.parent = gameObject.transform; _frame.transform.localPosition = new Vector3(0, 0, -0.1f); _frame.AddComponent <SpriteRenderer>().sprite = UnityResources.GetSprite("pc-board-card-small-highlight"); } _frame.SetActive(Highlight); }
public void DisplayWarning(Warning warning, GameObject warningPopup) { this._warningPopup = warningPopup; switch (warning.Type) { case WarningType.WarOverTerritory: case WarningType.WarOverTechnology: case WarningType.WarOverCulture: warningImg.sprite = UnityResources.GetSprite("SpriteTile/UI/icon-military"); var color = new[] { "e89d0e", "e00ee8", "2ce80e", "b4b4b4" }; var colorText = new[] { "橙色", "紫色", "绿色", "灰色" }; var warText = new[] { "领土战争", "文化战争", "资源战争" }; var warMarker = new[] { "yellow", "culture", "resource" }; _warningText = "与<color=#" + color [Convert.ToInt32(warning.Data)] + ">" + colorText [Convert.ToInt32(warning.Data)] + "</color>的" + warText[((int)warning.Type) - 1]; markerImg.sprite = UnityResources.GetSprite("SpriteTile/UI/icon-" + warMarker[((int)warning.Type) - 1]); break; case WarningType.Corruption: _warningText = "腐败 " + warning.Data + "级"; warningImg.sprite = UnityResources.GetSprite("SpriteTile/UI/icon-resource"); warningImg.transform.localScale = new Vector3(0.4f, 0.6f, 1); markerImg.gameObject.SetActive(false); break; case WarningType.CivilDisorder: _warningText = "暴动"; warningImg.sprite = UnityResources.GetSprite("SpriteTile/UI/icon-unhappy"); markerImg.gameObject.SetActive(false); break; case WarningType.Famine: _warningText = "饥荒"; warningImg.sprite = UnityResources.GetSprite("SpriteTile/UI/icon-food"); markerImg.gameObject.SetActive(false); break; case WarningType.LastTurn: _warningText = "最后一回合"; warningImg.sprite = UnityResources.GetSprite("SpriteTile/UI/icon-science"); markerImg.gameObject.SetActive(false); break; default: markerImg.gameObject.SetActive(false); _warningPopup = null; break; } }
private void DisplayAction() { //Get action background var sp = UnityResources.GetSprite("pc-board-card-" + ChooseParam("small", "normal") + "-action-background"); ActionCardFrame.SetActive(true); ActionCardFrame.GetComponent <SpriteRenderer>().sprite = sp; ActionCardFrame.FindObject("AgeText").GetComponent <TextMesh>().text = Card.CardAge.ToString(); ActionCardFrame.FindObject("NameText").GetComponent <TextMesh>().text = Card.CardName.WordWrap(ChooseParam(4, 6)); if (!SmallCard) { ActionCardFrame.FindObject("Description").GetComponent <TextMesh>().text = Card.Description.WordWrap(8); } }
private void DisplayLeader(TtaBoard board) { if (board.Leader == null) { LeaderFrame.GetComponent <PCBoardCardDisplayBehaviour>().Bind(null); LeaderFrame.GetComponent <SpriteRenderer>().sprite = UnityResources.GetSprite("leader_image_no_leader"); } else { var sprite = UnityResources.GetSprite(board.Leader.SpecialImage) ?? UnityResources.GetSprite("leader_unknown"); LeaderFrame.GetComponent <SpriteRenderer>().sprite = sprite; LeaderFrame.GetComponent <PCBoardCardDisplayBehaviour>().Bind(board.Leader); } }
protected override void Refresh() { var board = Manager.CurrentGame.Boards[Manager.CurrentDisplayingBoardNo]; if (board.Leader == null) { LeaderFrame.GetComponent <PCBoardCardDisplayBehaviour>().Bind(null); LeaderFrame.GetComponent <SpriteRenderer>().sprite = UnityResources.GetSprite("leader_image_no_leader"); } else { var sprite = UnityResources.GetSprite(board.Leader.SpecialImage) ?? UnityResources.GetSprite("leader_unknown"); LeaderFrame.GetComponent <SpriteRenderer>().sprite = sprite; LeaderFrame.GetComponent <PCBoardCardDisplayBehaviour>().Bind(board.Leader); } }
private void DisplayAggressionAndWar() { var sp = UnityResources.GetSprite("pc-board-card-" + ChooseParam("small", "normal") + "-" + (Card.CardType == CardType.War ? "war" : "aggression") + "-background"); WarAggressionCardFrame.SetActive(true); WarAggressionCardFrame.GetComponent <SpriteRenderer>().sprite = sp; WarAggressionCardFrame.FindObject("AgeText").GetComponent <TextMesh>().text = Card.CardAge.ToString(); WarAggressionCardFrame.FindObject("NameText").GetComponent <TextMesh>().text = Card.CardName.WordWrap(ChooseParam(4, 7)); if (!SmallCard) { WarAggressionCardFrame.FindObject("Description").GetComponent <TextMesh>().text = Card.Description.WordWrap(10); var frame = WarAggressionCardFrame.FindObject("RedDots"); foreach (Transform child in frame.transform) { Destroy(child.gameObject); } for (int i = 0; i < Card.RedMarkerCost[0]; i++) { var icon = new GameObject("Image", typeof(SpriteRenderer)); icon.transform.parent = frame.transform; icon.GetComponent <SpriteRenderer>().sprite = UnityResources.GetSprite("SpriteTile/UI/icon-red"); icon.transform.localScale = new Vector3(1f, 1f, 1f); icon.transform.localPosition = new Vector3(0 + 0.15f * i, 0f, -0.01f); } } var imageSp = UnityResources.GetSprite(Card.NormalImage); if (imageSp != null) { WarAggressionCardFrame.FindObject("NormalImage").GetComponent <SpriteRenderer>().sprite = imageSp; } }
private void DisplayLeader() { //Get action background var sp = UnityResources.GetSprite("pc-board-card-" + ChooseParam("small", "normal") + "-leader-background"); LeaderCardFrame.SetActive(true); LeaderCardFrame.GetComponent <SpriteRenderer>().sprite = sp; LeaderCardFrame.FindObject("AgeText").GetComponent <TextMesh>().text = Card.CardAge.ToString(); LeaderCardFrame.FindObject("NameText").GetComponent <TextMesh>().text = Card.CardName.WordWrap(ChooseParam(4, 6)); if (!SmallCard) { LeaderCardFrame.FindObject("Description").GetComponent <TextMesh>().text = Card.Description.WordWrap(10); } var imageSp = UnityResources.GetSprite(Card.NormalImage); if (imageSp != null) { LeaderCardFrame.FindObject("NormalImage").GetComponent <SpriteRenderer>().sprite = imageSp; } }
private void DisplayWonder() { var sp = UnityResources.GetSprite("pc-board-card-" + ChooseParam("small", "normal") + "-wonder-background"); WonderCardFrame.SetActive(true); WonderCardFrame.GetComponent <SpriteRenderer>().sprite = sp; WonderCardFrame.FindObject("AgeText").GetComponent <TextMesh>().text = Card.CardAge.ToString(); WonderCardFrame.FindObject("NameText").GetComponent <TextMesh>().text = Card.CardName.WordWrap(ChooseParam(4, 7)); if (!SmallCard) { WonderCardFrame.FindObject("Description").GetComponent <TextMesh>().text = Card.Description.WordWrap(10); WonderCardFrame.FindObject("Step").GetComponent <TextMesh>().text = Card.BuildCost.Aggregate("", (current, s) => current + (s + " ")).Trim(); } var imageSp = UnityResources.GetSprite(Card.NormalImage); if (imageSp != null) { WonderCardFrame.FindObject("NormalImage").GetComponent <SpriteRenderer>().sprite = imageSp; } DisplaySustainedEffects(WonderCardFrame.FindObject("ProductionFrame"), Card.SustainedEffects, ChooseParam(0.44f, 1.40f)); }
public void Refresh() { Age[] ages = { Age.A, Age.I, Age.II, Age.III }; for (int i = 0; i < 4; i++) { if (!Cells.ContainsKey(ages[i])) { Frames[i].SetActive(false); continue; } Frames[i].SetActive(true); //显示图片 var cellInfo = Cells[ages[i]]; Frames[i].FindObject("CardDisplay").GetComponent <PCBoardCardDisplayBehaviour>() .Bind(cellInfo.Card); //显示黄点 var yellowPrefab = Resources.Load <GameObject>("Dynamic-PC/YellowMarker"); DisplayMarker(cellInfo.Worker, yellowPrefab, Frames[i].FindObject("YellowMarkers")); //显示蓝点 var bluePrefab = Resources.Load <GameObject>("Dynamic-PC/BlueMarker"); DisplayMarker(cellInfo.Storage, bluePrefab, Frames[i].FindObject("BlueMarkers")); } for (int i = 0; i < 4; i++) { if (Frames[i].activeSelf == false) { continue; } var cellInfo = Cells[ages[i]]; if (i == 3 || Frames[i + 1].activeSelf != true) { Frames[i].FindObject("AgeText").SetActive(true); Frames[i].FindObject("NameText").SetActive(true); Frames[i].FindObject("SideName").SetActive(false); Frames[i].FindObject("AgeText").GetComponent <TextMesh>().text = cellInfo.Card.CardAge.ToString(); Frames[i].FindObject("NameText").GetComponent <TextMesh>().text = cellInfo.Card.CardName.WordWrap(4); } else { Frames[i].FindObject("AgeText").SetActive(false); Frames[i].FindObject("NameText").SetActive(false); Frames[i].FindObject("SideName").SetActive(true); Frames[i].FindObject("SideName").GetComponent <TextMesh>().text = cellInfo.Card.CardName.WordWrap(4); } var imageSp = UnityResources.GetSprite(cellInfo.Card.NormalImage); if (imageSp != null) { Frames[i].FindObject("NormalImage").GetComponent <SpriteRenderer>().sprite = imageSp; } } }
//用update会导致弹出窗口的OnMouseExit捕捉不到 public void Refresh() { if (!SceneTransporter.IsCurrentGameRefreshed()) { //当前游戏不完整,不刷新 ////此处应该抛出异常 return; } if (SceneTransporter.CurrentGame.Boards.Count <= BoardBehavior.CurrentPlayerBoardIndex) { //当前玩家编号出现错误,不刷新 //此处应该抛出异常 return; } TtaBoard board = SceneTransporter.CurrentGame.Boards[BoardBehavior.CurrentPlayerBoardIndex]; DisplayCardRow(SceneTransporter.CurrentGame.CardRow); DisplayEventsAndCardCounts(SceneTransporter.CurrentGame); //如果当前阶段是PoliticalPhase,那么就展示PoliticalPhase if (SceneTransporter.CurrentGame.CurrentPhase == TtaPhase.PoliticalPhase) { //不一定你是当前玩家,因为有可能别人在他的政治行动阶段打你呢 //或者你正在处理一个事件 if (SceneTransporter.CurrentGame.PossibleActions.Count > 0) { DisplayPoliticalPhaseDialogs(SceneTransporter.CurrentGame); } else { HideAllPoliticalPhaseDialogs(); } } else { HideAllPoliticalPhaseDialogs(); } var backgroundSpriteName = "SpriteTile/PCBoard/pc-board-player-background-" + "orange,purple,green,grey".Split(",".ToCharArray())[BoardBehavior.CurrentPlayerBoardIndex]; var backgroundsp = UnityResources.GetSprite(backgroundSpriteName); BackgroundSpriteGo.GetComponent <SpriteRenderer>().sprite = backgroundsp; JournalFrame.Refresh(); //展示用代码 DisplayYellowBlueBank(board); DisplayWhiteRedMarkers(board); DisplayGovenrment(board); DisplayLeader(board); DisplayCivilHandCard(board); DisplayMilitaryHandCard(board); DisplayWonders(board); DisplayColony(board); DisplayBuildings(board); DisplaySpecialTech(board); DisplayWarnings(board); DisplayTactics(board); DisplayWorkerPool(board); }
public void Refresh() { Age[] ages = { Age.A, Age.I, Age.II, Age.III }; for (int i = 0; i < 4; i++) { if (!Cells.ContainsKey(ages[i])) { Frames[i].SetActive(false); continue; } Frames[i].SetActive(true); //显示图片 var cellInfo = Cells[ages[i]]; Frames[i].FindObject("CardDisplay").GetComponent <PCBoardCardDisplayBehaviour>() .Bind(cellInfo.Card); Frames[i].GetComponent <BuildingCellController>() .Card = cellInfo.Card; //显示黄点 var yellowPrefab = Resources.Load <GameObject>("Dynamic-PC/YellowMarker"); DisplayMarker(cellInfo.Worker, yellowPrefab, Frames[i].FindObject("YellowMarkers")); //显示蓝点 var bluePrefab = Resources.Load <GameObject>("Dynamic-PC/BlueMarker"); DisplayMarker(cellInfo.Storage, bluePrefab, Frames[i].FindObject("BlueMarkers")); } for (int i = 0; i < 4; i++) { if (Frames[i].activeSelf == false) { continue; } var cellInfo = Cells[ages[i]]; if (i == 3 || Frames[i + 1].activeSelf != true) { Frames[i].FindObject("AgeText").SetActive(true); Frames[i].FindObject("NameText").SetActive(true); Frames[i].FindObject("SideName").SetActive(false); Frames[i].FindObject("AgeText").GetComponent <TextMesh>().text = cellInfo.Card.CardAge.ToString(); Frames[i].FindObject("NameText").GetComponent <TextMesh>().text = cellInfo.Card.CardName.WordWrap(4); } else { Frames[i].FindObject("AgeText").SetActive(false); Frames[i].FindObject("NameText").SetActive(false); Frames[i].FindObject("SideName").SetActive(true); Frames[i].FindObject("SideName").GetComponent <TextMesh>().text = cellInfo.Card.CardName.WordWrap(4); } var imageSp = UnityResources.GetSprite(cellInfo.Card.NormalImage); if (imageSp != null) { Frames[i].FindObject("NormalImage").GetComponent <SpriteRenderer>().sprite = imageSp; } String typeStr = "urban"; switch (cellInfo.Card.CardType) { case CardType.ResourceTechFarm: case CardType.ResourceTechMine: typeStr = "production"; break; case CardType.MilitaryTechAirForce: case CardType.MilitaryTechArtillery: case CardType.MilitaryTechCavalry: case CardType.MilitaryTechInfantry: typeStr = "military"; break; case CardType.SpecialTechCivil: case CardType.SpecialTechEngineering: case CardType.SpecialTechExploration: case CardType.SpecialTechMilitary: typeStr = "special"; break; } var sp = UnityResources.GetSprite("pc-board-card-small-" + typeStr + "-background"); Frames[i].FindObject("TypeFrame").GetComponent <SpriteRenderer>().sprite = sp; } }
private GameObject CreateFrameItem(CardEffect effect) { switch (effect.FunctionId) { case CardEffectType.E100: String iconImg; switch ((ResourceType)effect.Data[0]) { case ResourceType.Resource: case ResourceType.ResourceIncrement: iconImg = "SpriteTile/UI/icon-resource"; break; case ResourceType.Food: case ResourceType.FoodIncrement: iconImg = "SpriteTile/UI/icon-food"; break; case ResourceType.Culture: case ResourceType.CultureIncrement: iconImg = "SpriteTile/UI/icon-culture"; break; case ResourceType.Science: case ResourceType.ScienceIncrement: iconImg = "SpriteTile/UI/icon-science"; break; case ResourceType.MilitaryForce: iconImg = "SpriteTile/UI/icon-military"; break; case ResourceType.HappyFace: iconImg = effect.Data[0] >= 0 ? "SpriteTile/UI/icon-happy" : "SpriteTile/UI/icon-unhappy"; break; case ResourceType.WhiteMarkerMax: iconImg = "SpriteTile/UI/icon-white"; break; case ResourceType.RedMarkerMax: iconImg = "SpriteTile/UI/icon-red"; break; case ResourceType.YellowMarker: iconImg = "SpriteTile/UI/icon-yellow"; break; case ResourceType.BlueMarker: iconImg = "SpriteTile/UI/icon-blue"; break; default: return(null); } switch ((ResourceType)effect.Data[0]) { case ResourceType.Food: case ResourceType.FoodIncrement: case ResourceType.Resource: case ResourceType.ResourceIncrement: case ResourceType.Science: case ResourceType.ScienceIncrement: case ResourceType.Culture: case ResourceType.CultureIncrement: case ResourceType.MilitaryForce: case ResourceType.Exploration: { GameObject go = new GameObject("ProductionNumbered"); var icon = new GameObject("Image", typeof(SpriteRenderer)); icon.transform.parent = go.transform; icon.GetComponent <SpriteRenderer>().sprite = UnityResources.GetSprite(iconImg); icon.transform.localScale = new Vector3(ChooseParam(0.3f, 0.8f), ChooseParam(0.3f, 0.8f), 1); icon.transform.localPosition = new Vector3(0f, 0f, 0f); var text = new GameObject("Text", typeof(TextMesh)); text.AddComponent <TextOutline>(); text.GetComponent <TextMesh>().color = Color.white; text.GetComponent <TextMesh>().text = effect.Data[1].ToString(); text.GetComponent <TextMesh>().fontSize = ChooseParam(14, 30); text.transform.parent = go.transform; text.transform.localScale = new Vector3(0.1f, 0.1f, 1); text.transform.localPosition = new Vector3(ChooseParam(0f, 0.024f), ChooseParam(0.059f, 0.112f), -0.01f); return(go); } case ResourceType.HappyFace: case ResourceType.WhiteMarkerMax: case ResourceType.RedMarkerMax: case ResourceType.YellowMarker: case ResourceType.BlueMarker: { GameObject go = new GameObject("ProductionStacked"); for (int i = 0; i < Math.Abs(effect.Data[1]); i++) { var icon = new GameObject("Image", typeof(SpriteRenderer)); icon.transform.parent = go.transform; icon.GetComponent <SpriteRenderer>().sprite = UnityResources.GetSprite(iconImg); icon.transform.localScale = new Vector3(ChooseParam(0.3f, 0.8f), ChooseParam(0.3f, 0.8f), 1); icon.transform.localPosition = new Vector3(0f + ChooseParam(0.02f, 0.1f) * i, 0f, 0f); } if (effect.Data[1] < 0 && (effect.Data[0] != (int)ResourceType.HappyFace)) { var text = new GameObject("Text", typeof(TextMesh)); text.AddComponent <TextOutline>(); text.GetComponent <TextMesh>().color = Color.white; text.GetComponent <TextMesh>().text = "-"; text.GetComponent <TextMesh>().fontSize = ChooseParam(14, 30); text.transform.parent = go.transform; text.transform.localScale = new Vector3(0.1f, 0.1f, 1); text.transform.localPosition = new Vector3(ChooseParam(-0.15f, -0.24f), ChooseParam(0.059f, 0.2f), -0.01f); } return(go); } default: return(null); } default: return(null); } }
private void DisplayBuilding() { //Get action background String typeStr = "urban"; switch (Card.CardType) { case CardType.ResourceTechFarm: case CardType.ResourceTechMine: typeStr = "production"; break; case CardType.MilitaryTechAirForce: case CardType.MilitaryTechArtillery: case CardType.MilitaryTechCavalry: case CardType.MilitaryTechInfantry: typeStr = "military"; break; case CardType.SpecialTechCivil: case CardType.SpecialTechEngineering: case CardType.SpecialTechExploration: case CardType.SpecialTechMilitary: typeStr = "special"; break; } var sp = UnityResources.GetSprite("pc-board-card-" + ChooseParam("small", "normal") + "-" + typeStr + "-background"); BuildingCardFrame.SetActive(true); BuildingCardFrame.GetComponent <SpriteRenderer>().sprite = sp; BuildingCardFrame.FindObject("AgeText").GetComponent <TextMesh>().text = Card.CardAge.ToString(); BuildingCardFrame.FindObject("NameText").GetComponent <TextMesh>().text = Card.CardName.WordWrap(ChooseParam(4, 5)); if (!SmallCard) { if (Card.ResearchCost.Count > 0 && Card.ResearchCost[0] > 0) { BuildingCardFrame.FindObject("TechCost").GetComponent <TextMesh>().text = Card.ResearchCost[0].ToString(); } else { BuildingCardFrame.FindObject("TechCost").SetActive(false); BuildingCardFrame.FindObject("TechCostBackground").SetActive(false); } if (Card.BuildCost.Count > 0 && Card.BuildCost[0] > 0) { BuildingCardFrame.FindObject("ResourceCost").GetComponent <TextMesh>().text = Card.BuildCost[0].ToString(); BuildingCardFrame.FindObject("ResourceCost").SetActive(true); BuildingCardFrame.FindObject("ResourceCostBackground").SetActive(true); } else { BuildingCardFrame.FindObject("ResourceCost").SetActive(false); BuildingCardFrame.FindObject("ResourceCostBackground").SetActive(false); } if (Card.Description != null) { BuildingCardFrame.FindObject("Description").SetActive(true); BuildingCardFrame.FindObject("Description").GetComponent <TextMesh>().text = Card.Description.WordWrap(10); } else { BuildingCardFrame.FindObject("Description").SetActive(false); } var imageSp = UnityResources.GetSprite(Card.NormalImage); if (imageSp != null) { BuildingCardFrame.FindObject("NormalImage").GetComponent <SpriteRenderer>().sprite = imageSp; BuildingCardFrame.FindObject("NormalImage").transform.localScale = new Vector3(ChooseParam(0.333f, 1f), ChooseParam(0.333f, 1f), 1f); } DisplaySustainedEffects(BuildingCardFrame.FindObject("ProductionFrame"), Card.SustainedEffects, ChooseParam(0.44f, 1.40f)); } }
private void DisplayWonders(TtaBoard board) { //建造中 if (board.ConstructingWonder != null) { ConstructingWonderFrame.SetActive(true); ConstructingWonderFrame.FindObject("WonderName").GetComponent <TextMesh>().text = board.ConstructingWonder.CardName; var stepFrame = ConstructingWonderFrame.FindObject("Steps"); foreach (Transform child in stepFrame.transform) { Destroy(child.gameObject); } var stepPrefab = Resources.Load <GameObject>("Dynamic-PC/WonderBuildingStage"); float init = -0.16f * board.ConstructingWonderSteps.Count + 0.16f; for (int index = 0; index < board.ConstructingWonderSteps.Count; index++) { var str = board.ConstructingWonderSteps[index]; var mSp = Instantiate(stepPrefab); if (str == "X") { mSp.FindObject("StepText").SetActive(false); } else { mSp.FindObject("BlueMarker").SetActive(false); mSp.FindObject("StepText").GetComponent <TextMesh>().text = str; } mSp.transform.parent = stepFrame.transform; mSp.transform.localPosition = new Vector3(init + 0.16f * index, 0, 0); } ConstructingWonderFrame.GetComponent <PCBoardCardDisplayBehaviour>().Bind(board.ConstructingWonder); } else { ConstructingWonderFrame.SetActive(false); } //建造完成 var wonderPrefab = Resources.Load <GameObject>("Dynamic-PC/CompletedWonder"); foreach (Transform child in CompletedWondersFrame.transform) { Destroy(child.gameObject); } for (int i = 0; i < board.CompletedWonders.Count; i++) { var wonderCard = board.CompletedWonders[i]; GameObject cardGo = Instantiate(wonderPrefab); cardGo.FindObject("WonderName").GetComponent <TextMesh>().text = wonderCard.CardName; cardGo.transform.SetParent(CompletedWondersFrame.transform); cardGo.transform.localPosition = new Vector3(0, -0.27f * i); cardGo.FindObject("Mask").GetComponent <PCBoardCardDisplayBehaviour>().Bind(wonderCard); var sp = UnityResources.GetSprite(wonderCard.SpecialImage); if (sp != null) { cardGo.FindObject("Image").GetComponent <SpriteRenderer>().sprite = sp; } } }
private void DisplayGovernment() { var sp = UnityResources.GetSprite("pc-board-card-" + ChooseParam("small", "normal") + "-government-background"); GovernmentCardFrame.SetActive(true); GovernmentCardFrame.GetComponent <SpriteRenderer>().sprite = sp; GovernmentCardFrame.FindObject("AgeText").GetComponent <TextMesh>().text = Card.CardAge.ToString(); GovernmentCardFrame.FindObject("NameText").GetComponent <TextMesh>().text = Card.CardName.WordWrap(ChooseParam(4, 5)); if (Card.ResearchCost.Count > 0 && Card.ResearchCost[0] > 0) { GovernmentCardFrame.FindObject("TechCost").GetComponent <TextMesh>().text = Card.ResearchCost[0].ToString(); GovernmentCardFrame.FindObject("RevoCost").GetComponent <TextMesh>().text = Card.ResearchCost[1].ToString(); } else { GovernmentCardFrame.FindObject("TechCost").SetActive(false); GovernmentCardFrame.FindObject("TechCostBackground").SetActive(false); GovernmentCardFrame.FindObject("RevoCost").SetActive(false); GovernmentCardFrame.FindObject("RevoCostBackground").SetActive(false); } int whiteMarker = 0; int redMarker = 0; int urbanLimit = 0; List <CardEffect> effects = new List <CardEffect>(); foreach (var effect in Card.SustainedEffects) { if (effect.FunctionId == CardEffectType.E100) { switch ((ResourceType)effect.Data[0]) { case ResourceType.WhiteMarkerMax: whiteMarker = effect.Data[1]; continue; case ResourceType.RedMarkerMax: redMarker = effect.Data[1]; continue; case ResourceType.UrbanLimit: urbanLimit = effect.Data[1]; continue; } } effects.Add(effect); } if (!SmallCard) { var frame = GovernmentCardFrame.FindObject("WhiteMarkerFrame"); foreach (Transform child in frame.transform) { Destroy(child.gameObject); } for (int i = 0; i < whiteMarker; i++) { var icon = new GameObject("Image", typeof(SpriteRenderer)); icon.transform.parent = frame.transform; icon.GetComponent <SpriteRenderer>().sprite = UnityResources.GetSprite("SpriteTile/UI/icon-white"); icon.transform.localScale = new Vector3(ChooseParam(0.3f, 0.8f), ChooseParam(0.3f, 0.8f), 1); icon.transform.localPosition = new Vector3(0f + ChooseParam(0.02f, 0.1f) * i, 0f, -0.01f); } frame = GovernmentCardFrame.FindObject("RedMarkerFrame"); foreach (Transform child in frame.transform) { Destroy(child.gameObject); } for (int i = 0; i < redMarker; i++) { var icon = new GameObject("Image", typeof(SpriteRenderer)); icon.transform.parent = frame.transform; icon.GetComponent <SpriteRenderer>().sprite = UnityResources.GetSprite("SpriteTile/UI/icon-red"); icon.transform.localScale = new Vector3(ChooseParam(0.3f, 0.8f), ChooseParam(0.3f, 0.8f), 1); icon.transform.localPosition = new Vector3(0f + ChooseParam(0.02f, 0.1f) * i, 0f, -0.01f); } } GovernmentCardFrame.FindObject("WhiteCount").GetComponent <TextMesh>().text = whiteMarker.ToString(); GovernmentCardFrame.FindObject("RedCount").GetComponent <TextMesh>().text = redMarker.ToString(); GovernmentCardFrame.FindObject("UrbanLimit").GetComponent <TextMesh>().text = urbanLimit.ToString(); var imageSp = UnityResources.GetSprite(Card.NormalImage); if (imageSp != null) { GovernmentCardFrame.FindObject("NormalImage").GetComponent <SpriteRenderer>().sprite = imageSp; } DisplaySustainedEffects(GovernmentCardFrame.FindObject("ProductionFrame"), effects, ChooseParam(0.44f, 1f)); }