Exemplo n.º 1
0
    AudioClip GetClipByType(ClipType clipType)
    {
        switch (clipType)
        {
        case ClipType.yes:
            return(clipYes);

        case ClipType.no:
            return(clipNo);

        case ClipType.acquired:
            return(clipAcquired);

        case ClipType.lost:
            return(clipLost);

        case ClipType.music:
            return(clipMusic);

        case ClipType.turn:
            return(clipTurn);

        case ClipType.acknowledge:
            return(clipAcknowledge);

        case ClipType.done:
            return(clipDone);
        }
        return(null);
    }
        public static List <Polygon> Execute(
            List <Polygon> a, List <Polygon> b, ClipType clipType)
        {
            Paths solution = new Paths();

            Clipper clipper = new Clipper();

            var aPaths = a.Select(poly => poly.GetPoints()).ToList();

            clipper.AddPaths(aPaths, PolyType.ptSubject, true);
            var bPaths = b.Select(poly => poly.GetPoints()).ToList();

            clipper.AddPaths(bPaths, PolyType.ptClip, true);
            clipper.Execute(clipType, solution);

            List <Polygon> solutionPolygons = new List <Polygon>();

            foreach (Path path in solution)
            {
                Polygon polygon = new Polygon(path);
                solutionPolygons.Add(polygon);
            }

            return(solutionPolygons);
        }
Exemplo n.º 3
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="da">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess da)
        {
            // SETALL INPUT PARAMETERS

            List <Curve> curvesA = NGonsCore.Clipper.DataAccessHelper.FetchList <Curve>(da, "A");
            List <Curve> curvesB = NGonsCore.Clipper.DataAccessHelper.FetchList <Curve>(da, "B");

            try {
                ClipType type = (ClipType)NGonsCore.Clipper.DataAccessHelper.Fetch <int>(da, "BooleanType");
                //Plane pln = NGonsCore.Clipper.DataAccessHelper.Fetch<Plane>(da,"Plane");
                //double tolerance = NGonsCore.Clipper.DataAccessHelper.Fetch<double>(da,"Tolerance");
                double tolerance = 0.001;

                // Convert the curves to polylines
                // This is a crude way of doing this.
                // Should we add some parameters for this perhaps?
                List <Polyline> polylinesA = Polyline3D.ConvertCurvesToPolyline(curvesA).ToList();
                List <Polyline> polylinesB = Polyline3D.ConvertCurvesToPolyline(curvesB).ToList();

                // If we don't have a plane, let's try to create a plane from the first curve.
                //if (pln.Equals(default(Plane)) || !pln.IsValid) {
                // ReSharper disable once PossibleMultipleEnumeration
                Plane pln = polylinesA.First().FitPlane();
                //}

                // do the boolean operation
                List <Polyline> result = Polyline3D.Boolean(type, polylinesA, polylinesB, pln, tolerance, EvenOdd);

                // OUTPUT LOGIC
                da.SetDataList("Result", result);
            } catch (Exception e) {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.Message + ": " + e.StackTrace);
            }
        }
Exemplo n.º 4
0
        public static string ToTitle(this ClipType clipType)
        {
            switch (clipType)
            {
            case ClipType.ExtraTimeOrPen:
                return("Extra Time/Pens if any");

            case ClipType.FirstHalf:
                return("1st Half");

            case ClipType.HalfTime:
                return("Half Time");

            case ClipType.Highlights:
                return("Hightlights");

            case ClipType.PostMatch:
                return("Post match");

            case ClipType.PreMatch:
                return("Pre-match");

            case ClipType.SecondHalf:
                return("2nd Half");

            default:
                return(null);
            }
        }
Exemplo n.º 5
0
		public AudioSource GetSource(WindowBase window, ClipType clipType, int id) {
			
			#if UNITY_EDITOR
			if (Application.isPlaying == false) {
				
				return null;
				
			}
			#endif
			
			var key = (window != null) ? (long)window.GetInstanceID() : (long)(((int)clipType << 16) | (id & 0xffff));
			
			AudioSource value;
			if (this.instances.TryGetValue(key, out value) == false) {
				
				value = this.source.Spawn();
				this.instances.Add(key, value);
				
			}

			
			List<AudioSource> valuesByType;
			if (this.instancesByType.TryGetValue(clipType, out valuesByType) == false) {

				this.instancesByType.Add(clipType, new List<AudioSource>() { value });

			} else {

				valuesByType.Add(value);

			}

			return value;
			
		}
Exemplo n.º 6
0
		public static void Play(WindowBase window, Source sourceInfo, ClipType clipType, int id) {
			
			var source = sourceInfo.GetSource(window, clipType, id);
			if (source == null) return;

			if (id == 0) {

				// Stop
				Manager.Stop(window, sourceInfo, clipType, id);
				return;

			}

			var state = Manager.currentData.GetState(clipType, id);
			if (state == null) {
				
				Manager.Stop(window, sourceInfo, clipType, id);
				return;

			}

			Manager.Reset(source);

			if (clipType == ClipType.Music) {

				source.clip = state.clip;
				source.Play();

			} else if (clipType == ClipType.SFX) {
				
				source.PlayOneShot(state.clip);

			}

		}
