public void Test_TryGetAbsolute_OK(string pathString, PathMode pathMode) {
         string failureReason;

         var isAbsolute = pathMode == PathMode.Absolute;
         IAbsoluteDirectoryPath absoluteDirectoryPath;
         Assert.IsTrue(pathString.TryGetAbsoluteDirectoryPath(out absoluteDirectoryPath) == isAbsolute);
         Assert.IsTrue(pathString.TryGetAbsoluteDirectoryPath(out absoluteDirectoryPath, out failureReason) == isAbsolute);

         var isRelative = pathMode == PathMode.Relative;
         IRelativeDirectoryPath relativeDirectoryPath;
         Assert.IsTrue(pathString.TryGetRelativeDirectoryPath(out relativeDirectoryPath) == isRelative);
         Assert.IsTrue(pathString.TryGetRelativeDirectoryPath(out relativeDirectoryPath, out failureReason) == isRelative);

         var isEnvVar = pathMode == PathMode.EnvVar;
         IEnvVarDirectoryPath envVarDirectoryPath;
         Assert.IsTrue(pathString.TryGetEnvVarDirectoryPath(out envVarDirectoryPath) == isEnvVar);
         Assert.IsTrue(pathString.TryGetEnvVarDirectoryPath(out envVarDirectoryPath, out failureReason) == isEnvVar);

         var isVariable = pathMode == PathMode.Variable;
         IVariableDirectoryPath variableDirectoryPath;
         Assert.IsTrue(pathString.TryGetVariableDirectoryPath(out variableDirectoryPath) == isVariable);
         Assert.IsTrue(pathString.TryGetVariableDirectoryPath(out variableDirectoryPath, out failureReason) == isVariable);

         IDirectoryPath directoryPath;
         Assert.IsTrue(pathString.TryGetDirectoryPath(out directoryPath));
         Assert.IsTrue(pathString.TryGetDirectoryPath(out directoryPath, out failureReason));


         var pathStringFile = pathString + @"\File.txt";

         IAbsoluteFilePath absoluteFilePath;
         Assert.IsTrue(pathStringFile.TryGetAbsoluteFilePath(out absoluteFilePath) == isAbsolute);
         Assert.IsTrue(pathStringFile.TryGetAbsoluteFilePath(out absoluteFilePath, out failureReason) == isAbsolute);
         Assert.IsFalse(pathString.TryGetAbsoluteFilePath(out absoluteFilePath));
         Assert.IsFalse(pathString.TryGetAbsoluteFilePath(out absoluteFilePath, out failureReason));

         IRelativeFilePath relativeFilePath;
         Assert.IsTrue(pathStringFile.TryGetRelativeFilePath(out relativeFilePath) == isRelative);
         Assert.IsTrue(pathStringFile.TryGetRelativeFilePath(out relativeFilePath, out failureReason) == isRelative);
         Assert.IsFalse(pathString.TryGetRelativeFilePath(out relativeFilePath));
         Assert.IsFalse(pathString.TryGetRelativeFilePath(out relativeFilePath, out failureReason));

         IEnvVarFilePath envVarFilePath;
         Assert.IsTrue(pathStringFile.TryGetEnvVarFilePath(out envVarFilePath) == isEnvVar);
         Assert.IsTrue(pathStringFile.TryGetEnvVarFilePath(out envVarFilePath, out failureReason) == isEnvVar);
         Assert.IsFalse(pathString.TryGetEnvVarFilePath(out envVarFilePath));
         Assert.IsFalse(pathString.TryGetEnvVarFilePath(out envVarFilePath, out failureReason));

         IVariableFilePath variableFilePath;
         Assert.IsTrue(pathStringFile.TryGetVariableFilePath(out variableFilePath) == isVariable);
         Assert.IsTrue(pathStringFile.TryGetVariableFilePath(out variableFilePath, out failureReason) == isVariable);
         Assert.IsFalse(pathString.TryGetVariableFilePath(out variableFilePath));
         Assert.IsFalse(pathString.TryGetVariableFilePath(out variableFilePath, out failureReason));

         IFilePath filePath;
         Assert.IsTrue(pathStringFile.TryGetFilePath(out filePath));
         Assert.IsTrue(pathStringFile.TryGetFilePath(out filePath, out failureReason));
         Assert.IsFalse(pathString.TryGetFilePath(out filePath));
         Assert.IsFalse(pathString.TryGetFilePath(out filePath, out failureReason));
      }
Example #2
0
 public static bool DoesPathHasThisPathMode(BasePath basePath, PathMode pathMode)
 {
     if (basePath == null) {
     throw new ArgumentNullException();
      }
      return (basePath.IsAbsolutePath && pathMode == PathMode.Absolute) ||
         (basePath.IsRelativePath && pathMode == PathMode.Relative);
 }
Example #3
0
        // Extra goodies
        public Tweener DOCircle(int charIndex, float radius, float duration, int pathPoints = 8, PathType pathType = PathType.CatmullRom,
                                PathMode pathMode = PathMode.Full3D, int resolution = 10, Color?gizmoColor = null)
        {
            var tweenPath = new Vector3[pathPoints];

            for (var i = 0; i < tweenPath.Length; ++i)
            {
                var theta = Mathf.Lerp(0, 2 * Mathf.PI, i / (float)(tweenPath.Length - 1));
                tweenPath[i] = new Vector3(radius * Mathf.Cos(theta), radius * Mathf.Sin(theta), 0);
            }

            //The first point of the path is the transform itself
            GetProxyTransform(charIndex).localPosition = tweenPath[0];

            SetPositionOffset(charIndex, tweenPath[0]);
            return(DOLocalPath(charIndex, tweenPath, duration, pathType, pathMode, resolution, gizmoColor, true));
        }
Example #4
0
        public Path(ShareManager shareManager, ILocation start, ILocation end, PathMode pathMode, MacroSync macro)
        {
            this.shareManager = shareManager;
            this.pathMode     = pathMode;
            this.macro        = macro;

            if (pathMode == PathMode.Advanced)
            {
                ZMO.Mine = true;
            }
            else
            {
                ZMO.Mine = false;
            }
            radius = new IRadius(start, end);
            this.shareManager.SetArea(radius);
        }
        /// <summary>
        ///     Tweens a Rigidbody's position through the given path waypoints, using the chosen path algorithm.
        ///     Also stores the Rigidbody as the tween's target so it can be used for filtered operations.
        ///     <para>NOTE: to tween a rigidbody correctly it should be set to kinematic at least while being tweened.</para>
        ///     <para>
        ///         BEWARE: doesn't work on Windows Phone store (waiting for Unity to fix their own bug).
        ///         If you plan to publish there you should use a regular transform.DOPath.
        ///     </para>
        /// </summary>
        /// <param name="path">The waypoints to go through</param>
        /// <param name="duration">The duration of the tween</param>
        /// <param name="pathType">
        ///     The type of path: Linear (straight path), CatmullRom (curved CatmullRom path) or CubicBezier
        ///     (curved with control points)
        /// </param>
        /// <param name="pathMode">The path mode: 3D, side-scroller 2D, top-down 2D</param>
        /// <param name="resolution">
        ///     The resolution of the path (useless in case of Linear paths): higher resolutions make for more detailed curved
        ///     paths but are more expensive.
        ///     Defaults to 10, but a value of 5 is usually enough if you don't have dramatic long curves between waypoints
        /// </param>
        /// <param name="gizmoColor">
        ///     The color of the path (shown when gizmos are active in the Play panel and the tween is
        ///     running)
        /// </param>
        public static TweenerCore <Vector3, Path, PathOptions> DOPath(
            this Rigidbody target, Vector3[] path, float duration, PathType pathType = PathType.Linear,
            PathMode pathMode = PathMode.Full3D, int resolution = 10, Color?gizmoColor = null
            )
        {
            if (resolution < 1)
            {
                resolution = 1;
            }

            TweenerCore <Vector3, Path, PathOptions> t = DOTween.To(PathPlugin.Get(), () => target.position, target.MovePosition, new Path(pathType, path, resolution, gizmoColor), duration)
                                                         .SetTarget(target).SetUpdate(UpdateType.Fixed);

            t.plugOptions.isRigidbody = true;
            t.plugOptions.mode        = pathMode;
            return(t);
        }
