public void SpawnSubSelector(SelectionClass pclass) { SelectorOptions options = new SelectorOptions(sub_options [(int)pclass], pclass); if (child != null) { try { Destroy(child.gameObject); } catch { } } sbyte pos = (sbyte)options.selection_class; GameObject selectorobj = Instantiate(GameObject.Find("map_subselector")); selectorobj.transform.SetParent(SceneGlobals.map_canvas.transform); SubSelector new_child = Loader.EnsureComponent <SubSelector>(selectorobj); new_child.targets = targets; new_child.options = options; new_child.InitSub(); new_child.targets = targets; new_child.Position = UpperLeft + new Vector2(width + new_child.width / 2, -new_child.head_height); new_child.draggable = false; new_child.transform.SetParent(transform, true); child = new_child; }
public void DoLeftArrowSizeTween() { SubSelector subSelectorOfCurrentObject = selector.SubSelectionEntries[selector.Components[selector.Current]]; if (subSelectorOfCurrentObject.Components.Count > 0) { DoSizeTween(leftArrow); } }
private static IEnumerable <Filter> GetFiltersFromSubSelector(string filter) { var match = SubSelector.Match(filter); var name = match.Groups["node"].Value; var leaves = match.Groups["leaves"].Value.Trim('(', ')').Split(','); var filters = new List <Filter>(); foreach (var leaf in leaves) { filters.Add(new Filter(string.Join("/", name, leaf), true)); } return(filters); }
public static IEnumerable <Filter> Create(string filter) { if (string.IsNullOrEmpty(filter)) { return(Enumerable.Empty <Filter>()); } if (SubSelector.IsMatch(filter)) { return(GetFiltersFromSubSelector(filter)); } return(new List <Filter> { new Filter(filter, false) }); }
public void RepositionArrows() { SubSelector subSelectorOfCurrentObject = selector.SubSelectionEntries[selector.Components[selector.Current]]; NavigationInformation arrowInfo = leftArrow.gameObject.GetComponent <NavigationInformation>(); if (subSelectorOfCurrentObject.Components.Count > 0) { NavigationInformation applyArrow = leftArrowApply.gameObject.GetComponent <NavigationInformation>(); if (leftArrow.color.a == 0f) { TweenArrowColor(leftArrowApply, applyArrow.NormalColor); TweenArrowColor(rightArrowApply, applyArrow.NormalColor); } TweenArrowColor(leftArrow, arrowInfo.HighlightedColor); TweenArrowColor(rightArrow, arrowInfo.HighlightedColor); RectTransform currentSelection = subSelectorOfCurrentObject.Components[subSelectorOfCurrentObject.Current].GetComponent <RectTransform>(); float currentSelectionHalfWidth = currentSelection.sizeDelta.x * 0.5f; leftArrow.rectTransform.SetParent(currentSelection.parent, true); rightArrow.rectTransform.SetParent(currentSelection.parent, true); Vector2 leftArrowPosition = currentSelection.anchoredPosition - new Vector2(currentSelectionHalfWidth + leftArrow.rectTransform.sizeDelta.x, 0f); Vector2 rightArrowPosition = currentSelection.anchoredPosition + new Vector2(currentSelectionHalfWidth + rightArrow.rectTransform.sizeDelta.x, 0f); // Do ultra magic Tween! LeanTween.move(leftArrow.rectTransform, leftArrowPosition, tweenTime).setEase(easeType); LeanTween.move(rightArrow.rectTransform, rightArrowPosition, tweenTime).setEase(easeType); } else { if (leftArrow.color.a != 0f) { TweenArrowColor(leftArrow, arrowInfo.PressedColor); TweenArrowColor(rightArrow, arrowInfo.PressedColor); } NavigationInformation applyArrow = leftArrowApply.gameObject.GetComponent <NavigationInformation>(); TweenArrowColor(leftArrowApply, applyArrow.PressedColor); TweenArrowColor(rightArrowApply, applyArrow.PressedColor); } }
public void SelectorClicked(SelectorButton button) { SubSelector concerned = button.parent as SubSelector; if (concerned == null) { return; } byte option = button.num; bool multiple = concerned.targets.Length > 1; for (int i = 0; i < concerned.targets.Length; i++) { // Check Flags if (i != 0 && (button.flags >> 1) % 2 == 0) { // single vessel only goto LOOPEND; } if (i == 0 && button.flags % 2 == 1) { // use pinlabel Debug.Log(DeveloppmentTools.LogIterable(concerned.targets)); concerned_objects = concerned.targets; lasting_command = button.function; } IMarkerParentObject parentObject = concerned.targets[i]; var ship = parentObject as Ship; SelectorOptions options = concerned.options; switch (button.function) { // +-----------------------------------------------------------------------------------------------------------------------+ // | Reference | // +-----------------------------------------------------------------------------------------------------------------------+ case 0x0c: // Set Camera --------------------------------------------------------------------------------------------------------------- SceneGlobals.ReferenceSystem.Offset += parentObject.Position - SceneGlobals.ReferenceSystem.Position; goto LOOPEND; case 0x0d: // Set Reference ------------------------------------------------------------------------------------------------------------ SceneGlobals.map_core.CurrentSystem = new ReferenceSystem(parentObject.Position); goto LOOPEND; case 0x0e: // Lock Reference ----------------------------------------------------------------------------------------------------------- Vector3 offset = Vector3.zero; SceneObject scene_obj = parentObject as SceneObject; if (parentObject is SceneObject) { offset = SceneGlobals.ReferenceSystem.Position - scene_obj.Position; SceneGlobals.ReferenceSystem = new ReferenceSystem(scene_obj); } else if (parentObject is ITargetable) { offset = SceneGlobals.ReferenceSystem.Position - parentObject.Position; Target tgt = (parentObject as ITargetable).Associated; SceneGlobals.ReferenceSystem = new ReferenceSystem(tgt); } SceneGlobals.ReferenceSystem.Offset = offset; goto LOOPEND; case 0x0f: // Lock & Set --------------------------------------------------------------------------------------------------------------- if (parentObject is SceneObject) { SceneGlobals.ReferenceSystem = new ReferenceSystem(parentObject as SceneObject); } else if (parentObject is ITargetable) { SceneGlobals.ReferenceSystem = new ReferenceSystem((parentObject as ITargetable).Associated); } goto LOOPEND; case 0x19: // Match Velocity Closest --------------------------------------------------------------------------------------------------- if (parentObject is ITargetable) { foreach (IMarkerParentObject impo in MapCore.Active.selection) { Ship ship01 = impo as Ship; if (ship01 != null && ship01.Friendly) { ship01.low_ai.MatchVelocityNearTarget((parentObject as ITargetable).Associated); } } } goto LOOPEND; case 0x1a: // Match Velocity ----------------------------------------------------------------------------------------------------------- if (parentObject is IPhysicsObject) { foreach (IMarkerParentObject impo in MapCore.Active.selection) { Ship ship01 = impo as Ship; if (ship01 != null && ship01.Friendly) { ship01.low_ai.MatchVelocity((parentObject as ITargetable).Associated); } } } goto LOOPEND; case 0x1b: // Attack ------------------------------------------------------------------------------------------------------------------- if (parentObject is ITargetable) { Target self_tgt = (parentObject as ITargetable).Associated; foreach (IMarkerParentObject impo in MapCore.Active.selection) { Ship ship01 = impo as Ship; if (ship01 != null && ship01.Friendly) { ship01.low_ai.Attack(self_tgt); } } } goto LOOPEND; case 0x1c: // TurretAttack ------------------------------------------------------------------------------------------------------------- if (parentObject is ITargetable) { Target self_tgt = (parentObject as ITargetable).Associated; foreach (IMarkerParentObject impo in MapCore.Active.selection) { Ship ship01 = impo as Ship; if (ship01 != null && ship01.Friendly) { ship01.low_ai.TurretAttack(self_tgt); } } } goto LOOPEND; case 0x1d: // Aim Here ----------------------------------------------------------------------------------------------------------------- SceneGlobals.Player.TurretAim = parentObject; goto LOOPEND; case 0x1e: // Target Part -------------------------------------------------------------------------------------------------------------- goto LOOPEND; case 0x1f: // Set Target --------------------------------------------------------------------------------------------------------------- if (parentObject is ITargetable) { Target tgt = (parentObject as ITargetable).Associated; SceneGlobals.Player.Target = tgt; } goto LOOPEND; // +-----------------------------------------------------------------------------------------------------------------------+ // | Info | // +-----------------------------------------------------------------------------------------------------------------------+ case 0x2e: // Ship Information --------------------------------------------------------------------------------------------------------- if (i != 0) { goto LOOPEND; } concerned.SpawnChild("Ship Information", new string [] { ship.Mass.ToString("Mass: 0.0 t"), string.Format("HP: {0:0.0} / {1:0.0}", ship.HP, ship.tot_hp), }); goto LOOPEND; case 0x2f: // OS ----------------------------------------------------------------------------------------------------------------------- goto LOOPEND; // +-----------------------------------------------------------------------------------------------------------------------+ // | Command | // +-----------------------------------------------------------------------------------------------------------------------+ // Match Velocity Closest --------------------------------------------------------------------------------------------------- case 0x29: goto LOOPEND; // Match Velocity ----------------------------------------------------------------------------------------------------------- case 0x3a: goto LOOPEND; case 0x3b: // Flee --------------------------------------------------------------------------------------------------------------------- ship.low_ai.Flee(); goto LOOPEND; case 0x3c: // Idle --------------------------------------------------------------------------------------------------------------------- ship.low_ai.Idle(); goto LOOPEND; case 0x3d: // Attack ------------------------------------------------------------------------------------------------------------------- goto LOOPEND; case 0x3e: // TurretAttack ------------------------------------------------------------------------------------------------------------- goto LOOPEND; case 0x3f: // Control ------------------------------------------------------------------------------------------------------------------ if (parentObject is Ship) { SceneGlobals.Player = parentObject as Ship; } goto LOOPEND; default: goto LOOPEND; } LOOPEND :; } }