Exemplo n.º 7
0
        public void Execute(ClipType clipType, Region output)
        {
            List <List <IntPoint> > solution = new List <List <IntPoint> > ();

            Execute(clipType, solution);
            int contourCount = solution.Count;

            if (contourCount == 0)
            {
                output.Clear();
            }
            else
            {
                int best       = 0;
                int pointCount = solution [0].Count;
                for (int k = 1; k < contourCount; k++)
                {
                    int candidatePointCount = solution [k].Count;
                    if (candidatePointCount > pointCount)
                    {
                        pointCount = candidatePointCount;
                        best       = k;
                    }
                }
                List <IntPoint> points    = solution [best];
                int             count     = points.Count;
                Vector2[]       newPoints = new Vector2[count];
                for (int k = 0; k < count; k++)
                {
                    newPoints [k] = new Vector2((float)points [k].X / MULTIPLIER, (float)points [k].Y / MULTIPLIER);
                }
                output.UpdatePointsAndRect(newPoints);
            }
        }
        public Polygon Clip(Polygon clippingPoly, ClipType type = ClipType.ctIntersection)
        {
            List <List <IntPoint> > list = new List <List <IntPoint> >();

            list.Add(GetPath());
            List <List <IntPoint> > list2 = new List <List <IntPoint> >();

            list2.Add(clippingPoly.GetPath());
            Clipper  clipper  = new Clipper(0);
            PolyTree polytree = new PolyTree();

            clipper.AddPaths(list, PolyType.ptSubject, true);
            clipper.AddPaths(list2, PolyType.ptClip, true);
            clipper.Execute(type, polytree, PolyFillType.pftEvenOdd, PolyFillType.pftEvenOdd);
            List <List <IntPoint> > list3 = Clipper.PolyTreeToPaths(polytree);

            if (list3.Count > 0)
            {
                List <Vector2> list4 = new List <Vector2>();
                for (int i = 0; i < list3[0].Count; i++)
                {
                    List <Vector2> list5     = list4;
                    IntPoint       intPoint  = list3[0][i];
                    float          x         = (float)intPoint.X * 0.0001f;
                    IntPoint       intPoint2 = list3[0][i];
                    list5.Add(new Vector2(x, (float)intPoint2.Y * 0.0001f));
                }
                return(new Polygon(list4));
            }
            return(null);
        }
Exemplo n.º 9
0
		public State GetState(ClipType clipType, int key) {

#if UNITY_EDITOR
			if (Application.isPlaying == false) {
				
				if (clipType == ClipType.Music) {
					
					return this.music.FirstOrDefault(item => item.key == key);
					
				} else if (clipType == ClipType.SFX) {
					
					return this.fx.FirstOrDefault(item => item.key == key);
					
				}

			}
#endif
			if (clipType == ClipType.Music) {
				
				return this.musicCache.GetValue(key);
				
			} else if (clipType == ClipType.SFX) {
				
				return this.fxCache.GetValue(key);
				
			}

			return null;
			
		}
Exemplo n.º 10
0
        public void Execute(ClipType clipType, Region output)
        {
            if (solution == null)
            {
                solution = new List <List <IntPoint> > ();
            }
            Execute(clipType, solution);
            int contourCount = solution.Count;

            if (contourCount == 0)
            {
                output.Clear();
            }
            else
            {
                // Use the largest contour
                int best       = 0;
                int pointCount = solution [0].Count;
                for (int k = 1; k < contourCount; k++)
                {
                    int candidatePointCount = solution [k].Count;
                    if (candidatePointCount > pointCount)
                    {
                        pointCount = candidatePointCount;
                        best       = k;
                    }
                }
                Vector2[] newPoints = BuildPointArray(solution [best]);
                output.UpdatePointsAndRect(newPoints);
            }
        }
Exemplo n.º 11
0
        public void PlayClip(ClipType cType, AudioSource audioSrc = null, float resetTime = -1f)
        {
            if (!GameSettings.isSFXOn)
            {
                return;
            }

            if (audioSrc == null)
            {
                audioSrc = audSrc;
            }

            switch (cType)
            {
            case ClipType.UI_BUTTON_CLICK:
                audioSrc.clip = clickClip;
                break;

            case ClipType.TORCH_BUTTON_CLICK:
                break;
            }
            audSrc.Play();

            if (resetTime > 0f)
            {
                StartCoroutine(ResetAudioSrc(resetTime));
            }
        }
Exemplo n.º 12
0
        private static IPolygon BinaryOperation(IPolygon p, IPolygon q, ClipType operationType)
        {
            if (p.IsEmpty && q.IsEmpty)
            {
                return(Polygon.Empty);
            }

            var boundingBox = Box2.Hull(p.BoundingBox(), q.BoundingBox());

            var fixedP = ConvertToFixedPoint(p, boundingBox);
            var fixedQ = ConvertToFixedPoint(q, boundingBox);

            try
            {
                var clipper = new Clipper();
                clipper.AddPaths(fixedP, PolyType.ptSubject, closed: true);
                clipper.AddPaths(fixedQ, PolyType.ptClip, closed: true);

                var fixedAnswer = new ClipperPolygon();

                clipper.Execute(operationType, fixedAnswer);

                return(ConvertToFloatingPoint(fixedAnswer, boundingBox));
            }
            catch (Exception e)
            {
                Console.WriteLine("EXCEPTION: {0}", e);
                return(Polygon.Empty);
            }
        }
Exemplo n.º 13
0
        public static PolygonList Execute(PolygonList a, PolygonList b, ClipType clipType)
        {
            PolyTree solution = new PolyTree();

            Clipper clipper = new Clipper();

            PolygonList a_flat = new PolygonList();

            _addRecursive(a, ref a_flat);
            PolygonList b_flat = new PolygonList();

            _addRecursive(b, ref b_flat);

            clipper.AddPaths(a_flat, PolyType.ptSubject, true);
            clipper.AddPaths(b_flat, PolyType.ptClip, true);
            clipper.Execute(clipType, solution);

            PolygonList solutionPolygons = new PolygonList();

            foreach (PolyNode node in solution.Childs)
            {
                Polygon polygon = new Polygon(node);
                solutionPolygons.AddRange(polygon.Flatten());
            }

            return(solutionPolygons);
        }
    //Assuming explosionPoints centered on 0,0
    public void ExplosionCut(Vector2[] cutVertices, Vector2 worldHitPoint, ClipType clipType = ClipType.ctDifference)
    {
        Transform ourTransform = gameObject.transform;

        PolyClipper.OffsetVertices( cutVertices,
          PolyClipper.GetOffset((Vector2)ourTransform.position,
                worldHitPoint));

        //IF YOU MAKE NON KINEMATIC, PROBLEM:
        //Moved Relative to PARENT, NOT ROTATED RELATIVE TO PARENT
        //Polygon points are all moved relative to parent GO's transform
        Vector2[] ourVertices = ourPolygon.points;
        IntoLocalSpace(ourVertices);

        //  public enum ClipType { ctIntersection, ctUnion, ctDifference, ctXor };
        List<Vector2[]> cutPolygons = PolyClipper.ClipPoly(ourVertices,cutVertices,clipType);

        if(cutPolygons.Count == 0){
        Destroy(this.gameObject);
        return;
        }

        OutLocalSpace(cutPolygons[0]);
        UpdateShape( cutPolygons[0] );

        for(int i = 1; i<cutPolygons.Count; i++){
        //OutLocalSpace(cutPolygons[i]);
        CreateCopy( cutPolygons[i] );
        }
    }