Example #6
0
        public Mine(ShareManager shareManager, Mode mode, PathMode pathMode, ushort[] ignore, MacroSync macro)
        {
            this.shareManager = shareManager;
            this.mode         = mode;
            this.pathMode     = pathMode;
            this.ignore       = ignore;
            this.macro        = macro;

            if (pathMode == PathMode.Advanced)
            {
                MO.Mine = true;
            }
            else
            {
                MO.Mine = false;
            }
        }
        public Tweener DOCircle(int charIndex, float radius, float duration, int pathPoints = 8, PathType pathType = PathType.CatmullRom,
                                PathMode pathMode = PathMode.Full3D, int resolution = 10, Color?gizmoColor = null)
        {
            NotifyActiveTransformTween();
            Vector3[] tweenPath = new Vector3[pathPoints + 1];
            Vector3   origin    = Vector3.zero;

            for (int i = 0; i < pathPoints; ++i)
            {
                float theta = Mathf.Lerp(0, 2 * Mathf.PI, i / (float)pathPoints);
                tweenPath[i] = new Vector3(radius * Mathf.Cos(theta), radius * Mathf.Sin(theta), 0) + origin;
            }

            tweenPath[pathPoints] = new Vector3(radius, 0, 0) + origin;
            SetOffsetPosition(charIndex, tweenPath[0]);
            return(DOLocalPath(charIndex, tweenPath, duration, pathType, pathMode, resolution, gizmoColor));
        }
Example #8
0
        public void CopyFrom(TweenParam param)
        {
            Type       = param.Type;
            Identifier = param.Identifier;

            CopyFromToValueFrom(param);

            CurveMode   = param.CurveMode;
            CurveTarget = param.CurveTarget;
            Curve       = param.Curve;
            CurveX      = param.CurveX;
            CurveY      = param.CurveY;
            CurveZ      = param.CurveZ;
            CurveW      = param.CurveW;

            PlayType   = param.PlayType;
            EaseType   = param.EaseType;
            LoopCount  = param.LoopCount;
            Duration   = param.Duration;
            Interval   = param.Interval;
            SpeedBased = param.SpeedBased;
            StartDelay = param.StartDelay;
            AutoPlay   = param.AutoPlay;
            UpdateType = param.UpdateType;
            TimeScale  = param.TimeScale;
            TimeSmooth = param.TimeSmooth;
            SelfScale  = param.SelfScale;
            AutoKill   = param.AutoKill;

            WorldSpace     = param.WorldSpace;
            ColorLerpMode  = param.ColorLerpMode;
            ColorBlockType = param.ColorBlockType;
            PathMode       = param.PathMode;
            ShakeArgs      = param.ShakeArgs;

            ResourcesIndex = param.ResourcesIndex;
            ResourcesKey   = param.ResourcesKey;

            OnPlay         = param.OnPlay;
            OnStop         = param.OnStop;
            OnValueFloat   = param.OnValueFloat;
            OnValueVector2 = param.OnValueVector2;
            OnValueVector3 = param.OnValueVector3;
            OnValueColor   = param.OnValueColor;
        }
        /// <summary>Tweens a Rigidbody's localPosition through the given path waypoints, using the chosen path algorithm.
        /// Also stores the Rigidbody as the tween's target so it can be used for filtered operations
        /// <para>NOTE: to tween a rigidbody correctly it should be set to kinematic at least while being tweened.</para>
        /// <para>BEWARE: doesn't work on Windows Phone store (waiting for Unity to fix their own bug).
        /// If you plan to publish there you should use a regular transform.DOLocalPath.</para></summary>
        /// <param name="path">The waypoint to go through</param>
        /// <param name="duration">The duration of the tween</param>
        /// <param name="pathType">The type of path: Linear (straight path) or CatmullRom (curved CatmullRom path)</param>
        /// <param name="pathMode">The path mode: 3D, side-scroller 2D, top-down 2D</param>
        /// <param name="resolution">The resolution of the path: higher resolutions make for more detailed curved paths but are more expensive.
        /// Defaults to 10, but a value of 5 is usually enough if you don't have dramatic long curves between waypoints</param>
        /// <param name="gizmoColor">The color of the path (shown when gizmos are enabled in the Play panel and the tween is running)</param>
        public static TweenerCore <Vector3, Path, PathOptions> DOLocalPath(
            this Rigidbody target, Vector3[] path, float duration, PathType pathType = PathType.Linear,
            PathMode pathMode = PathMode.Full3D, int resolution = 10, Color?gizmoColor = null
            )
        {
            if (resolution < 1)
            {
                resolution = 1;
            }
            Transform trans = target.transform;
            TweenerCore <Vector3, Path, PathOptions> t = DOTween.To(PathPlugin.Get(), () => trans.localPosition, x => target.MovePosition(trans.parent == null ? x : trans.parent.TransformPoint(x)), new Path(pathType, path, resolution, gizmoColor), duration)
                                                         .SetTarget(target).SetUpdate(UpdateType.Fixed);

            t.plugOptions.isRigidbody      = true;
            t.plugOptions.mode             = pathMode;
            t.plugOptions.useLocalPosition = true;
            return(t);
        }
