protected void PutInSlot(Button slot, IHoldable holdable) { if (slot != null) { var trigger = slot.GetComponent <EventTrigger>(); EventTrigger.Entry entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.PointerUp; entry.callback.AddListener((data) => { player.TakeInHand(holdable); foreach (var item in AllSlots) { slotSelector.Deselect(item.gameObject); } slotSelector.Select(data.selectedObject); }); trigger.triggers.Add(entry); // set name to slot var text = slot.GetComponentInChildren <Text>(); if (text != null) { text.text = holdable == null ? "Empty" : holdable.ToString(); } } }
public static void selectProvince(int number) { if (number < 0 || World.FindProvince(number) == Game.selectedProvince)// same province clicked, hide selection { var lastSelected = Game.selectedProvince; Game.selectedProvince = null; if (lastSelected != null) { //lastSelected.setBorderMaterial(LinksManager.Get.defaultProvinceBorderMaterial); //lastSelected.setBorderMaterials(true); provinceSelector.Deselect(lastSelected.GameObject); } if (provincePanel.isActiveAndEnabled) { provincePanel.Hide(); } } else // new province selected { if (Game.selectedProvince != null)//deal with previous selection { //Game.selectedProvince.setBorderMaterial(LinksManager.Get.defaultProvinceBorderMaterial); //Game.selectedProvince.setBorderMaterials(true); provinceSelector.Deselect(Game.selectedProvince.GameObject); } // freshly selected province Game.selectedProvince = World.FindProvince(number); provinceSelector.Select(Game.selectedProvince.GameObject); //Game.selectedProvince.setBorderMaterial(LinksManager.Get.selectedProvinceBorderMaterial); provincePanel.Show(); if (Game.MapMode == Game.MapModes.Cores) //core map mode { Game.redrawMapAccordingToMapMode(); } } if (buildPanel != null && buildPanel.isActiveAndEnabled) { buildPanel.Refresh(); } }
public override void Refresh() { var sb = new StringBuilder(); sb.Append("You rule: ").Append(Game.Player.FullName); if (!Game.Player.IsAlive) { sb.Append(" (destroyed by enemies, but could rise again)"); } sb.Append(" Month: ").Append(Date.Today); if (Game.Player.IsAlive) { sb.Append(" Population: ").Append(Game.Player.Provinces.getFamilyPopulation().ToString("N0")) .Append(" (") .Append(Game.Player.Provinces.AllPopsChanges.Where(y => y.Key == null || y.Key is Staff || (y.Key is Province && (y.Key as Province).Country != Game.Player)) .Sum(x => x.Value).ToString("+0;-0;0")) .Append(")"); } sb.Append("\nMoney: ").Append(Game.Player.Cash) .Append(" Tech points: ").Append(Game.Player.Science.Points.ToString("F0")); if (Game.Player.IsAlive) { sb.Append(" Loyalty: ").Append(Game.Player.Provinces.AllPops.GetAverageProcent(x => x.loyalty)) .Append(" Education: ").Append(Game.Player.Provinces.AllPops.GetAverageProcent(x => x.Education)); } if (Game.Player != null) { if (Game.Player.FailedPayments.Income.isNotZero()) { buttonSelector.Select(financeButton.gameObject); financeButton.GetComponent <ToolTipHandler>().RemoveTextStartingWith("\nCan't"); financeButton.GetComponent <ToolTipHandler>().AddText("\nCan't pay for:" + Game.Player.FailedPayments.GetIncomeText()); } else { buttonSelector.Deselect(financeButton.gameObject); financeButton.GetComponent <ToolTipHandler>().RemoveTextStartingWith("\nCan't"); } } generalText.text = sb.ToString(); }
/// <summary> /// Creates copy of this object ready to put in a world /// </summary> protected GameObject InstantiateCopy() { // Restores original material, instead of green "allowing" material placingAllowedSelector.Deselect(block); placingDeniedSelector.Deselect(block); var newBlock = UnityEngine.Object.Instantiate(this.block); newBlock.layer = 0; // placed block wouldn't be ignored by raycast if (this.isTrigger) { newBlock.GetComponent <Collider>().isTrigger = true; } else { newBlock.GetComponent <Collider>().isTrigger = false; } return(newBlock); }
public void Deselect(GameObject someObject) { selectorComponent.Deselect(someObject); }