Exemplo n.º 15
0
    /// <summary>
    /// Creates a TypedAudioClip and adds it to the typedAudioClips collection.
    /// Note: The method allows you to omit type and name, but you should always provide these parameters if you want to play the clip
    /// </summary>
    /// <param name="clip"></param>
    /// <param name="type"></param>
    /// <param name="name">Must be unique to guarantee playability</param>
    /// <returns></returns>
    public int AddAudioClip(AudioClip clip, ClipType type = ClipType.Undefined, string name = "GiveMeAName")
    {
        TypedAudioClip c = new TypedAudioClip(clip, type, name);

        typedAudioClips.Add(c);
        return(typedAudioClips.IndexOf(c));
    }
Exemplo n.º 16
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // SET ALL INPUT PARAMETERS
            List <Curve> A = DA.FetchList <Curve>("A");
            List <Curve> B = DA.FetchList <Curve>("B");

            try {
                ClipType type      = (ClipType)DA.Fetch <int>("BooleanType");
                Plane    pln       = DA.Fetch <Plane>("Plane");
                double   tolerance = DA.Fetch <double>("Tolerance");

                // Convert the curves to polylines
                // This is a crude way of doing this.
                // Should we add some parameters for this perhaps?
                IEnumerable <Polyline> APl = Polyline3D.ConvertCurvesToPolyline(A);
                IEnumerable <Polyline> BPl = Polyline3D.ConvertCurvesToPolyline(B);

                // If we don't have a plane, let's try to create a plane from the first curve.
                if (pln.Equals(default(Plane)) || !pln.IsValid)
                {
                    pln = APl.First().FitPlane();
                }

                List <Polyline> result = new List <Polyline>();

                // do the boolean operation
                result = Polyline3D.Boolean(type, APl, BPl, pln, tolerance, EvenOdd);

                // OUTPUT LOGIC
                DA.SetDataList("Result", result);
            } catch (Exception e) {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.Message + ": " + e.StackTrace.ToString());
            }
        }
Exemplo n.º 17
0
 public void ApplyVolume(ClipType clipType, AudioSource source)
 {
     if (source != null)
     {
         source.volume = this.GetVolume(clipType);
     }
 }
Exemplo n.º 18
0
 public Clip(BitmapImage thumb, ClipEvent clipEvent, ClipType clipType, IReadOnlyCollection <Video> videos)
 {
     Thumb  = thumb;
     _event = clipEvent;
     Type   = clipType;
     Videos = videos;
 }
Exemplo n.º 19
0
        public State GetState(ClipType clipType, int key)
        {
#if UNITY_EDITOR
            if (Application.isPlaying == false)
            {
                if (clipType == ClipType.Music)
                {
                    return(this.music.FirstOrDefault(item => item.key == key));
                }
                else if (clipType == ClipType.SFX)
                {
                    return(this.fx.FirstOrDefault(item => item.key == key));
                }
            }
#endif
            if (clipType == ClipType.Music)
            {
                return(this.musicCache.GetValue(key));
            }
            else if (clipType == ClipType.SFX)
            {
                return(this.fxCache.GetValue(key));
            }

            return(null);
        }
Exemplo n.º 20
0
        private IEnumerable <Clip> GetEventClips(ClipType clipType, CancellationToken cancellationToken)
        {
            return(_usbFileSystemService
                   .GetClips(clipType)
                   .Where(IsClipValid)
                   .Where(c => _options.CamerasToProcess.Contains(c.Camera))
                   .Where(c => !_archiveService.IsArchived(c)));

            // var clips = _usbFileSystemService
            //     .GetClips(clipType)
            //     .ToArray();
            //
            // var clipsToArchive = new List<Clip>();
            //
            // foreach (var eventClips in clips.GroupBy(c => c.EventDate))
            // {
            //     // Group clips by minute and only take minutes we want to keep
            //     var clipsByMinute = eventClips
            //         .GroupBy(c => c.Date)
            //         .OrderByDescending(c => c.Key)
            //         .Take(_options.KeepClipsPerEventAmount);
            //
            //     // Filter clips in every minute
            //     clipsToArchive.AddRange(clipsByMinute
            //         .SelectMany(cbm => cbm)
            //         .Where(IsClipValid)
            //         .Where(c => _options.CamerasToProcess.Contains(c.Camera))
            //         .Where(c => !_archiveService.IsArchived(c)));
            // }
            //
            // _archiveService.CreateClips(clips.Except(clipsToArchive), cancellationToken);
            //
            // return clipsToArchive;
        }