Example #10
0
        /// <summary>
        /// This will erase all saved files
        /// </summary>
        public void EraseAllSavedData(PathMode pathMode = PathMode.PLAYER)
        {
            if (pathMode == PathMode.PLAYER)
            {
                if (Directory.Exists(automaticPlayerSavedDataDirectoryPath))
                {
                    Directory.Delete(automaticPlayerSavedDataDirectoryPath, true);
                }
            }
            else
            {
                if (Directory.Exists(Application.streamingAssetsPath + "/" + PersistentDataSystemDirectory))
                {
                    Directory.Delete(Application.streamingAssetsPath + "/" + PersistentDataSystemDirectory, true);
                }
            }

            savedDataDictionnary.Clear();
        }
 protected override void JsonTo(JsonData json)
 {
     if (json.Contains("beginPosition"))
     {
         BeginPosition = JTweenUtils.JsonToVector3(json["beginPosition"]);
     }
     // end if
     if (json.Contains("path"))
     {
         JsonData pathJson = json["path"];
         m_toPath = new Vector3[pathJson.Count];
         for (int i = 0, imax = pathJson.Count; i < imax; ++i)
         {
             m_toPath[i] = JTweenUtils.JsonToVector3(pathJson[i]);
         } // end for
     }     // end if
     if (json.Contains("type"))
     {
         m_pathType = (PathType)json["type"].ToInt32();
     }
     // end if
     if (json.Contains("mode"))
     {
         m_pathMode = (PathMode)json["mode"].ToInt32();
     }
     // end if
     if (json.Contains("resolution"))
     {
         m_resolution = json["resolution"].ToInt32();
     }
     // end if
     if (json.Contains("gizmoColor"))
     {
         m_gizmoColor = JTweenUtils.JsonToColor(json["gizmoColor"]);
     }
     // end if
     if (json.Contains("showGizmo"))
     {
         m_showGizmo = json["showGizmo"].ToBool();
     }
     // end if
     Restore();
 }
 protected override void JsonTo(IJsonNode json)
 {
     if (json.Contains("beginPosition"))
     {
         BeginPosition = JTweenUtils.JsonToVector3(json.GetNode("beginPosition"));
     }
     // end if
     if (json.Contains("path"))
     {
         IJsonNode pathJson = json.GetNode("path");
         m_toPath = new Vector3[pathJson.Count];
         for (int i = 0, imax = pathJson.Count; i < imax; ++i)
         {
             m_toPath[i] = JTweenUtils.JsonToVector3(pathJson[i]);
         } // end for
     }     // end if
     if (json.Contains("type"))
     {
         m_pathType = (PathType)json.GetInt("type");
     }
     // end if
     if (json.Contains("mode"))
     {
         m_pathMode = (PathMode)json.GetInt("mode");
     }
     // end if
     if (json.Contains("resolution"))
     {
         m_resolution = json.GetInt("resolution");
     }
     // end if
     if (json.Contains("gizmoColor"))
     {
         m_gizmoColor = JTweenUtils.JsonToColor(json.GetNode("gizmoColor"));
     }
     // end if
     if (json.Contains("showGizmo"))
     {
         m_showGizmo = json.GetBool("showGizmo");
     }
     // end if
     Restore();
 }
        // Override for UGUI
        public Tweener DOCircleUGUI(Camera viewCamera, int charIndex, float radius, float duration, int pathPoints = 8, PathType pathType = PathType.CatmullRom,
                                    PathMode pathMode = PathMode.Full3D, int resolution = 10, Color?gizmoColor = null)
        {
            RectTransform rectTransform = GetComponent <RectTransform>();

            var tweenPath = new Vector3[pathPoints + 1];

            for (var i = 0; i < tweenPath.Length; ++i)
            {
                var theta = Mathf.Lerp(0, 2 * Mathf.PI, i / (float)(tweenPath.Length - 1));

                Vector3 charWorldPosition = viewCamera.WorldToScreenPoint(transform.position);;
                Vector3 worldPosition;

                RectTransformUtility.ScreenPointToWorldPointInRectangle(rectTransform, new Vector3(radius * Mathf.Cos(theta) + charWorldPosition.x, radius * Mathf.Sin(theta) + charWorldPosition.y, 0), viewCamera, out worldPosition);
                tweenPath[i] = worldPosition;
            }

            SetPositionOffset(charIndex, tweenPath[0]);
            return(DOPath(charIndex, tweenPath, duration, pathType, pathMode, resolution, gizmoColor));
        }
Example #14
0
        /// <summary>
        /// Return a T type in the persistent data dictionnary.
        /// If T type is not present in the dictionnary, this function will try to load saved files.
        /// Load saved file work only for multiple file system.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="maxNumber"></param>
        /// <returns></returns>
        public List <T> GetAllSavedData <T>(int maxNumber = int.MaxValue, PathMode pathMode = PathMode.PLAYER) where T : SavedData, new()
        {
            List <SavedData> savedDataList;

            savedDataDictionnary.TryGetValue(typeof(T), out savedDataList);

            if (savedDataList != null)
            {
                return(savedDataList as List <T>);
            }
            //This data is not in the dictionnary
            else
            {
                //It's not in the dictionnary, so if use multiple file LoadIt with the file
                if (saveMode == SaveMode.MULTIPLE_FILE)
                {
                    return(LoadAllSavedData <T>(maxNumber, pathMode));
                }
            }

            return(new List <T>());
        }
Example #15
0
        public static string GetCygpath(string path, PathMode target)
        {
            string convertedPath;

            if (!CygpathCache.ContainsKey(target))
            {
                CygpathCache[target] = new Dictionary <string, string>();
            }

            if (!CygpathCache[target].TryGetValue(path, out convertedPath))
            {
                lock (CygpathProcesses)
                {
                    Process process;
                    if (!CygpathProcesses.TryGetValue(target, out process) || process.HasExited)
                    {
                        var targetArgument = target == PathMode.Windows ? "-w"
                                           : target == PathMode.Unix ? "-u"
                                           : target == PathMode.Cygwin ? "-u"
                                           : string.Empty;
                        var processStartInfo = new ProcessStartInfo("cygpath", "-f - " + targetArgument)
                        {
                            CreateNoWindow         = true,
                            UseShellExecute        = false,
                            RedirectStandardInput  = true,
                            RedirectStandardOutput = true,
                        };

                        process = CygpathProcesses[target] = Process.Start(processStartInfo);
                    }

                    process.StandardInput.WriteLine(path);
                    convertedPath = process.StandardOutput.ReadLine();
                }
            }

            return(convertedPath);
        }
