private static void ChangePosition(ControllerStick controller, float newPosition) { ControllerStickEditor pointsEditor = (ControllerStickEditor)UnityEditor.Editor.CreateEditor((ControllerStick)controller, typeof(ControllerStickEditor)); pointsEditor.ChangePosition(newPosition); GameObject.DestroyImmediate(pointsEditor); }
public static GameObject CreateEventTrigger(string nameGameObject = "Points Lister") { GameObject whereToPut; if (Selection.activeGameObject != null) { ControllerStick controller = Selection.activeGameObject.GetComponent <ControllerStick>(); if (controller != null) { whereToPut = Selection.activeGameObject; } else { whereToPut = new GameObject(nameGameObject); whereToPut.transform.SetParent(controller.transform); whereToPut.transform.localPosition = Vector3.zero; Undo.RegisterCreatedObjectUndo(whereToPut, "Create " + nameGameObject); } } else { whereToPut = new GameObject(nameGameObject); whereToPut.transform.localPosition = Vector3.zero; Undo.RegisterCreatedObjectUndo(whereToPut, "Create " + nameGameObject); } return(whereToPut); }
public void ShowBattleController(Action callback = null) { if (m_goControllerUI != null) { m_goControllerUI.SetActive(true); if (callback != null) { callback(); } return; } AssetCacheMgr.GetUIInstance("MainControllerUI.prefab", (prefab, guid, go) => { m_goControllerUI = go as GameObject; m_goControllerUI.transform.parent = MogoMainUIPanel.transform.FindChild("BattleUI/BottomLeft"); m_goControllerUI.transform.localPosition = new Vector3(150, 150, 0); m_goControllerUI.transform.localScale = Vector3.one; StickMgr = m_goControllerUI.AddComponent <ControllerStick>(); m_goControllerUI.SetActive(true); if (callback != null) { callback(); } }); }
internal static ControllerInputBinding[] createStickKeyBinding(ControllerStick stick, Microsoft.Xna.Framework.Vector2 comparisonVector, StickState comparisonState, StickState oldState, System.Windows.Forms.Keys key, InputMode applicableMode = InputMode.All, CommandTarget target = CommandTarget.None) { ControllerInputBinding downResult = new ControllerInputBinding(); downResult.stick = new ControllerStickBinding(stick, comparisonVector, comparisonState, oldState); KeyboardCommand newCommand = new KeyboardCommand(); newCommand.key = key; newCommand.commandState = ButtonState.Down; newCommand.applicableMode = applicableMode; newCommand.target = target; downResult.commands.Add(newCommand); ControllerInputBinding upResult = new ControllerInputBinding(); upResult = new ControllerInputBinding(); upResult.stick = new ControllerStickBinding(stick, comparisonVector, comparisonState, oldState); newCommand = new KeyboardCommand(); newCommand.key = key; newCommand.commandState = ButtonState.Up; newCommand.applicableMode = applicableMode; newCommand.target = target; upResult.commands.Add(newCommand); return(new ControllerInputBinding[2] { downResult, upResult }); }
public ControllerStickBinding(ControllerStick leftOrRight, Vector2 v, StickState newS, StickState oldS = StickState.Any) { side = leftOrRight; position = v; newState = newS; oldState = oldS; }
public static float DistFromWayPoint(Waypoint waypoint, ControllerStick controller) { if (waypoint == null || controller == null) { return(0); } return(Mathf.Abs(waypoint.GetPathPosition(controller.PositionUnits) - controller.PathPosition)); }
public void ConstructSticker(ControllerStick sticker) { this.UpdateEditor(); if (sticker != null) { ExtSerializedProperties.SetObjectReferenceValueIfEmpty <ControllerStick>(this.GetPropertie("_targetStick"), sticker.transform); ExtSerializedProperties.SetObjectReferenceValueIfEmpty <SplineBase>(this.GetPropertie("_spline"), sticker.SplineBase.transform); } ExtSerializedProperties.SetObjectReferenceValueIfEmpty <Transform>(this.GetPropertie("_toMove"), _target.transform); this.ApplyModification(); }
public PointsOnSplineExtension.Waypoint GetClosestWaypointRight(ControllerStick controller, out float dist, out PointsOnSplineExtension lister) { dist = 0; lister = null; if (ListToCheck.Length == 0) { return(null); } PointsOnSplineExtension.Waypoint closest = null; dist = 0; lister = null; bool foundOne = false; for (int i = 0; i < ListToCheck.Length; i++) { if (ListToCheck[i] == null || !ListToCheck[i].gameObject.activeInHierarchy) { continue; } PointsOnSplineExtension.Waypoint waypointToTest = ListToCheck[i].GetClosestWaypointRight(controller); if (waypointToTest == null) { continue; } if (!foundOne) { closest = waypointToTest; dist = PointsOnSplineExtension.DistFromWayPoint(waypointToTest, controller); lister = ListToCheck[i]; foundOne = true; } else { float distToTest = PointsOnSplineExtension.DistFromWayPoint(waypointToTest, controller); if (distToTest < dist) { closest = waypointToTest; dist = distToTest; lister = ListToCheck[i]; } } } return(closest); }
/// <summary> /// taking into account that points are ordered by pathPosition! /// </summary> /// <param name="controller"></param> /// <returns></returns> public Waypoint GetClosestWaypointRight(ControllerStick controller) { if (WaypointsCount == 0) { return(null); } Waypoint previous = null; for (int i = WaypointsCount - 1; i >= 0; i--) { Waypoint waypointToTest = GetWayPoint(i); if (waypointToTest.GetPathPosition(controller.PositionUnits) < controller.PathPosition) { break; } previous = waypointToTest; } return(previous); }
internal static ControllerInputBinding createStickCursorMoveBinding(ControllerStick stick, Microsoft.Xna.Framework.Vector2 comparisonVector, StickState comparisonState, StickState oldState, MouseMoveType moveType, Types.UIntVector moveScale, CommandTarget commandTarget, InputMode applicableMode) { ControllerInputBinding newBinding = new ControllerInputBinding(); newBinding.stick = new ControllerStickBinding(stick, comparisonVector, comparisonState, oldState); CursorMoveCommand newCommand = new CursorMoveCommand(); newCommand.mouseMove = new MouseMove(); newCommand.mouseMove.commandTarget = commandTarget; newCommand.mouseMove.moveType = moveType; newCommand.mouseMove.moveScale = moveScale; newCommand.applicableMode = applicableMode; newBinding.commands.Add(newCommand); //bindings.Add(newBinding); return(newBinding); }
public Waypoint GetClosestWaypointBidirectionnal(ControllerStick controller) { if (WaypointsCount == 0) { return(null); } Waypoint closest = GetWayPoint(0); float dist = DistFromWayPoint(closest, controller); for (int i = 1; i < WaypointsCount; i++) { Waypoint waypointToTest = GetWayPoint(i); float distToTest = DistFromWayPoint(waypointToTest, controller); if (distToTest < dist) { closest = waypointToTest; dist = distToTest; } } return(closest); }
private static void CreateSplineControllerStick() { string nameStickOffet = "Controller Offset From Other Sticker"; ControllerStick stickReference = null; GameObject stickOffsetGameObject; if (Selection.activeGameObject != null) { stickReference = Selection.activeGameObject.GetComponent <ControllerStick>(); } if (stickReference != null) { stickOffsetGameObject = new GameObject(nameStickOffet); stickOffsetGameObject.transform.SetParent(stickReference.transform.parent); stickOffsetGameObject.transform.SetSiblingIndex(stickReference.transform.GetSiblingIndex() + 1); Undo.RegisterCreatedObjectUndo(stickOffsetGameObject, nameStickOffet); GameObjectUtility.EnsureUniqueNameForSibling(stickOffsetGameObject); } else if (Selection.activeGameObject != null && stickReference == null) { stickOffsetGameObject = Selection.activeGameObject; } else { stickOffsetGameObject = new GameObject(nameStickOffet); GameObjectUtility.EnsureUniqueNameForSibling(stickOffsetGameObject); Undo.RegisterCreatedObjectUndo(stickOffsetGameObject, nameStickOffet); } //GameObject ControllerStickOffset stickOffset = stickOffsetGameObject.AddComponent <ControllerStickOffset>(); Selection.activeGameObject = stickOffsetGameObject; SceneView.lastActiveSceneView.MoveToView(stickOffsetGameObject.transform); ControllerStickOffsetEditor splineEditorGeneric = (ControllerStickOffsetEditor)CreateEditor((ControllerStickOffset)stickOffset, typeof(ControllerStickOffsetEditor)); splineEditorGeneric.ConstructSticker(stickReference); }
public PointsOnSplineExtension.Waypoint GetClosestWaypointBidirectionnal(ControllerStick controller, out float dist, out PointsOnSplineExtension lister) { dist = 0; lister = null; if (ListToCheck.Length == 0) { return(null); } PointsOnSplineExtension.Waypoint closest = ListToCheck[0].GetClosestWaypointBidirectionnal(controller); dist = PointsOnSplineExtension.DistFromWayPoint(closest, controller); lister = ListToCheck[0]; for (int i = 1; i < ListToCheck.Length; i++) { PointsOnSplineExtension.Waypoint waypointToTest = ListToCheck[i].GetClosestWaypointBidirectionnal(controller); float distToTest = PointsOnSplineExtension.DistFromWayPoint(waypointToTest, controller); if (distToTest < dist) { closest = waypointToTest; dist = distToTest; lister = ListToCheck[i]; } } return(closest); }
private void AddStickKeyBinding(ControllerStick stick, Microsoft.Xna.Framework.Vector2 comparisonVector, StickState comparisonState, StickState oldComparisonState, System.Windows.Forms.Keys key, CommandTarget commandTarget, InputMode inputMode) { bindings.AddRange(ControllerInputBinding.createStickKeyBinding(stick, comparisonVector, comparisonState, oldComparisonState, key, inputMode, commandTarget)); }
private void AddStickCursorMoveBinding(ControllerStick stick, Microsoft.Xna.Framework.Vector2 comparisonVector, StickState comparisonState, StickState oldComparisonState, MouseMoveType moveType, UIntVector moveScale, CommandTarget commandTarget, InputMode bindingMode = InputMode.All) { bindings.Add(ControllerInputBinding.createStickCursorMoveBinding(stick, comparisonVector, comparisonState, oldComparisonState, moveType, moveScale, commandTarget, bindingMode)); }