Exemplo n.º 21
0
    /// <summary>
    /// Called by explosions to partially destroy this object.
    /// </summary>
    /// <param name="force"> Force to apply to this object </param>
    /// <param name="explosionPoints"> WORLD position of explosion points </param>
    /// <param name="clipType"> public enum ClipType { ctIntersection, ctUnion, ctDifference, ctXor }; </param>
    public void ExplosionCut(Vector2 force, List <Vector2> explosionPoints, ClipType clipType = ClipType.ctDifference)
    {
        Transform ourTransform = gameObject.transform;


        PolyClipper clipper = new PolyClipper();

        Polygon          explosionPolygon = new Polygon(explosionPoints);
        List <Vector2[]> cutPolygons      = clipper.ClipPoly(polygon.points.ToArray(), explosionPolygon.getWorldToLocalPoints(this.transform).ToArray(), clipType);

        if (cutPolygons.Count == 0)
        {
            Destroy(this.gameObject);
            return;
        }

        //Update children copies before determining if self is anchored
        for (int i = 1; i < cutPolygons.Count; i++)
        {
            CreateCopy(cutPolygons[i]);
        }

        updateShape(cutPolygons[0]);
        determineAnchored(isAnchored());
    }
    //Apply a polygon clipper operation on subject vertices using cut vertices
    public static List<Vector2[]> ClipPoly(Vector2[] subject, Vector2[] cut, ClipType operation)
    {
        List<Vector2[]> cutPolygons = new List<Vector2[]>();

        Paths subj = new Paths(1);
        subj.Add(Vector2ToIntList(subject));

        Paths clip = new Paths(1);
        clip.Add(Vector2ToIntList(cut));

        Paths solution = new Paths();

        Clipper c = new Clipper();
        c.AddPaths(subj, PolyType.ptSubject, true);
        c.AddPaths(clip, PolyType.ptClip, true);

        c.Execute(operation,solution,
              PolyFillType.pftEvenOdd, PolyFillType.pftEvenOdd);

        /*
        for(int i = 0; i<solution.Count; i++){
        if( Mathf.Abs((float)Clipper.Area(solution[i])) > ignoreArea){
            cutPolygons.Add( IntListToVector2( solution[i] ));
        }
        }
        */
        return IntListsToVector2(solution);
    }
Exemplo n.º 23
0
    public void PlayRandomClip(ClipType clipType, Transform audioSource)
    {
        switch (clipType)
        {
        case ClipType.DEATH:
            PlayRandom(deathSounds, audioSource);
            break;

        case ClipType.JUMP:
            PlayRandom(jumpSounds, audioSource);
            break;

        case ClipType.WEB:
            PlayRandom(webSounds, audioSource);
            break;

        case ClipType.FIRE:
            PlayRandom(fireSounds, audioSource);
            break;

        case ClipType.IMPACT:
            PlayRandom(impactSounds, audioSource);
            break;

        case ClipType.POINTS_GAINED:
            PlayRandom(pointsGainedSounds, audioSource);
            break;

        case ClipType.TAKE_DAMAGE:
            PlayRandom(takeDamageSounds, audioSource);
            break;
        }
    }
Exemplo n.º 24
0
 public bool IsOperation(PolyLog ppLog, PolyLog pLog, ClipType ctOperation)
 {
     foreach (APPair aP in pLog.ApPairs)
     {
         if (aP.AdderComp == this.Comp)
         {
             //foreach (APPair apPairThis in this.ApPairs)
             if (ppLog != null)
             {
                 foreach (APPair aPP in ppLog.ApPairs)
                 {
                     if (EntraSolver.IsPolyOperation(aP.Poly, aPP.Poly, ClipType.ctIntersection))
                     {
                         //if (EntraSolver.IsPolyOperation(apPairParent.Poly, apPairThis.Poly, ClipType.ctIntersection))
                         return(true);
                     }
                     //EntraDrawer.DrawIntoFileTesting(aPP.Poly);
                     //EntraDrawer.DrawIntoFileTesting(aP.Poly);
                 }
             }
             else
             {
                 // Frog
                 return(true);
             }
         }
     }
     return(false);
 }
Exemplo n.º 25
0
		public long GetKey(WindowBase window, ClipType clipType, int id) {
			
			var key = (long)(((int)clipType << 16) | (id & 0xffff));

			return key;

		}
Exemplo n.º 26
0
        public static void Stop(WindowBase window, Source sourceInfo, ClipType clipType, int id)
        {
            if (id == 0)
            {
                // Stop all
                var sources = sourceInfo.GetPlayingSources(window, clipType);
                if (sources == null)
                {
                    return;
                }

                foreach (var source in sources)
                {
                    if (source != null)
                    {
                        source.Stop();
                        source.clip = null;
                    }
                }
            }
            else
            {
                var source = sourceInfo.GetPlayingSource(window, clipType, id);
                if (source == null)
                {
                    return;
                }

                source.Stop();
                source.clip = null;
            }
        }
Exemplo n.º 27
0
		public static void Play(WindowBase window, Source sourceInfo, ClipType clipType, int id, bool replaceOnEquals) {

			if (clipType == ClipType.Music) {

				var currentMusicId = sourceInfo.GetCurrentMusicId();
				if (currentMusicId > 0) {

					var equals = (currentMusicId == id);
					if (equals == false || replaceOnEquals == true) {

						// Stop
						Manager.Stop(window, sourceInfo, clipType, currentMusicId);

					} else if (equals == true) {

						// Don't play anything
						return;

					}

				}

			}

			var source = sourceInfo.GetSource(window, clipType, id);
			if (source == null) return;

			if (id == 0) {

				// Stop
				Manager.Stop(window, sourceInfo, clipType, id);
				return;

			}

			var state = Manager.currentData.GetState(clipType, id);
			if (state == null) {
				
				Manager.Stop(window, sourceInfo, clipType, id);
				return;

			}

			Manager.Reset(source);

			sourceInfo.ApplyVolume(clipType, source);

			if (clipType == ClipType.Music) {

				source.clip = state.clip;
				source.Play();

			} else if (clipType == ClipType.SFX) {
				
				source.PlayOneShot(state.clip);

			}

		}