Example #16
0
        public static string GetCygpath(string path, PathMode target)
        {
            string convertedPath;

            if (!CygpathCache.ContainsKey(target))
            {
                CygpathCache[target] = new Dictionary<string,string>();
            }

            if (!CygpathCache[target].TryGetValue(path, out convertedPath))
            {
                lock (CygpathProcesses)
                {
                    Process process;
                    if (!CygpathProcesses.TryGetValue(target, out process) || process.HasExited)
                    {
                        var targetArgument = target == PathMode.Windows ? "-w"
                                           : target == PathMode.Unix ? "-u"
                                           : target == PathMode.Cygwin ? "-u"
                                           : string.Empty;
                        var processStartInfo = new ProcessStartInfo("cygpath", "-f - "+targetArgument)
                        {
                            CreateNoWindow = true,
                            UseShellExecute = false,
                            RedirectStandardInput = true,
                            RedirectStandardOutput = true,
                        };

                        process = CygpathProcesses[target] = Process.Start(processStartInfo);
                    }

                    process.StandardInput.WriteLine(path);
                    convertedPath = process.StandardOutput.ReadLine();
                }
            }

            return convertedPath;
        }
        /// <summary>Tweens a Rigidbody2D's position through the given path waypoints, using the chosen path algorithm.
        /// Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations.
        /// <para>NOTE: to tween a Rigidbody2D correctly it should be set to kinematic at least while being tweened.</para>
        /// <para>BEWARE: doesn't work on Windows Phone store (waiting for Unity to fix their own bug).
        /// If you plan to publish there you should use a regular transform.DOPath.</para></summary>
        /// <param name="path">The waypoints to go through</param>
        /// <param name="duration">The duration of the tween</param>
        /// <param name="pathType">The type of path: Linear (straight path), CatmullRom (curved CatmullRom path) or CubicBezier (curved with control points)</param>
        /// <param name="pathMode">The path mode: 3D, side-scroller 2D, top-down 2D</param>
        /// <param name="resolution">The resolution of the path (useless in case of Linear paths): higher resolutions make for more detailed curved paths but are more expensive.
        /// Defaults to 10, but a value of 5 is usually enough if you don't have dramatic long curves between waypoints</param>
        /// <param name="gizmoColor">The color of the path (shown when gizmos are active in the Play panel and the tween is running)</param>
        public static TweenerCore <Vector3, Path, PathOptions> DOPath(
            this Rigidbody2D target, Vector2[] path, float duration, PathType pathType = PathType.Linear,
            PathMode pathMode = PathMode.Full3D, int resolution = 10, Color?gizmoColor = null
            )
        {
            if (resolution < 1)
            {
                resolution = 1;
            }
            int len = path.Length;

            Vector3[] path3D = new Vector3[len];
            for (int i = 0; i < len; ++i)
            {
                path3D[i] = path[i];
            }
            TweenerCore <Vector3, Path, PathOptions> t = DOTween.To(PathPlugin.Get(), () => target.position, x => target.MovePosition(x), new Path(pathType, path3D, resolution, gizmoColor), duration)
                                                         .SetTarget(target).SetUpdate(UpdateType.Fixed);

            t.plugOptions.isRigidbody = true;
            t.plugOptions.mode        = pathMode;
            return(t);
        }
Example #18
0
        public override void Reset()
        {
            base.Reset();

            gameObject = null;

            duration = new FsmFloat {
                UseVariable = false
            };
            setSpeedBased = new FsmBool {
                UseVariable = false, Value = false
            };
            pathType   = PathType.Linear;
            pathMode   = PathMode.Full3D;
            resolution = new FsmInt {
                UseVariable = false, Value = 10
            };
            gizmoColor = new FsmColor {
                UseVariable = false
            };

            closePath = new FsmBool {
                UseVariable = false, Value = false
            };
            lockPosition = AxisConstraint.None;
            lockRotation = AxisConstraint.None;

            lookAt         = LookAt.nothing;
            lookAtPosition = new FsmVector3 {
                UseVariable = false, Value = Vector3.zero
            };
            lookAtTarget = new FsmGameObject {
                UseVariable = false, Value = null
            };
            lookAhead = new FsmFloat {
                UseVariable = false, Value = 0
            };

            forwardDirection = new FsmVector3 {
                UseVariable = false, Value = Vector3.forward
            };
            up = new FsmVector3 {
                UseVariable = false, Value = Vector3.up
            };

            startEvent        = null;
            finishEvent       = null;
            finishImmediately = new FsmBool {
                UseVariable = false, Value = false
            };

            startDelay = new FsmFloat {
                Value = 0
            };
            easeType = Ease.Linear;

            loops = new FsmInt {
                Value = 0
            };
            loopType = LoopType.Restart;

            autoKillOnCompletion = new FsmBool {
                Value = true
            };
            recyclable = new FsmBool {
                Value = false
            };

            updateType          = UpdateType.Normal;
            isIndependentUpdate = new FsmBool {
                Value = false
            };

            debugThis = new FsmBool {
                Value = false
            };
        }
 public static T SetPathMode <T, TComponent>(this T tween, PathMode pathMode) where T : TweenQueueVector3Base <TComponent> where TComponent : Component
 {
     tween.PathMode = pathMode;
     return(tween);
 }
Example #20
0
        public void Test_TryGetAbsolute_OK(string pathString, PathMode pathMode)
        {
            string failureReason;

            var isAbsolute = pathMode == PathMode.Absolute;
            IAbsoluteDirectoryPath absoluteDirectoryPath;

            Assert.IsTrue(pathString.TryGetAbsoluteDirectoryPath(out absoluteDirectoryPath) == isAbsolute);
            Assert.IsTrue(pathString.TryGetAbsoluteDirectoryPath(out absoluteDirectoryPath, out failureReason) == isAbsolute);

            var isRelative = pathMode == PathMode.Relative;
            IRelativeDirectoryPath relativeDirectoryPath;

            Assert.IsTrue(pathString.TryGetRelativeDirectoryPath(out relativeDirectoryPath) == isRelative);
            Assert.IsTrue(pathString.TryGetRelativeDirectoryPath(out relativeDirectoryPath, out failureReason) == isRelative);

            var isEnvVar = pathMode == PathMode.EnvVar;
            IEnvVarDirectoryPath envVarDirectoryPath;

            Assert.IsTrue(pathString.TryGetEnvVarDirectoryPath(out envVarDirectoryPath) == isEnvVar);
            Assert.IsTrue(pathString.TryGetEnvVarDirectoryPath(out envVarDirectoryPath, out failureReason) == isEnvVar);

            var isVariable = pathMode == PathMode.Variable;
            IVariableDirectoryPath variableDirectoryPath;

            Assert.IsTrue(pathString.TryGetVariableDirectoryPath(out variableDirectoryPath) == isVariable);
            Assert.IsTrue(pathString.TryGetVariableDirectoryPath(out variableDirectoryPath, out failureReason) == isVariable);

            IDirectoryPath directoryPath;

            Assert.IsTrue(pathString.TryGetDirectoryPath(out directoryPath));
            Assert.IsTrue(pathString.TryGetDirectoryPath(out directoryPath, out failureReason));

            var pathStringFile = pathString + @"\File.txt";

            IAbsoluteFilePath absoluteFilePath;

            Assert.IsTrue(pathStringFile.TryGetAbsoluteFilePath(out absoluteFilePath) == isAbsolute);
            Assert.IsTrue(pathStringFile.TryGetAbsoluteFilePath(out absoluteFilePath, out failureReason) == isAbsolute);
            Assert.IsFalse(pathString.TryGetAbsoluteFilePath(out absoluteFilePath));
            Assert.IsFalse(pathString.TryGetAbsoluteFilePath(out absoluteFilePath, out failureReason));

            IRelativeFilePath relativeFilePath;

            Assert.IsTrue(pathStringFile.TryGetRelativeFilePath(out relativeFilePath) == isRelative);
            Assert.IsTrue(pathStringFile.TryGetRelativeFilePath(out relativeFilePath, out failureReason) == isRelative);
            Assert.IsFalse(pathString.TryGetRelativeFilePath(out relativeFilePath));
            Assert.IsFalse(pathString.TryGetRelativeFilePath(out relativeFilePath, out failureReason));

            IEnvVarFilePath envVarFilePath;

            Assert.IsTrue(pathStringFile.TryGetEnvVarFilePath(out envVarFilePath) == isEnvVar);
            Assert.IsTrue(pathStringFile.TryGetEnvVarFilePath(out envVarFilePath, out failureReason) == isEnvVar);
            Assert.IsFalse(pathString.TryGetEnvVarFilePath(out envVarFilePath));
            Assert.IsFalse(pathString.TryGetEnvVarFilePath(out envVarFilePath, out failureReason));

            IVariableFilePath variableFilePath;

            Assert.IsTrue(pathStringFile.TryGetVariableFilePath(out variableFilePath) == isVariable);
            Assert.IsTrue(pathStringFile.TryGetVariableFilePath(out variableFilePath, out failureReason) == isVariable);
            Assert.IsFalse(pathString.TryGetVariableFilePath(out variableFilePath));
            Assert.IsFalse(pathString.TryGetVariableFilePath(out variableFilePath, out failureReason));

            IFilePath filePath;

            Assert.IsTrue(pathStringFile.TryGetFilePath(out filePath));
            Assert.IsTrue(pathStringFile.TryGetFilePath(out filePath, out failureReason));
            Assert.IsFalse(pathString.TryGetFilePath(out filePath));
            Assert.IsFalse(pathString.TryGetFilePath(out filePath, out failureReason));
        }
