private bool HandleHouseSlotClick(RaycastHit hit) { var townHouseController = hit.collider.GetComponent <TownHouseController>(); var townHouseSlot = hit.collider.GetComponent <TownHouseSlot>(); if (townHouseController) { townHouseSlot = townHouseController.GetComponentInParent <TownHouseSlot>(); } if (!townHouseSlot) { return(false); } if (selectedHouseSlot) { selectedHouseSlot.Deselect(defaultMaterial); } selectedHouseSlot = townHouseSlot; selectedHouseSlot.Select(selectedMaterial); buildSlotIcons.Show(selectedHouseSlot); return(true); }
internal void SetHouse(TownHouseSlot slot, TownHouseSlotType type) { if (slot == null || !slot) { return; } if (type == TownHouseSlotType.Empty) { SetHouseType(slot, TownHouseSlotType.Empty, null); return; } if (buildableTownHouses == null || buildableTownHouses.Length == 0) { return; } var house = buildableTownHouses.FirstOrDefault(x => x.Type == type); if (house == null || !house) { return; } SetHouseType(slot, type, house); }
public void Hide() { HideBuildDialog(); HidePlayerAssignDialog(); gameObject.SetActive(false); activeSlot = null; }
public void Show(TownHouseSlot slot) { if (slot == null || !slot) { Hide(); return; } transform.position = slot.transform.position + ((yOffset + slot.IconOffset) * Vector3.up); activeSlot = slot; switch (slot.SlotType) { case TownHouseSlotType.Undefined: case TownHouseSlotType.Empty: SetPlayerLogo(null); buttonBuildHouse.gameObject.SetActive(true); buttonEraseHouse.gameObject.SetActive(false); buttonSwitchPlayer.gameObject.SetActive(false); buttonAssignPlayer.gameObject.SetActive(false); break; default: SetPlayerLogo(slot.OwnerUserId); buttonBuildHouse.gameObject.SetActive(false); buttonEraseHouse.gameObject.SetActive(true); buttonSwitchPlayer.gameObject.SetActive(!string.IsNullOrEmpty(slot.OwnerUserId)); buttonAssignPlayer.gameObject.SetActive(!slot.Owner && string.IsNullOrEmpty(slot.OwnerUserId)); break; } HideBuildDialog(); gameObject.SetActive(true); }
internal void SetOwner(TownHouseSlot activeSlot, PlayerController newOwner) { if (newOwner != null && newOwner) { var owningSlot = slots.FirstOrDefault(x => x.Owner?.UserId == newOwner.UserId); if (owningSlot) { owningSlot.SetOwner(null); } } activeSlot.SetOwner(newOwner); }
private void SetHouseType(TownHouseSlot slot, TownHouseSlotType type, TownHouse house) { try { slot.SetHouse(new VillageHouseInfo() { Slot = slot.Slot, Type = (int)type }, house); if (slots != null && slots.Length > 0) { info.UsedSlots = slots.Count(x => x != null && x.SlotType != TownHouseSlotType.Empty && x.SlotType != TownHouseSlotType.Undefined); } } catch { } }
internal void SetHouse(TownHouseSlot slot, TownHouseSlotType type) { if (slot == null || !slot || buildableTownHouses == null || buildableTownHouses.Length == 0) { return; } var house = buildableTownHouses.FirstOrDefault(x => x.Type == type); if (house == null || !house) { return; } slot.SetHouse(new VillageHouseInfo() { Slot = slot.Slot, Type = (int)type }, house); }
internal void SetOwner(TownHouseSlot activeSlot, PlayerController newOwner) { if (slots == null || slots.Length == 0) { return; } if (newOwner != null && newOwner) { var owningSlot = slots.FirstOrDefault(x => x.Owner?.UserId == newOwner.UserId); if (owningSlot != null && owningSlot) { owningSlot.SetOwner(null); } } if (!activeSlot || activeSlot == null) { return; } activeSlot.SetOwner(newOwner); }