Exemplo n.º 28
0
        /// <summary>
        /// Performs the clipping operation.
        /// Can be called multiple times without reassigning subject and clip polygons
        /// (ie when different clipping operations are required on the same polygon sets).
        /// </summary>
        /// <param name="clipType"> Type of the clipping operation. </param>
        /// <param name="output"> The List that will receive the result of the clipping operation. </param>
        /// <param name="subjectFillType"> Fill rule that will be applied to the subject paths. </param>
        /// <param name="clipFillType"> Fill rule that will be applied to the clip paths. </param>
        /// <returns> True if the operation was successful, false otherwise. </returns>
        public bool Clip(ClipType clipType, ref List <List <Vector2> > output, PolyFillType subjectFillType, PolyFillType clipFillType)
        {
            var  intOutput = new List <List <IntPoint> >();
            bool succeeded = clipper.Execute(clipType, intOutput, subjectFillType, clipFillType);

            ClipperUtility.ToVector2Paths(intOutput, ref output);
            return(succeeded);
        }
Exemplo n.º 29
0
        public async Task GetClipsAsync(ClipType clipType, DeviceInformationDisplay deviceInfoDisplay)
        {
            SentryEventItemsViewSource.Clear();

            if (null == deviceInfoDisplay)
            {
                return;
            }

            var sentryClipsFolder = await deviceInfoDisplay.StorageFolder.GetFolderAsync("TeslaCam\\SentryClips");

            List <string> fileTypeFilter = new List <string>();

            fileTypeFilter.Add(".jpg");
            fileTypeFilter.Add(".png");
            fileTypeFilter.Add(".bmp");
            fileTypeFilter.Add(".gif");

            var query = sentryClipsFolder.CreateFolderQueryWithOptions(new Windows.Storage.Search.QueryOptions(Windows.Storage.Search.CommonFileQuery.OrderByName, fileTypeFilter));

            var folders = await query.GetFoldersAsync();


            foreach (var folder in folders)
            {
                var thumbSource = folder.Path + @"\thumb.png";
                var jsonPath    = folder.Path + @"\event.json";

                StorageFile sfi = await StorageFile.GetFileFromPathAsync(thumbSource);

                StorageFile json = await StorageFile.GetFileFromPathAsync(jsonPath);

                var thumbImage = await FromStorageFile(sfi);

                var jonText = await StringFromStorageFile(json);

                var clipEvent = new ClipEvent(jonText);

                var files = await folder.GetFilesAsync();

                var videoPaths = new List <string>();

                foreach (var file in files)
                {
                    if (file.FileType != ".mp4")
                    {
                        continue;
                    }

                    videoPaths.Add(file.Path);
                }

                var videos = videoPaths.Select(path => new Video(path)).ToList().AsReadOnly();


                SentryEventItemsViewSource.Add(new Clip(thumbImage, clipEvent, ClipType.Sentry, videos));
            }
        }
Exemplo n.º 30
0
        static PathWriter CombinePaths(VertexStoreSnap a, VertexStoreSnap b, ClipType clipType)
        {
            List <List <IntPoint> > aPolys = CreatePolygons(a);
            List <List <IntPoint> > bPolys = CreatePolygons(b);

            Clipper clipper = new Clipper();

            clipper.AddPaths(aPolys, PolyType.ptSubject, true);
            clipper.AddPaths(bPolys, PolyType.ptClip, true);

            List <List <IntPoint> > intersectedPolys = new List <List <IntPoint> >();

            clipper.Execute(clipType, intersectedPolys);

            PathWriter output = new PathWriter();

            foreach (List <IntPoint> polygon in intersectedPolys)
            {
                bool first = true;
                int  j     = polygon.Count;

                if (j > 0)
                {
                    //first one
                    IntPoint point = polygon[0];

                    output.MoveTo(point.X / 1000.0, point.Y / 1000.0);

                    //next ...
                    if (j > 1)
                    {
                        for (int i = 1; i < j; ++i)
                        {
                            point = polygon[i];
                            output.LineTo(point.X / 1000.0, point.Y / 1000.0);
                        }
                    }
                }
                //foreach (IntPoint point in polygon)
                //{
                //    if (first)
                //    {
                //        output.AddVertex(point.X / 1000.0, point.Y / 1000.0, ShapePath.FlagsAndCommand.CommandMoveTo);
                //        first = false;
                //    }
                //    else
                //    {
                //        output.AddVertex(point.X / 1000.0, point.Y / 1000.0, ShapePath.FlagsAndCommand.CommandLineTo);
                //    }
                //}

                output.CloseFigure();
            }


            output.Stop();
            return(output);
        }
Exemplo n.º 31
0
 public void Execute(ClipType clipType)
 {
     if (subject == null)
     {
         Debug.LogError("Clipper.Execute called without defined subject");
         return;
     }
     Execute(clipType, subject);
 }
Exemplo n.º 32
0
        public static void Play(WindowBase window, Source sourceInfo, ClipType clipType, int id, bool replaceOnEquals)
        {
            if (clipType == ClipType.Music)
            {
                var currentMusicId = sourceInfo.GetCurrentMusicId();
                if (currentMusicId > 0)
                {
                    var equals = (currentMusicId == id);
                    if (equals == false || replaceOnEquals == true)
                    {
                        // Stop
                        Manager.Stop(window, sourceInfo, clipType, currentMusicId);
                    }
                    else if (equals == true)
                    {
                        // Don't play anything
                        return;
                    }
                }
            }

            var source = sourceInfo.GetSource(window, clipType, id);

            if (source == null)
            {
                return;
            }

            if (id == 0)
            {
                // Stop
                Manager.Stop(window, sourceInfo, clipType, id);
                return;
            }

            var state = Manager.currentData.GetState(clipType, id);

            if (state == null)
            {
                Manager.Stop(window, sourceInfo, clipType, id);
                return;
            }

            Manager.Reset(source);

            sourceInfo.ApplyVolume(clipType, source);

            if (clipType == ClipType.Music)
            {
                source.clip = state.clip;
                source.Play();
            }
            else if (clipType == ClipType.SFX)
            {
                source.PlayOneShot(state.clip);
            }
        }
Exemplo n.º 33
0
        public static void SetVolume(ClipType clipType, float value)
        {
            if (WindowSystem.instance == null)
            {
                return;
            }

            WindowSystem.instance.audio.SetVolume(clipType, value);
        }