Example #21
0
 public Tweener DOLocalPath(int charIndex, Vector3[] path, float duration, PathType pathType = PathType.Linear,
                            PathMode pathMode = PathMode.Full3D, int resolution = 10, Color?gizmoColor = null, bool closePath = false)
 {
     return(MonitorTransformTween(GetProxyTransform(charIndex).DOLocalPath(path, duration, pathType, pathMode, resolution, gizmoColor).SetOptions(closePath)));
 }
Example #22
0
        private static GraphicsPath GetEllipsePath(Rectangle rect, int r, int reflectionHeight, PathMode mode, RoundedCorners corners)
        {
            GraphicsPath path = new GraphicsPath();
            switch (mode)
            {
                case PathMode.All:
                    path.AddEllipse(rect);
                    break;

                case PathMode.Top:
                    path.AddArc(rect, 180, 180);
                    break;

                case PathMode.Bottom:
                    path.AddArc(rect, 0, 180);
                    break;
            }

            path.CloseFigure();

            return path;
        }
            public static TweenerCore <Vector3, Path, PathOptions> CreateDOTweenPathTween(MonoBehaviour target, bool tweenRigidbody, bool isLocal, Path path, float duration, PathMode pathMode)
            {
                Rigidbody rigidbody = (!tweenRigidbody) ? null : target.GetComponent <Rigidbody>();

                if (tweenRigidbody && rigidbody != null)
                {
                    return((!isLocal) ? rigidbody.DOPath(path, duration, pathMode) : rigidbody.DOLocalPath(path, duration, pathMode));
                }
                return((!isLocal) ? target.transform.DOPath(path, duration, pathMode) : target.transform.DOLocalPath(path, duration, pathMode));
            }
Example #24
0
        internal static TweenerCore <Vector3, Path, PathOptions> DOLocalPath(this Rigidbody target, Path path, float duration, PathMode pathMode = PathMode.Full3D)
        {
            Transform trans = target.transform;
            TweenerCore <Vector3, Path, PathOptions> tweenerCore = DOTween.To(PathPlugin.Get(), () => trans.localPosition, delegate(Vector3 x)
            {
                target.MovePosition((!(trans.parent == null)) ? trans.parent.TransformPoint(x) : x);
            }, path, duration).SetTarget(target);

            tweenerCore.plugOptions.isRigidbody      = true;
            tweenerCore.plugOptions.mode             = pathMode;
            tweenerCore.plugOptions.useLocalPosition = true;
            return(tweenerCore);
        }
 public void Test_PathModeOk(string pathString, PathMode pathMode) {
    IDirectoryPath path = pathString.ToDirectoryPath();
    Assert.IsFalse(path.IsFilePath);
    Assert.IsTrue(path.IsDirectoryPath);
    Assert.IsTrue(path.PathMode == pathMode);
    Assert.IsTrue(path.IsAbsolutePath == (pathMode == PathMode.Absolute));
    Assert.IsTrue(path.IsRelativePath == (pathMode == PathMode.Relative));
    Assert.IsTrue(path.IsVariablePath == (pathMode == PathMode.Variable));
    Assert.IsTrue(path.IsEnvVarPath == (pathMode == PathMode.EnvVar));
 }
Example #26
0
        /// <summary>Tweens a Transform's localPosition through the given path waypoints, using the chosen path algorithm.
        /// Also stores the transform as the tween's target so it can be used for filtered operations</summary>
        /// <param name="path">The waypoint to go through</param>
        /// <param name="duration">The duration of the tween</param>
        /// <param name="pathType">The type of path: Linear (straight path) or CatmullRom (curved CatmullRom path)</param>
        /// <param name="pathMode">The path mode: 3D, side-scroller 2D, top-down 2D</param>
        /// <param name="resolution">The resolution of the path: higher resolutions make for more detailed curved paths but are more expensive.
        /// Defaults to 10, but a value of 5 is usually enough if you don't have dramatic long curves between waypoints</param>
        /// <param name="gizmoColor">The color of the path (shown when gizmos are active in the Play panel and the tween is running)</param>
        public static TweenerCore<Vector3, Path, PathOptions> DOLocalPath(
            this Transform target, Vector3[] path, float duration, PathType pathType = PathType.Linear,
            PathMode pathMode = PathMode.Full3D, int resolution = 10, Color? gizmoColor = null
        )
        {
            if (resolution < 1) resolution = 1;
            TweenerCore<Vector3, Path, PathOptions> t = DOTween.To(PathPlugin.Get(), () => target.localPosition, x => target.localPosition = x, new Path(pathType, path, resolution, gizmoColor), duration)
                .SetTarget(target);

            t.plugOptions.mode = pathMode;
            return t;
        }
