Esempio n. 1
0
        private void DoOptionUI(RotationOptions option, string rotationField, string targetField)
        {
            switch (option)
            {
            case RotationOptions.CurrentRotation:
                break;

            case RotationOptions.WorldRotation:
                EditField(rotationField, "World Rotation");
                break;

            case RotationOptions.LocalRotation:
                EditField(rotationField, "Local Rotation");
                break;

            case RotationOptions.WorldOffsetRotation:
                EditField(rotationField, "World Offset Rotation");
                break;

            case RotationOptions.LocalOffsetRotation:
                EditField(rotationField, "Local Offset Rotation");
                break;

            case RotationOptions.MatchGameObjectRotation:
                EditField(targetField, "GameObject");
                EditField(rotationField, "Local Offset Rotation");
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Esempio n. 2
0
        private static bool CanEditTargetRotation(RotationOptions option, NamedVariable rotation, FsmGameObject target)
        {
            if (target == null)
            {
                return(false);
            }

            switch (option)
            {
            case RotationOptions.CurrentRotation:
                return(false);

            case RotationOptions.WorldRotation:
            case RotationOptions.LocalRotation:
            case RotationOptions.WorldOffsetRotation:
            case RotationOptions.LocalOffsetRotation:
                return(!rotation.IsNone);

            case RotationOptions.MatchGameObjectRotation:
                return(target.Value != null);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Esempio n. 3
0
        private void ShowMainGUI()
        {
            GUILayout.Space(10);

            EditorGUILayout.BeginHorizontal();
            HedraEditor.SetButton("Specific", delegate { rangedOption = false; });
            HedraEditor.SetButton("Ranged", delegate { rangedOption = true; });
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(20);

            targetOption   = (TargetOptions)EditorGUILayout.EnumPopup("Affect: ", targetOption);
            rotationOption = (RotationOptions)EditorGUILayout.EnumPopup("Rotate: ", rotationOption);

            GUILayout.Space(10);

            if (rangedOption)
            {
                ShowRangedGUI();
            }
            else
            {
                ShowSpecificGUI();
            }
        }
Esempio n. 4
0
        public override void Reset()
        {
            base.Reset();

            fromOptions  = RotationOptions.CurrentRotation;
            fromTarget   = null;
            fromRotation = null;
            toOptions    = RotationOptions.WorldRotation;
            toTarget     = null;
            toRotation   = null;
        }
 public static bool GetTargetRotation(RotationOptions option, Transform owner, FsmVector3 rotation,
                                      FsmGameObject target, out Quaternion targetRotation)
 {
     targetRotation = Quaternion.identity;
     if (owner == null || !CanEditTargetRotation(option, rotation, target))
     {
         return(false);
     }
     targetRotation = GetTargetRotation(option, owner,
                                        target.Value != null ? target.Value.transform : null,
                                        rotation.Value);
     return(true);
 }
        /*
         * public static bool GetPosition(PositionOptions options, GameObject go, FsmGameObject target,
         *  FsmVector3 position, out Vector3 finalPos)
         * {
         *  var validPos = false;
         *  finalPos = Vector3.zero;
         *
         *  if (go == null || target == null || position == null)
         *      return false;
         *
         *  switch (options)
         *  {
         *      case PositionOptions.CurrentPosition:
         *          finalPos = go.transform.position;
         *          validPos = true;
         *          break;
         *
         *      case PositionOptions.WorldPosition:
         *          if (!position.IsNone)
         *          {
         *              finalPos = position.Value;
         *              validPos = true;
         *          }
         *      break;
         *
         *      case PositionOptions.GameObject:
         *          if (target.Value != null)
         *          {
         *              finalPos = target.Value.transform.position;
         *              validPos = true;
         *          }
         *          break;
         *
         *      case PositionOptions.GameObjectWithOffset:
         *          if (target != null)
         *          {
         *              finalPos = GetPosition(target, position);
         *              validPos = true;
         *          }
         *          break;
         *
         *
         *
         *      case PositionOptions.WorldOffset:
         *          finalPos = go.transform.position + position.Value;
         *          validPos = true;
         *          break;
         *
         *      case PositionOptions.LocalOffset:
         *          finalPos = go.transform.position + go.transform.InverseTransformPoint(position.Value);
         *          validPos = true;
         *          break;
         *
         *      default:
         *          throw new ArgumentOutOfRangeException();
         *  }
         *
         *  return validPos;
         * }*/

        /// <summary>
        /// Returns a target rotation in world space given the specified parameters
        /// Some parameters are interpreted differently based on RotationOptions selected.
        /// E.g. used by TweenRotation
        /// </summary>
        /// <param name="option">Rotation options exposed to user</param>
        /// <param name="owner">The transform being rotated</param>
        /// <param name="target">A potential target transform</param>
        /// <param name="rotation">A potential target rotation</param>
        /// <returns></returns>
        public static Quaternion GetTargetRotation(RotationOptions option, Transform owner, Transform target, Vector3 rotation)
        {
            if (owner == null)
            {
                return(Quaternion.identity);
            }

            switch (option)
            {
            case RotationOptions.CurrentRotation:
                return(owner.rotation);

            case RotationOptions.WorldRotation:
                return(Quaternion.Euler(rotation));

            case RotationOptions.LocalRotation:
                // same as world rotation if no parent
                if (owner.parent == null)
                {
                    return(Quaternion.Euler(rotation));
                }
                return(owner.parent.rotation * Quaternion.Euler(rotation));

            case RotationOptions.WorldOffsetRotation:
                // same as rotating with global in editor
                return(Quaternion.Euler(rotation) * owner.rotation);

            case RotationOptions.LocalOffsetRotation:
                return(owner.rotation * Quaternion.Euler(rotation));

            case RotationOptions.MatchGameObjectRotation:
                if (target == null)
                {
                    return(owner.rotation);
                }
                return(target.rotation * Quaternion.Euler(rotation));

            default:
                throw new ArgumentOutOfRangeException();
            }

            //return owner.rotation; // leave as is
        }
Esempio n. 7
0
        public BatchExportViewModel(IEnumerable <SingleMouseViewModel> mice)
        {
            Videos = new ObservableCollection <SingleMouseViewModel>(mice);

            ObservableCollection <MovementBehaviourBaseViewModel> movements = new ObservableCollection <MovementBehaviourBaseViewModel>();

            movements.Add(new StillViewModel());
            movements.Add(new WalkingViewModel());
            movements.Add(new RunningViewModel());
            VelocityOptions = movements;

            ObservableCollection <RotationBehaviourBaseViewModel> rotations = new ObservableCollection <RotationBehaviourBaseViewModel>();

            rotations.Add(new NoRotationViewModel());
            rotations.Add(new SlowTurningViewModel());
            rotations.Add(new FastTurningViewModel());
            RotationOptions = rotations;

            SelectedVelocityOption = VelocityOptions.First();
            SelectedRotationOption = RotationOptions.First();
        }
Esempio n. 8
0
        public TPiece(Texture2D texture, Point gridPosition, Color color, Vector2 scale, RotationOptions rotationOption)
            : base(texture, gridPosition, color, scale, rotationOption)
        {
            PieceType = PieceTypes.T;

            Shape = new Dictionary <RotationOptions, int[, ]>()
            {
                [RotationOptions.NoRotation] = new int[, ]
                {
                    { 0, 1, 0 },
                    { 1, 1, 1 },
                    { 0, 0, 0 }
                },
                [RotationOptions.NintyDegrees] = new int[, ]
                {
                    { 0, 1, 0 },
                    { 0, 1, 1 },
                    { 0, 1, 0 }
                },
                [RotationOptions.HundredEightyDegrees] = new int[, ]
                {
                    { 0, 0, 0 },
                    { 1, 1, 1 },
                    { 0, 1, 0 }
                },
                [RotationOptions.TwoHundredSeventyDegrees] = new int[, ]
                {
                    { 0, 1, 0 },
                    { 1, 1, 0 },
                    { 0, 1, 0 }
                }
            };
        }