Exemplo n.º 34
0
    public void Play(ClipType type)
    {
        var clip = clips.Find((Clip c) => { return(c.type == type); });

        if (clip != null)
        {
            Play(clip.autioClip);
        }
    }
Exemplo n.º 35
0
        public static List <Audio.Data.State> GetAudioItems(ClipType clipType)
        {
            if (FlowSystem.HasData() == false)
            {
                return(null);
            }

            return(FlowSystem.instance.data.audio.GetStates(clipType));
        }
Exemplo n.º 36
0
        public static float GetVolume(ClipType clipType)
        {
            if (WindowSystem.instance == null)
            {
                return(0f);
            }

            return(WindowSystem.instance.audio.GetVolume(clipType));
        }
Exemplo n.º 37
0
 public TypedAudioClip(AudioClip clip, ClipType type = ClipType.Undefined, string name = "NoName", float volume = 1f, bool mute = false, bool playOnAwake = false, bool loop = false)
 {
     this.clip        = clip;
     this.type        = type;
     this.name        = name;
     this.volume      = volume;
     this.mute        = mute;
     this.playOnAwake = playOnAwake;
     this.loop        = loop;
 }
Exemplo n.º 38
0
		public List<State> GetStates(ClipType clipType) {

			if (clipType == ClipType.Music) {

				return this.music;

			} else if (clipType == ClipType.SFX) {

				return this.fx;

			}

			return null;

		}
Exemplo n.º 39
0
		public float GetVolume(ClipType clipType) {

			var volume = 0f;

			if (clipType == ClipType.Music) {
				
				volume = this.musicVolume;

			} else if (clipType == ClipType.SFX) {
				
				volume = this.sfxVolume;
				
			}

			return volume;

		}
Exemplo n.º 40
0
		public static void Change(WindowBase window, Source sourceInfo, ClipType clipType, int id, Audio.Window audioSettings) {

			var source = sourceInfo.GetSource(window, clipType, id);
			if (source == null) return;
			
			source.bypassEffects = audioSettings.bypassEffect;
			source.bypassListenerEffects = audioSettings.bypassListenerEffect;
			source.bypassReverbZones = audioSettings.bypassReverbEffect;
			source.loop = audioSettings.loop;
			
			source.priority = audioSettings.priority;
			source.volume = audioSettings.volume;
			source.pitch = audioSettings.pitch;
			source.panStereo = audioSettings.panStereo;
			source.spatialBlend = audioSettings.spatialBlend;
			source.reverbZoneMix = audioSettings.reverbZoneMix;

		}
Exemplo n.º 41
0
		private PathStorage CombinePaths(IVertexSource a, IVertexSource b, ClipType clipType)
		{
			List<List<IntPoint>> aPolys = VertexSourceToClipperPolygons.CreatePolygons(a);
			List<List<IntPoint>> bPolys = VertexSourceToClipperPolygons.CreatePolygons(b);

			Clipper clipper = new Clipper();

			clipper.AddPaths(aPolys, PolyType.ptSubject, true);
			clipper.AddPaths(bPolys, PolyType.ptClip, true);

			List<List<IntPoint>> intersectedPolys = new List<List<IntPoint>>();
			clipper.Execute(clipType, intersectedPolys);

			PathStorage output = VertexSourceToClipperPolygons.CreatePathStorage(intersectedPolys);

			output.Add(0, 0, ShapePath.FlagsAndCommand.CommandStop);

			return output;
		}
Exemplo n.º 42
0
		public List<AudioSource> GetSources(WindowBase window, ClipType clipType) {
			
			#if UNITY_EDITOR
			if (Application.isPlaying == false) {
				
				return null;
				
			}
			#endif

			List<AudioSource> valuesByType;
			if (this.instancesByType.TryGetValue(clipType, out valuesByType) == false) {
				
				return null;
				
			} else {
				
				return valuesByType;
				
			}

		}
Exemplo n.º 43
0
		private PathStorage CombinePaths(IVertexSource a, IVertexSource b, ClipType clipType)
		{
			List<List<IntPoint>> aPolys = CreatePolygons(a);
			List<List<IntPoint>> bPolys = CreatePolygons(b);

			Clipper clipper = new Clipper();

			clipper.AddPaths(aPolys, PolyType.ptSubject, true);
			clipper.AddPaths(bPolys, PolyType.ptClip, true);

			List<List<IntPoint>> intersectedPolys = new List<List<IntPoint>>();
			clipper.Execute(clipType, intersectedPolys);

			PathStorage output = new PathStorage();

			foreach (List<IntPoint> polygon in intersectedPolys)
			{
				bool first = true;
				foreach (IntPoint point in polygon)
				{
					if (first)
					{
						output.Add(point.X / 1000.0, point.Y / 1000.0, ShapePath.FlagsAndCommand.CommandMoveTo);
						first = false;
					}
					else
					{
						output.Add(point.X / 1000.0, point.Y / 1000.0, ShapePath.FlagsAndCommand.CommandLineTo);
					}
				}

				output.ClosePolygon();
			}

			output.Add(0, 0, ShapePath.FlagsAndCommand.CommandStop);

			return output;
		}
Exemplo n.º 44
0
		public void SetVolume(ClipType clipType, float value) {

			if (clipType == ClipType.Music) {

				this.musicVolume = value;

			} else if (clipType == ClipType.SFX) {

				this.sfxVolume = value;

			}
			
			var sources = this.GetPlayingSources(null, clipType);
			if (sources != null) {

				foreach (var source in sources) {

					this.ApplyVolume(clipType, source);

				}

			}

		}
Exemplo n.º 45
0
        //------------------------------------------------------------------------------

        public bool Execute(ClipType clipType, PolyTree polytree)
        {
            return Execute(clipType, polytree,
                PolyFillType.pftEvenOdd, PolyFillType.pftEvenOdd);
        }