Example #27
0
        /// <summary>
        /// Initializes the configuration subsystem.
        /// </summary>
        /// <param name="producer"></param>
        /// <param name="product"></param>
        /// <param name="pathMode"></param>
        /// <param name="configurationRoot"></param>
        /// <returns>true if initilized, false if aborted as it already was initialized</returns>
        public static Boolean Initialize(
            String producer          = null,
            String product           = null,
            PathMode pathMode        = PathMode.Simple,
            String configurationRoot = null
            )
        {
            // First: check for redundant call. This is a one off only.
            var repeated = Interlocked.Exchange(ref _isInitialized, 1);

            if (repeated != 0)
            {
                return(false);
            }

            // Next: we generate the container name out of producer and product.

            var builder = new StringBuilder();

            if (!String.IsNullOrWhiteSpace(producer))
            {
                builder.Append(producer.Trim()).Append(".");
            }
            if (!String.IsNullOrWhiteSpace(product))
            {
                switch (pathMode)
                {
                case PathMode.Simple:
                    builder.Append(product.Trim()).Append(".");
                    break;
                }
            }
            if (builder.Length > 1)
            {
                builder.Length -= 1;
            }
            if (builder.Length == 0)
            {
                throw new ArgumentException("producer or product must be set");
            }
            Container = builder.ToString();

            // Next: Product
            if (!String.IsNullOrWhiteSpace(product))
            {
                switch (pathMode)
                {
                case PathMode.Prefix:
                    Product = product;
                    break;
                }
            }

            // Next: find the root folder where the configuration is stored. This is named by the Container
            // variable. It can be in various places, including explicit pointing us to some - so we need to search.

            // If we have a container explicit, we use that one.
            if (!String.IsNullOrWhiteSpace(configurationRoot))
            {
                ConfigurationRoot = configurationRoot;
            }
            ConfigurationRoot = Path.GetFullPath(GetConfigurationRoot());

            // Now, the variant.
            Variant = GetVariant();
            return(true);
        }
Example #28
0
        private static GraphicsPath GetNextPath(Rectangle rect, int r, int reflectionHeight, PathMode mode, RoundedCorners corners)
        {
            GraphicsPath path = new GraphicsPath();
            int x = rect.X, y = rect.Y, w = rect.Width, h = rect.Height;
            int h2 = rect.Height / 2;
            int offset = (h - h2 * 2);
            int r2 = r / 2;

            if (mode != PathMode.Bottom)
            {
                path.AddArc(x, y, r, r, 180, 90);
                path.AddArc(x + w - h2 - r2, y, r, r, 270, 45);
                path.AddArc(x + w - r, y + h2 - r2, r, r, 270 + 45, 45);
            }
            RectangleF gr = new RectangleF(x, y + r, w, h - r);

            if (mode != PathMode.All)
            {
                Point pt1 = new Point(x + w, y + h2);
                Point pt2 = new Point(x, y + h2);
                if (mode == PathMode.Top)
                {
                    path.AddLine(pt1, pt2);
                }
                else
                {
                    path.AddLine(pt2, pt1);
                }
            }
            if (mode != PathMode.Top)
            {
                path.AddArc(x + w - r, y + h2 - r2, r, r, 0, 45);
                path.AddArc(x + w - h2 - r2 + offset, y + h - r, r, r, 45, 45);
                path.AddArc(x, y + h - r, r, r, 90, 90);
            }

            path.CloseFigure();
            return path;
        }
Example #29
0
        /// <summary>
        /// Load saved data of the specified type, if no such file exist, one saved data will be Init.
        /// </summary>
        /// <param name="type"></param>
        /// <returns>null is used with single file system<</returns>
        SavedData LoadSavedData(Type type, PathMode pathMode = PathMode.PLAYER)
        {
            if (saveMode == SaveMode.SINGLE_FILE)
            {
                return(null);
            }

            SavedData savedData = null;

            ClearSavedDataList(type);

            try
            {
                string dataPath;

                if (pathMode == PathMode.PLAYER)
                {
                    dataPath = System.IO.Path.Combine(System.IO.Path.Combine(multiplePlayerFilesDirectoryPath, type.Name), "0");
                }
                else
                {
                    dataPath = System.IO.Path.Combine(System.IO.Path.Combine(multipleDefaultFilesDirectoryPath, type.Name), "0");
                }

                if (type.GetInterface(typeof(IFullSerializationControl).Name) != null)
                {
                    dataPath += ControlledSerializationFileExtension;
                }
                else
                {
                    dataPath += AutomaticSerializationFileExtension;
                }


                savedData = LoadSavedData(dataPath, 0, pathMode == PathMode.DEFAULT);

                if (savedData == null)
                {
                    throw new System.ArgumentException("No data of this type or incompatible version");
                }
                else if (pathMode == PathMode.DEFAULT)
                {
                    savedData.OnDefaultDataLoaded();
                }
            }
            catch
            {
#if DEBUG || UNITY_EDITOR
                Debug.Log("Load save at path: " + pathMode);
#endif

                if (pathMode == PathMode.PLAYER)
                {
                    return(LoadSavedData(type, PathMode.DEFAULT));
                }

#if DEBUG || UNITY_EDITOR
                Debug.Log("New instance of " + type + " loaded");
#endif

                savedData             = Activator.CreateInstance(type) as SavedData;
                savedData.dataVersion = dataVersion;
                savedData.timestamp   = 0;
                savedData.OnDataCreated(dataVersion);

                AddSavedDataToDictionnary(savedData, -1);

                if (OnDataLoaded != null)
                {
                    OnDataLoaded(this, savedData);
                }
            }

            return(savedData);
        }
Example #30
0
        /// <summary>
        /// Load all the saved data in the persistentDataSystem directory.
        /// </summary>
        public List <SavedData> LoadAllSavedData(PathMode pathMode = PathMode.PLAYER)
        {
            List <SavedData> savedDataList = new List <SavedData>();

            //The directory does not exist, return immediatly
            if ((saveMode == SaveMode.SINGLE_FILE && !Directory.Exists(pathMode == PathMode.DEFAULT ? singleDefaultFileDirectoryPath : singlePlayerFileDirectoryPath)) ||
                (saveMode == SaveMode.MULTIPLE_FILE && !Directory.Exists(pathMode == PathMode.DEFAULT ? multipleDefaultFilesDirectoryPath : multiplePlayerFilesDirectoryPath)))
            {
                return(savedDataList);
            }

            savedDataDictionnary.Clear();

            if (saveMode == SaveMode.MULTIPLE_FILE)
            {
                string[] directories;

                if (pathMode == PathMode.PLAYER)
                {
                    directories = Directory.GetDirectories(multiplePlayerFilesDirectoryPath);
                }
                else
                {
                    directories = Directory.GetDirectories(multipleDefaultFilesDirectoryPath);
                }

                for (int i = 0; i < directories.Length; i++)
                {
                    string[] files = Directory.GetFiles(directories[i], "*", SearchOption.AllDirectories);

                    for (int j = 0; j < files.Length; j++)
                    {
                        SavedData s = LoadSavedData(files[j], j, pathMode == PathMode.DEFAULT);

                        if (s != null)
                        {
                            savedDataList.Add(s);

                            if (OnDataLoaded != null)
                            {
                                OnDataLoaded(this, s);
                            }
                        }
                    }
                }
            }
            else
            {
                try
                {
                    string dataPath;

                    if (pathMode == PathMode.PLAYER)
                    {
                        dataPath = singlePlayerFileDirectoryPath + SingleFileName + AutomaticSerializationFileExtension;
                    }
                    else
                    {
                        dataPath = singleDefaultFileDirectoryPath + SingleFileName + AutomaticSerializationFileExtension;
                    }

                    BinaryFormatter bf = new BinaryFormatter();
                    using (FileStream fs = File.Open(dataPath, FileMode.Open, FileAccess.Read))
                    {
                        savedDataDictionnary = (Dictionary <Type, List <SavedData> >)bf.Deserialize(fs);
                        fs.Close();
                    }

                    //If version is different, reinit with default file
                    for (int i = 0; i < savedDataList.Count; i++)
                    {
                        if (!CheckDataversion(dataVersion, savedDataList[i]))
                        {
                            if (pathMode == PathMode.PLAYER)
                            {
                                return(LoadAllSavedData(PathMode.DEFAULT));
                            }
                            else
                            {
                                return(new List <SavedData>()); //Considere Data are all outdated
                            }
                        }

                        savedDataList.Add(savedDataList[i]);
                    }
                }
                catch
                {
#if DEBUG || UNITY_EDITOR
                    Debug.LogWarning("Unable to load persistent data");
#endif
                }
            }

            return(savedDataList);
        }
