public SelectableCards(SelectableType type) { Type = type; CardButtons = new List <ICardButton>(); CardSet = new CardSet(this); CardSet.Buttons.CollectionChanged += (s, e) => CardSetUpdated(); }
UISelectable GetSelectable(SelectableType selectableType) { foreach (UISelectable uISelectable in FindObjectsOfType <UISelectable>()) { if (uISelectable.selectableType == selectableType) { return(uISelectable); } } return(null); }
public void OnMouseLeftClickDown() { List <ISelectable> lastSelection = new List <ISelectable>(currentSelection); if (Input.GetKey(KeyCode.LeftControl) == false) { _DeselectAll(); } Ray raycastVector = Camera.main.ScreenPointToRay(Input.mousePosition); List <ISelectable> selectableHits = new List <ISelectable>(); RaycastHit[] raycastHits = Physics.RaycastAll(raycastVector, raycastMaxDistance, raycastLayerMask); foreach (RaycastHit raycastHit in raycastHits) { ISelectable selectable = GetSelectableItem(raycastHit.collider.transform); if (selectable != null) { SelectableType currentType = GetSelectionType(); if (currentType == SelectableType.None || selectable.GetSelectableType() == currentType) { selectable.Select(true); selectableHits.Add(selectable); } } } if (selectableHits.Count > 0) { ISelectable selectable = selectableHits.OrderBy((item) => item.GetPriority()).First(); currentSelection.Add(selectable); } if (Input.GetKey(KeyCode.LeftControl) == false) { if (Utils.Equals(currentSelection, lastSelection) == false) { SelectionChange(); } } }
static KMHoldable() { SelectableType = ReflectionHelper.FindType("Selectable"); if (SelectableType != null) { ParentField = SelectableType.GetField("Parent", BindingFlags.Instance | BindingFlags.Public); ChildrenField = SelectableType.GetField("Children", BindingFlags.Instance | BindingFlags.Public); ChildRowLengthField = SelectableType.GetField("ChildRowLength", BindingFlags.Instance | BindingFlags.Public); FocusOnInteractionField = SelectableType.GetField("FocusOnInteraction", BindingFlags.Instance | BindingFlags.Public); InitMethod = SelectableType.GetMethod("Init", BindingFlags.Instance | BindingFlags.Public); } SetupRoomType = ReflectionHelper.FindType("SetupRoom"); GameplayRoomType = ReflectionHelper.FindType("GameplayRoom"); ModSelectableType = ReflectionHelper.FindType("ModSelectable"); if (ModSelectableType != null) { CopySettingsFromProxyMethod = ModSelectableType.GetMethod("CopySettingsFromProxy", BindingFlags.Instance | BindingFlags.Public); } FloatingHoldableType = ReflectionHelper.FindType("FloatingHoldable"); if (FloatingHoldableType != null) { HoldableTargetField = FloatingHoldableType.GetField("HoldableTarget", BindingFlags.Instance | BindingFlags.Public); FacesField = FloatingHoldableType.GetField("Faces", BindingFlags.Instance | BindingFlags.Public); } HoldableTargetType = ReflectionHelper.FindType("HoldableTarget"); if (HoldableTargetType != null) { AnimationIndexField = HoldableTargetType.GetField("AnimationIndex", BindingFlags.Instance | BindingFlags.Public); } FaceSelectableType = ReflectionHelper.FindType("Assets.Scripts.Input.FaceSelectable"); if (FaceSelectableType != null) { FaceField = FaceSelectableType.GetField("Face", BindingFlags.Instance | BindingFlags.Public); SelectableField = FaceSelectableType.GetField("Selectable", BindingFlags.Instance | BindingFlags.Public); } FaceEnumType = ReflectionHelper.FindType("Assets.Scripts.Input.FaceEnum"); }
void Awake() { isSelected = false; selectionBarPrefab = Resources.Load <GameObject> ("SelectionBar"); //check which kind of gameobject this is and set type if (gameObject.tag == "Ship") { selectableType = SelectableType.Ship; } if (gameObject.tag == "Planet") { selectableType = SelectableType.Planet; } if (gameObject.tag == "Module") { selectableType = SelectableType.Module; } }
// Only used by motion path, copying everything isn't necessairy public void CopyFrom(Movement m) { movementType = m.movementType; stopOnTarget = m.stopOnTarget; selectableType = m.selectableType; maxTargets = m.maxTargets; speed = m.speed; rotationSpeed = m.rotationSpeed; speedBoostMultiplier = m.speedBoostMultiplier; speedBoostDuration = m.speedBoostDuration; speedBoostTime = m.SpeedBoostTime(); targets.Clear(); LinkedListNode <Vector3> t = m.Targets().First; while (t != null) { targets.AddLast(t.Value); t = t.Next; } target = m.Target(); targetReached = m.TargetReached(); }