Exemplo n.º 46
0
		public static void Stop(WindowBase window, Source sourceInfo, ClipType clipType, int id) {

			if (id == 0) {

				// Stop all
				var sources = sourceInfo.GetSources(window, clipType);
				if (sources == null) return;

				foreach (var source in sources) {

					if (source != null) {

						source.Stop();
						source.clip = null;

					}

				}

			} else {

				var source = sourceInfo.GetSource(window, clipType, id);
				if (source == null) return;

				source.Stop();
				source.clip = null;

			}

		}
Exemplo n.º 47
0
		public AudioSource GetPlayingSource(WindowBase window, ClipType clipType, int id) {
			
			#if UNITY_EDITOR
			if (Application.isPlaying == false) {
				
				return null;
				
			}
			#endif

			var key = this.GetKey(window, clipType, id);

			AudioSource value;
			if (this.instances.TryGetValue(key, out value) == false) {
				
				return null;
				
			} else {
				
				return value;
				
			}

		}
 //------------------------------------------------------------------------------
 public bool Execute(ClipType clipType, ExPolygons solution)
 {
     return Execute(clipType, solution,
         PolyFillType.pftEvenOdd, PolyFillType.pftEvenOdd);
 }
Exemplo n.º 49
0
        //------------------------------------------------------------------------------

        public bool Execute(ClipType clipType, PolyTree polytree,
            PolyFillType subjFillType, PolyFillType clipFillType)
        {
            if (m_ExecuteLocked) return false;
            m_ExecuteLocked = true;
            m_SubjFillType = subjFillType;
            m_ClipFillType = clipFillType;
            m_ClipType = clipType;
            m_UsingPolyTree = true;
            bool succeeded = ExecuteInternal();
            //build the return polygons ...
            if (succeeded) BuildResult2(polytree);
            m_ExecuteLocked = false;
            return succeeded;
        }
Exemplo n.º 50
0
        /// <summary>
        ///     Joins all the polygones.
        ///     ClipType: http://www.angusj.com/delphi/clipper/documentation/Docs/Units/ClipperLib/Types/ClipType.htm
        ///     PolyFillType: http://www.angusj.com/delphi/clipper/documentation/Docs/Units/ClipperLib/Types/PolyFillType.htm
        /// </summary>
        /// <param name="sList">The s list.</param>
        /// <param name="cType">Type of the c.</param>
        /// <param name="pType">Type of the p.</param>
        /// <param name="pFType1">The p f type1.</param>
        /// <param name="pFType2">The p f type2.</param>
        /// <returns></returns>
        public static List<Polygon> ELJoinPolygons(this List<Polygon> sList, ClipType cType,
            PolyType pType = PolyType.ptClip, PolyFillType pFType1 = PolyFillType.pftNonZero,
            PolyFillType pFType2 = PolyFillType.pftNonZero)
        {
            var p = ELClipPolygons(sList);
            var tList = new List<List<IntPoint>>();

            var c = new Clipper();
            c.AddPaths(p, pType, true);
            c.Execute(cType, tList, pFType1, pFType2);

            return ToPolygons(tList);
        }
Exemplo n.º 51
0
 public RangeList[] GetBoundedRanges(int x, int y, int width, int height, CoordType coordType, ClipType xClipType, ClipType yClipType)
 {
     return proxy.GetBoundedRanges (x, y, width, height, coordType, xClipType, yClipType);
 }
Exemplo n.º 52
0
        //public static void
        public static List<List<Vertex>> Clip(Vertex subject, Vertex clip, ClipType clipType)
        {
            bool isIntersect = false;
            //phase 1
            for (var si = subject; si != null; si = si.Next == subject ? null : si.Next)
            {
                if (si.IsIntersect)
                    continue;

                for (var cj = clip; cj != null; cj = cj.Next == clip ? null : cj.Next)
                {
                    if (cj.IsIntersect)
                        continue;

                    var cross = Segment.Intersect (si.ToPoint(), si.NonIntersectionNext.ToPoint(),
                            cj.ToPoint(), cj.NonIntersectionNext.ToPoint());
                    if (cross.HasValue)
                    {
                        double a = cross.Value.DistanceBetween (si.ToPoint ()) /
                                   si.ToPoint ().DistanceBetween (si.NonIntersectionNext.ToPoint ());
                        double b = cross.Value.DistanceBetween (cj.ToPoint ()) /
                            cj.ToPoint ().DistanceBetween (cj.NonIntersectionNext.ToPoint ());

                        Vertex i1 = new Vertex () {
                            X = cross.Value.X,
                            Y = cross.Value.Y,
                            IsIntersect = true,
                            Alpha = a,
                        };
                        Vertex i2 = new Vertex () {
                            X = cross.Value.X,
                            Y = cross.Value.Y,
                            IsIntersect = true,
                            Alpha = b,
                        };
                        i1.Neibour = i2;
                        i2.Neibour = i1;

                        i1.InsertTo (si, si.NonIntersectionNext);
                        i2.InsertTo (cj, cj.NonIntersectionNext);
                        isIntersect = true;
                    }
                }
            }

            if(!isIntersect)
            {
                List<List<Vertex>> result = new List<List<Vertex>>();
                if (subject.Contains(clip))
                {
                    result.Add(clip.ToVertexList());
                }
                else if (clip.Contains(subject))
                {
                    result.Add(subject.ToVertexList());
                }
                return result;
            }

            //phase 2
            bool status = clip.Contains(subject);
            if (clipType == ClipType.Union || clipType == ClipType.Difference)
                status = !status;
            for (var si = subject; si != null; si = si.Next == subject ? null : si.Next)
            {
                if (si.IsIntersect)
                {
                    si.IsExit = status;
                    status = !status;
                }
            }

            status = subject.Contains(clip);
            if (clipType == ClipType.Union)
                status = !status;
            for (var cj = clip; cj != null; cj = cj.Next == clip ? null : cj.Next)
            {
                if (cj.IsIntersect)
                {
                    cj.IsExit = status;
                    status = !status;
                }
            }

            //phase 3
            Vertex current;
            List<List<Vertex>> polygonList = new List<List<Vertex>>();

            for (var si = subject; si != null; si = si.Next == subject ? null : si.Next)
            {
                if (si.IsIntersect && !si.IsVisit)
                {
                    current = si;

                    var polygon = new List<Vertex>();
                    polygonList.Add(polygon);

                    polygon.Add(current);
                    do
                    {
                        current.IsVisit = true;
                        if (current.IsExit)
                        {
                            do
                            {
                                current = current.Previous;
                                if(current.Neibour!= polygon[0])
                                    polygon.Add(current);
                                current.IsVisit = true;
                            } while (!current.IsIntersect);
                        }
                        else
                        {
                            do
                            {
                                current = current.Next;
                                if(current.Neibour != polygon[0])
                                    polygon.Add(current);
                                current.IsVisit = true;
                            } while (!current.IsIntersect);
                        }

                        current = current.Neibour;
                    } while (!current.IsVisit);
                }
            }

            return polygonList;
        }