Example #31
0
        private static GraphicsPath GetRoundPath(Rectangle rect, int r, int reflectionHeight, PathMode mode, RoundedCorners corners)
        {
            GraphicsPath path = new GraphicsPath();
            int x = rect.X, y = rect.Y, w = rect.Width, h = rect.Height;

            if (mode != PathMode.Bottom)
            {
                if ((corners & RoundedCorners.TopLeft) != 0) path.AddArc(x, y, r, r, 180, 90); else path.AddLine(x, y, x + r, y);
                if ((corners & RoundedCorners.TopRight) != 0) path.AddArc(x + w - r, y, r, r, 270, 90); else path.AddLine(x + w - r, y, x + w, y);
            }
            RectangleF gr = new RectangleF(x, y + r, w, h - r);

            if (mode != PathMode.All)
            {
                Point pt1 = new Point(x + w, y + reflectionHeight);
                Point pt2 = new Point(x, y + reflectionHeight);
                if (mode == PathMode.Top)
                {
                    path.AddLine(pt1, pt2);
                }
                else
                {
                    //pt1.Y--;
                    //pt2.Y--;
                    path.AddLine(pt2, pt1);
                }
            }
            if (mode != PathMode.Top)
            {
                if ((corners & RoundedCorners.BottomRight) != 0) path.AddArc(x + w - r, y + h - r, r, r, 0, 90); else path.AddLine(x + w, y + h, x + w - r, y + h);
                if ((corners & RoundedCorners.BottomLeft) != 0) path.AddArc(x, y + h - r, r, r, 90, 90); else path.AddLine(x + r, y + h, x, y + h);
            }

            path.CloseFigure();
            return path;
        }
Example #32
0
        private static GraphicsPath GetRectPath(Rectangle rect, int r, int reflectionHeight, PathMode mode, RoundedCorners corners)
        {
            switch (mode)
            {
                case PathMode.Top:
                    rect.Height = reflectionHeight;
                    break;

                case PathMode.Bottom:
                    rect.Height = rect.Height - reflectionHeight;
                    rect.Y += reflectionHeight;
                    break;

            }

            GraphicsPath path = new GraphicsPath();
            path.AddRectangle(rect);
            //            path.CloseFigure();
            return path;
        }
Example #33
0
        internal static TweenerCore <Vector3, Path, PathOptions> DOPath(this Rigidbody target, Path path, float duration, PathMode pathMode = PathMode.Full3D)
        {
            TweenerCore <Vector3, Path, PathOptions> tweenerCore = DOTween.To(PathPlugin.Get(), () => target.position, target.MovePosition, path, duration).SetTarget(target);

            tweenerCore.plugOptions.isRigidbody = true;
            tweenerCore.plugOptions.mode        = pathMode;
            return(tweenerCore);
        }
            // Called via Reflection by DOTweenPath
            public static TweenerCore <Vector3, Path, PathOptions> CreateDOTweenPathTween(
                MonoBehaviour target, bool tweenRigidbody, bool isLocal, Path path, float duration, PathMode pathMode
                )
            {
                TweenerCore <Vector3, Path, PathOptions> t;

#if true // PHYSICS_MARKER
                Rigidbody rBody = tweenRigidbody ? target.GetComponent <Rigidbody>() : null;
                if (tweenRigidbody && rBody != null)
                {
                    t = isLocal
                        ? rBody.DOLocalPath(path, duration, pathMode)
                        : rBody.DOPath(path, duration, pathMode);
                }
                else
                {
                    t = isLocal
                        ? target.transform.DOLocalPath(path, duration, pathMode)
                        : target.transform.DOPath(path, duration, pathMode);
                }
#else
                t = isLocal
                    ? target.transform.DOLocalPath(path, duration, pathMode)
                    : target.transform.DOPath(path, duration, pathMode);
#endif
                return(t);
            }
Example #35
0
        /// <summary>
        /// Load all saved data of the type. If no savedData of this type exist, this will NOT create a new one.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="maxNumber"></param>
        /// <returns></returns>
        public List <T> LoadAllSavedData <T>(int maxNumber = int.MaxValue, PathMode pathMode = PathMode.PLAYER) where T : SavedData
        {
            if (saveMode == SaveMode.SINGLE_FILE)
            {
                return(null);
            }

            List <T>  savedDataList = new List <T>();
            SavedData savedData     = null;
            Type      type          = typeof(T);

            ClearSavedDataList(type);

            for (int i = 0; i < maxNumber; i++)
            {
                try
                {
                    string playerDataPath;
                    string defaultDataPath;

                    playerDataPath  = System.IO.Path.Combine(System.IO.Path.Combine(multiplePlayerFilesDirectoryPath, type.Name), i.ToString());
                    defaultDataPath = System.IO.Path.Combine(System.IO.Path.Combine(multipleDefaultFilesDirectoryPath, type.Name), i.ToString());

                    if (type.GetInterface(typeof(IFullSerializationControl).Name) != null)
                    {
                        playerDataPath  += ControlledSerializationFileExtension;
                        defaultDataPath += ControlledSerializationFileExtension;
                    }
                    else
                    {
                        playerDataPath  += AutomaticSerializationFileExtension;
                        defaultDataPath += AutomaticSerializationFileExtension;
                    }

                    if (pathMode == PathMode.PLAYER)
                    {
                        savedData = LoadSavedData(playerDataPath, i, false);
                    }
                    else
                    {
                        savedData = LoadSavedData(defaultDataPath, i, true);
                    }

                    //If player data are not present or version is not the same, try with default
                    if (savedData == null && pathMode == PathMode.PLAYER)
                    {
                        savedData = LoadSavedData(defaultDataPath, i, false);
                    }

                    if (savedData != null)
                    {
                        savedDataList.Add((T)savedData);
                    }
                    else
                    {
                        break;
                    }
                }
                catch
                {
                    break;
                }
            }

            return(savedDataList);
        }
 public void Test_DoesPathHasThisPathMode(string str, PathMode pathMode) {
    Assert.IsTrue(str.ToDirectoryPath().PathMode == pathMode);
    Assert.IsTrue(str.ToFilePath().PathMode == pathMode);
 }