Exemplo n.º 53
0
        void calculateRegionPath(ClipType clipType)
        {
            Clipper c = new Clipper();

            var subjects = solution;
            //subjects.Add (solution);

            var clips = new Paths ();

            foreach (var path in regionList [regionList.Count - 1].regionPath)
                clips.Add (path);

            c.AddPolygons(subjects, PolyType.ptSubject);
            c.AddPolygons(clips, PolyType.ptClip);

            solution.Clear();

            bool succeeded = c.Execute(clipType, solution, SUBJ_FILL_TYPE, CLIP_FILL_TYPE);

            if (succeeded)
            {
                PathsToInternalPath (solution);

                // Not sure what this is returning
            //				var bounds = c.GetBounds ();
            //				regionBounds.X = bounds.left / scale;
            //				regionBounds.Y = bounds.top / scale;
            //				regionBounds.Width = (bounds.right - bounds.left) / scale;
            //				regionBounds.Height = (bounds.bottom - bounds.top) / scale;

                if (regionPath.IsEmpty)
                    regionBounds = RectangleF.Empty;
                else
                    regionBounds = regionPath.BoundingBox;

            }
        }
Exemplo n.º 54
0
		public AudioSource GetSource(WindowBase window, ClipType clipType, int id) {
			
			#if UNITY_EDITOR
			if (Application.isPlaying == false) {
				
				return null;
				
			}
			#endif

			if (clipType == ClipType.Music) {
				
				this.currentMusicId = id;
				
			}

			var key = this.GetKey(window, clipType, id);

			AudioSource value;
			if (this.instances.TryGetValue(key, out value) == false) {
				
				value = this.source.Spawn();
				#if UNITY_EDITOR
				value.gameObject.name = string.Format("[ AudioSource ] {0} {1} {2}", (window != null ? window.name : string.Empty), clipType, id);
				#endif
				this.instances.Add(key, value);
				
			}

			List<AudioSource> valuesByType;
			if (this.instancesByType.TryGetValue(clipType, out valuesByType) == false) {

				this.instancesByType.Add(clipType, new List<AudioSource>() { value });

			} else {

				valuesByType.Add(value);

			}
			
			this.ApplyVolume(clipType, value);

			return value;
			
		}
Exemplo n.º 55
0
 public void playClip(ClipType cliptype)
 {
     switch (cliptype)
     {
     case ClipType.ENEMYSPAWN: AudioSource.PlayClipAtPoint(clipEnemySpawn, Camera.mainCamera.transform.position);break;
     case ClipType.EAT: AudioSource.PlayClipAtPoint(clipEat, Camera.mainCamera.transform.position);break;
     case ClipType.HURT: AudioSource.PlayClipAtPoint(clipHurt, Camera.mainCamera.transform.position);break;
     case ClipType.DIE: AudioSource.PlayClipAtPoint(clipDie, Camera.mainCamera.transform.position);break;
     case ClipType.MUSIC: break;
     }
 }
Exemplo n.º 56
0
      //------------------------------------------------------------------------------

      public bool Execute(ClipType clipType, Paths solution,
          PolyFillType subjFillType, PolyFillType clipFillType)
      {
          if (m_ExecuteLocked) return false;
          if (m_HasOpenPaths) throw 
            new ClipperException("Error: PolyTree struct is need for open path clipping.");

        m_ExecuteLocked = true;
          solution.Clear();
          m_SubjFillType = subjFillType;
          m_ClipFillType = clipFillType;
          m_ClipType = clipType;
          m_UsingPolyTree = false;
          bool succeeded = ExecuteInternal();
          //build the return polygons ...
          if (succeeded) BuildResult(solution);
          m_ExecuteLocked = false;
          return succeeded;
      }
 //------------------------------------------------------------------------------
 public bool Execute(ClipType clipType, ExPolygons solution,
     PolyFillType subjFillType, PolyFillType clipFillType)
 {
     if (m_ExecuteLocked) return false;
     m_ExecuteLocked = true;
     solution.Clear();
     m_SubjFillType = subjFillType;
     m_ClipFillType = clipFillType;
     m_ClipType = clipType;
     bool succeeded = ExecuteInternal(true);
     //build the return polygons ...
     if (succeeded) BuildResultEx(solution);
     m_ExecuteLocked = false;
     return succeeded;
 }
Exemplo n.º 58
0
		public void ApplyVolume(ClipType clipType, AudioSource source) {

			if (source != null) source.volume = this.GetVolume(clipType);

		}
Exemplo n.º 59
0
		public void RemoveAudioItem(ClipType clipType, int key) {

			this.audio.Remove(clipType, key);

		}
Exemplo n.º 60
0
		public void AddAudioItem(ClipType clipType, Audio.Data.State state) {

			state.key = this.GetNextAudioItemId(clipType);
			this.audio.Add(clipType, state);

		}