Example #37
0
        internal static TweenerCore<Vector3, Path, PathOptions> DOLocalPath(
            this Transform target, Path path, float duration, PathMode pathMode = PathMode.Full3D
        )
        {
            TweenerCore<Vector3, Path, PathOptions> t = DOTween.To(PathPlugin.Get(), () => target.localPosition, x => target.localPosition = x, path, duration)
                .SetTarget(target);

            t.plugOptions.mode = pathMode;
            return t;
        }
Example #38
0
        /// <summary>
        /// Save all data in the PersistentDataSystem dictionnary
        /// </summary>
        public void SaveAllData(PathMode pathMode = PathMode.PLAYER)
        {
            foreach (List <SavedData> sdList in savedDataDictionnary.Values)
            {
                foreach (SavedData sd in sdList)
                {
                    if (OnBeginDataSaving != null)
                    {
                        OnBeginDataSaving(this, sd);
                    }
                }
            }

            if (saveMode == SaveMode.SINGLE_FILE)
            {
                string dataPath;

                if (pathMode == PathMode.PLAYER)
                {
                    dataPath = singlePlayerFileDirectoryPath;
                }
                else
                {
                    dataPath = singleDefaultFileDirectoryPath;
                }

                if (!Directory.Exists(dataPath))
                {
                    Directory.CreateDirectory(dataPath);
                }

                dataPath += SingleFileName + AutomaticSerializationFileExtension;

                BinaryFormatter bf = new BinaryFormatter();
                using (FileStream fs = File.Create(dataPath))
                {
                    bf.Serialize(fs, savedDataDictionnary);
                    fs.Close();
                }

                foreach (List <SavedData> sdList in savedDataDictionnary.Values)
                {
                    foreach (SavedData sd in sdList)
                    {
                        sd.filePath   = dataPath;
                        sd.fileNumber = 0;
                        OnDataSaved?.Invoke(this, sd);
                    }
                }
            }
            else
            {
                foreach (List <SavedData> sdList in savedDataDictionnary.Values)
                {
                    foreach (SavedData sd in sdList)
                    {
                        SaveData(sd, pathMode);
                    }
                }
            }
        }
            public static TweenerCore <Vector3, Path, PathOptions> CreateDOTweenPathTween(
                MonoBehaviour target, bool tweenRigidbody, bool isLocal, Path path, float duration, PathMode pathMode
                )
            {
                TweenerCore <Vector3, Path, PathOptions> t = null;
                bool rBodyFoundAndTweened = false;

#if true // PHYSICS_MARKER
                if (tweenRigidbody)
                {
                    Rigidbody rBody = target.GetComponent <Rigidbody>();
                    if (rBody != null)
                    {
                        rBodyFoundAndTweened = true;
                        t = isLocal
                            ? rBody.DOLocalPath(path, duration, pathMode)
                            : rBody.DOPath(path, duration, pathMode);
                    }
                }
#endif
#if true // PHYSICS2D_MARKER
                if (!rBodyFoundAndTweened && tweenRigidbody)
                {
                    Rigidbody2D rBody2D = target.GetComponent <Rigidbody2D>();
                    if (rBody2D != null)
                    {
                        rBodyFoundAndTweened = true;
                        t = isLocal
                            ? rBody2D.DOLocalPath(path, duration, pathMode)
                            : rBody2D.DOPath(path, duration, pathMode);
                    }
                }
#endif
                if (!rBodyFoundAndTweened)
                {
                    t = isLocal
                        ? target.transform.DOLocalPath(path, duration, pathMode)
                        : target.transform.DOPath(path, duration, pathMode);
                }
                return(t);
            }
Example #40
0
        /// <summary>
        /// Will save your data only if it present on persistentData
        /// </summary>
        /// <param name="savedData"></param>
        public void SaveData(SavedData savedData, PathMode loadMode = PathMode.PLAYER)
        {
            if (saveMode == SaveMode.SINGLE_FILE)
            {
                Debug.LogError("You don't use multiple file, you can't save only one saved data. Use SaveData() instead");
                return;
            }

            string dataPath = savedData.filePath;
            Type   type     = savedData.GetType();

            List <SavedData> savedDataList;

            savedDataDictionnary.TryGetValue(savedData.GetType(), out savedDataList);

            if (savedDataList == null)
            {
                Debug.LogError("There is no type of this data in the dictionnary, this is not possible. Use AddNewSavedData");
                return;
            }

            if (!savedDataList.Contains(savedData))
            {
                Debug.LogError("This data is not in the dictionnary, this is not possible. Use AddNewSavedData");
                return;
            }

            int cpt = 0;

            foreach (SavedData sd in savedDataList)
            {
                if (OnBeginDataSaving != null)
                {
                    OnBeginDataSaving(this, sd);
                }

                if (sd == savedData)
                {
                    if (loadMode == PathMode.PLAYER)
                    {
                        dataPath = System.IO.Path.Combine(multiplePlayerFilesDirectoryPath, type.Name);
                    }
                    else
                    {
                        dataPath = System.IO.Path.Combine(multipleDefaultFilesDirectoryPath, type.Name);
                    }

                    if (!Directory.Exists(dataPath))
                    {
                        Directory.CreateDirectory(dataPath);
                    }

                    dataPath += "/" + cpt;

                    if (savedData is IFullSerializationControl)
                    {
                        dataPath += ControlledSerializationFileExtension;
                        using (FileStream fs = File.Create(dataPath))
                        {
                            BinaryWriter writer = new BinaryWriter(fs);
                            writer.Write(type.Name);
                            writer.Write(sd.dataVersion);
                            writer.Write(new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds());

                            ((IFullSerializationControl)savedData).WriteObjectData(writer);
                            fs.Close();
                        }
                    }
                    else
                    {
                        dataPath += AutomaticSerializationFileExtension;
                        BinaryFormatter bf = new BinaryFormatter();
                        using (FileStream fs = File.Create(dataPath))
                        {
                            bf.Serialize(fs, savedData);
                            fs.Close();
                        }
                    }

                    savedData.filePath   = dataPath;
                    savedData.fileNumber = cpt;

                    OnDataSaved?.Invoke(this, sd);
                }

                cpt++;
            }
        }
Example #41
0
 /// <summary>
 /// Load the first saved data of type T, if no such file exist, saved data will be Init.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <returns>null if used with single file system</returns>
 public T LoadSavedData <T>(PathMode pathMode = PathMode.PLAYER) where T : SavedData
 {
     return((T)LoadSavedData(typeof(T), pathMode));
 }
Example #42
0
 public static Tweener DOPath(Transform target, Vector3[] path, float duration, PathType pathType = PathType.Linear, PathMode pathMode = PathMode.Full3D, int resolution = 10, Color? gizmoColor = null, float delay = 0, System.Action doComplete = null)
 {
     Tweener tweener = target.DOPath(path, duration, pathType, pathMode, resolution, gizmoColor);
     SetTweenerComplete(tweener, delay, doComplete);
     return tweener;
 }