示例#1
0
        protected ArrayPathFinder(Level level)
            : base(level)
        {
            data = level.Data;
            boxCoordinates = level.BoxCoordinates;
            boxCount = boxCoordinates.Length;
            n = level.Width;
            m = level.Height * level.Width;
            q = new FixedQueue<int>(m);

            firstInside = -1;
            lastInside = -1;
            neighborMap = new int[m][];
            foreach (Coordinate2D coord in level.InsideCoordinates)
            {
                lastInside = coord.Row * n + coord.Column;
                if (firstInside == -1)
                {
                    firstInside = lastInside;
                }

                List<int> neighbors = new List<int>();
                foreach (Coordinate2D neighbor in coord.FourNeighbors)
                {
                    if (level.IsFloor(neighbor))
                    {
                        neighbors.Add(neighbor.Row * n + neighbor.Column);
                    }
                }
                neighborMap[coord.Row * n + coord.Column] = neighbors.ToArray();
            }
            insideCount = lastInside - firstInside + 1;
        }
示例#2
0
        public DijkstraPathFinder(Level level)
            : base(level)
        {
            data = level.Data;
            rowLimit = level.Height - 1;
            insideCoordinates = level.InsideCoordinates;
            int m = level.Height * level.Width;
            q = new FixedQueue<Vertex>(m);

            // Initialize the vertex map.
            vertexMap = new Array2D<Vertex>(level.Height, level.Width);
            foreach (Coordinate2D coord in level.Coordinates)
            {
                Vertex vertex = new Vertex(coord.Row, coord.Column);
                vertex.Distance = DefaultInaccessible;
                vertex.Visited = true;
                vertexMap[coord.Row, coord.Column] = vertex;
            }

            // Calculate the neighbors of each coordinate.
            foreach (Coordinate2D coord in level.InsideCoordinates)
            {
                Vertex vertex = vertexMap[coord];
                List<Vertex> neighbors = new List<Vertex>();
                foreach (Coordinate2D neighbor in coord.FourNeighbors)
                {
                    if (level.IsFloor(neighbor))
                    {
                        neighbors.Add(vertexMap[neighbor]);
                    }
                }
                vertex.Neighbors = neighbors.ToArray();
            }
        }
示例#3
0
        protected override void OnCreate()
        {
            loadedScenes = new Dictionary <Scenes, SceneInstance>();
            cacheScenes  = new FixedQueue <SceneInstance>(CacheSize);

            loadingScenes   = new Dictionary <Scenes, IObservable <SceneInstance> >();
            unloadingScenes = new Dictionary <Scenes, IObservable <Unit> >();

            appendSceneInstances = new List <SceneInstance>();

            history        = new List <ISceneArgument>();
            waitHandlerIds = new HashSet <int>();

            // キャッシュ許容数を超えたらアンロード.
            cacheScenes.OnExtrudedAsObservable()
            .Subscribe(x => UnloadCacheScene(x))
            .AddTo(Disposable);
        }
示例#4
0
        public static int Stop(ref List <ProfilerTick> tickBuffer)
        {
            if (!isRunning)
            {
                return(0);
            }
            int iteration = Ticks.Count > tickBuffer.Count ? tickBuffer.Count : Ticks.Count;

            for (int i = 0; i < iteration; i++)
            {
                tickBuffer[i] = Ticks[i];
            }

            Ticks       = null; //leave to GC
            CurrentTick = null; //leave to GC
            isRunning   = false;

            return(iteration);
        }
        public void RemoveDuplicatedTimeStamps()
        {
            List <DateTime> lDateTimeStampsLoc      = lDateTimeStamps.ToList();
            List <DateTime> lDateTimeStampsFiltered = new List <DateTime>(lDateTimeStamps.ToList().Distinct <DateTime>());
            List <T>        dataSeriaLoc            = dataSeria.ToList();

            List <T> dataSeriaFiltered = new List <T>();
            int      idx = 0;

            foreach (DateTime dtStamp in lDateTimeStampsFiltered)
            {
                idx = lDateTimeStampsLoc.FindIndex(idx, datetimeValue => datetimeValue == dtStamp);
                dataSeriaFiltered.Add(dataSeriaLoc[idx]);
            }

            lDateTimeStamps = new FixedQueue <DateTime>(lDateTimeStamps.Count);
            lDateTimeStamps.Enqueue(lDateTimeStampsFiltered);
            dataSeria = new FixedQueue <T>(dataSeria.Count);
            dataSeria.Enqueue(dataSeriaFiltered);
        }
 public Enumerator(FixedQueue <T> q)
 {
     this.q  = q;
     index   = 0;
     current = default;
 }
示例#7
0
        /// <summary>
        /// Creates a new ReplayState instance.
        /// </summary>
        public ReplayState(string fieldPath, FixedQueue <List <ContactDescriptor> > contactPoints)
        {
            tStart = Time.time;

            this.fieldPath     = fieldPath;
            this.contactPoints = contactPoints.ToList();
            trackers           = UnityEngine.Object.FindObjectsOfType <Tracker>().ToList();

            playbackMode     = PlaybackMode.Paused;
            firstFrame       = true;
            active           = false;
            contactThreshold = Mathf.Sqrt(30f);

            DynamicCamera.ControlEnabled = true;

            Texture2D thumbTexture = (Texture2D)Resources.Load("Images/ReplayMode/thumb");

            Texture2D rewindTexture        = (Texture2D)Resources.Load("Images/ReplayMode/rewind");
            Texture2D rewindHoverTexture   = (Texture2D)Resources.Load("Images/ReplayMode/rewindHover");
            Texture2D rewindPressedTexture = (Texture2D)Resources.Load("Images/ReplayMode/rewindPressed");

            Texture2D stopTexture        = (Texture2D)Resources.Load("Images/ReplayMode/stop");
            Texture2D stopHoverTexture   = (Texture2D)Resources.Load("Images/ReplayMode/stopHover");
            Texture2D stopPressedTexture = (Texture2D)Resources.Load("Images/ReplayMode/stopPressed");

            Texture2D playTexture        = (Texture2D)Resources.Load("Images/ReplayMode/play");
            Texture2D playHoverTexture   = (Texture2D)Resources.Load("Images/ReplayMode/playHover");
            Texture2D playPressedTexture = (Texture2D)Resources.Load("Images/ReplayMode/playPressed");

            Texture2D collisionTexture        = (Texture2D)Resources.Load("Images/ReplayMode/collision");
            Texture2D collisionHoverTexture   = (Texture2D)Resources.Load("Images/ReplayMode/collisionHover");
            Texture2D collisionPressedTexture = (Texture2D)Resources.Load("Images/ReplayMode/collisionPressed");

            Texture2D consolidateTexture        = (Texture2D)Resources.Load("Images/ReplayMode/consolidate");
            Texture2D consolidateHoverTexture   = (Texture2D)Resources.Load("Images/ReplayMode/consolidateHover");
            Texture2D consolidatePressedTexture = (Texture2D)Resources.Load("Images/ReplayMode/consolidatePressed");

            circleTexture   = (Texture)Resources.Load("Images/ReplayMode/circle");
            keyframeTexture = (Texture)Resources.Load("Images/ReplayMode/keyframe");

            Texture2D sliderBackground = new Texture2D(1, 1);

            sliderBackground.SetPixel(0, 0, new Color(0.1f, 0.15f, 0.15f, 0.75f));
            sliderBackground.Apply();

            windowStyle = new GUIStyle
            {
                alignment = TextAnchor.UpperLeft,
                normal    = new GUIStyleState
                {
                    background = sliderBackground,
                    textColor  = Color.white
                }
            };

            thumbStyle = new GUIStyle
            {
                fixedWidth  = ThumbWidth,
                fixedHeight = ThumbHeight,
                normal      = new GUIStyleState
                {
                    background = thumbTexture
                }
            };

            rewindStyle      = CreateButtonStyle("rewind");
            stopStyle        = CreateButtonStyle("stop");
            playStyle        = CreateButtonStyle("play");
            collisionStyle   = CreateButtonStyle("collision");
            consolidateStyle = CreateButtonStyle("consolidate");
        }
示例#8
0
        //----- method -----

        protected override void OnCreate()
        {
            logs = new FixedQueue <LogData>(50);
        }
        //----- method -----

        protected override void OnCreate()
        {
            webRequestInfos    = new Dictionary <WebRequest, WebRequestInfo>();
            requestInfoHistory = new FixedQueue <WebRequestInfo>(HistoryCount);
        }
示例#10
0
 /// <summary>
 /// Constructs a new pattern matcher history.
 /// </summary>
 /// <param name="memory">The amount of values this history should remember.</param>
 protected PatternMatcherHistory(int memory)
 {
     _historyValues = new FixedQueue <T>(memory);
     _historyValues.ExcessDequeued += (value) => OnHistoryValueDequeued();
 }
示例#11
0
 void Start()
 {
     Framekeys = new FixedQueue <float>(maxPoints);
     Framekeys.Enqueue(0);
     LagCompensationManager.simulationObjects.Add(this);
 }
 public FixedTimeQueue(int capacity)
 {
     dataSeria       = new FixedQueue <T>(capacity);
     lDateTimeStamps = new FixedQueue <DateTime>(capacity);
 }
 public FixedTimeQueue(IEnumerable <T> dataSeriaList, IEnumerable <DateTime> dateTimeStamps)
 {
     dataSeria       = new FixedQueue <T>(dataSeriaList);
     lDateTimeStamps = new FixedQueue <DateTime>(dateTimeStamps);
 }
示例#14
0
        //----- property -----

        //----- method -----

        private void ApplyDummyAsset()
        {
            if (Application.isPlaying)
            {
                return;
            }

            DeleteCreatedAsset();

            if (RawImage.texture != null && RawImage.texture.name != DummyAssetName)
            {
                return;
            }

            if (string.IsNullOrEmpty(assetGuid))
            {
                return;
            }

            var assetPath = AssetDatabase.GUIDToAssetPath(assetGuid);

            if (string.IsNullOrEmpty(assetPath))
            {
                return;
            }

            if (textureAssetCache == null)
            {
                textureAssetCache = new FixedQueue <AssetCacheInfo>(100);
            }

            Texture textureAsset = null;

            var cacheAssetInfo = textureAssetCache.FirstOrDefault(x => x.assetGuid == assetGuid);

            if (cacheAssetInfo == null)
            {
                textureAsset = AssetDatabase.LoadMainAssetAtPath(assetPath) as Texture;

                if (textureAsset != null)
                {
                    cacheAssetInfo = new AssetCacheInfo()
                    {
                        assetGuid    = assetGuid,
                        textureAsset = textureAsset,
                    };

                    textureAssetCache.Enqueue(cacheAssetInfo);
                }
            }
            else
            {
                textureAsset = cacheAssetInfo.textureAsset;

                textureAssetCache.Remove(cacheAssetInfo);

                textureAssetCache.Enqueue(cacheAssetInfo);
            }

            if (textureAsset == null)
            {
                return;
            }

            DeleteCreatedAsset();

            var texture = new Texture2D(textureAsset.width, textureAsset.height, TextureFormat.ARGB32, false);

            texture.name = DummyAssetName;

            texture.hideFlags = HideFlags.DontSaveInEditor;

            Graphics.ConvertTexture(textureAsset, texture);

            // Bug: UnityのバグでこのタイミングでアクティブなRenderTextureを空にしないと下記警告が出る.
            // 「Releasing render texture that is set to be RenderTexture.active!」.
            RenderTexture.active = null;

            RawImage.texture = texture;
        }
示例#15
0
 private void Awake()
 {
     items = new FixedQueue <PowerUp>(maxNumberOfItems);
 }
示例#16
0
        //----- method -----

        protected override void OnCreate()
        {
            apiInfos       = new Dictionary <IWebRequestClient, ApiInfo>();
            apiInfoHistory = new FixedQueue <ApiInfo>(HistoryCount);
        }
 public void TestInitialize()
 {
     Target = new FixedQueue<object>(QueueCapacity);
 }
示例#18
0
        //----- property -----

        //----- method -----

        private void ApplyDummyAsset()
        {
            if (Application.isPlaying)
            {
                return;
            }

            if (Image.sprite != null && Image.sprite.name != DummyAssetName)
            {
                return;
            }

            if (string.IsNullOrEmpty(assetGuid))
            {
                return;
            }

            if (string.IsNullOrEmpty(spriteId))
            {
                return;
            }

            var assetPath = AssetDatabase.GUIDToAssetPath(assetGuid);

            if (string.IsNullOrEmpty(assetPath))
            {
                return;
            }

            if (spriteAssetCache == null)
            {
                spriteAssetCache = new FixedQueue <AssetCacheInfo>(250);
            }

            Sprite spriteAsset = null;

            var cacheAssetInfo = spriteAssetCache.FirstOrDefault(x => x.assetGuid == assetGuid && x.spriteId == spriteId);

            if (cacheAssetInfo == null)
            {
                spriteAsset = AssetDatabase.LoadAllAssetsAtPath(assetPath)
                              .OfType <Sprite>()
                              .FirstOrDefault(x => x.GetSpriteID().ToString() == spriteId);

                if (spriteAsset != null)
                {
                    cacheAssetInfo = new AssetCacheInfo()
                    {
                        assetGuid   = assetGuid,
                        spriteId    = spriteId,
                        spriteAsset = spriteAsset,
                    };

                    spriteAssetCache.Enqueue(cacheAssetInfo);
                }
            }
            else
            {
                spriteAsset = cacheAssetInfo.spriteAsset;

                spriteAssetCache.Remove(cacheAssetInfo);

                spriteAssetCache.Enqueue(cacheAssetInfo);
            }

            if (spriteAsset == null)
            {
                return;
            }

            DeleteCreatedAsset();

            var texture       = spriteAsset.texture;
            var rect          = spriteAsset.rect;
            var pivot         = spriteAsset.pivot;
            var pixelsPerUnit = spriteAsset.pixelsPerUnit;
            var border        = spriteAsset.border;

            var sprite = Sprite.Create(texture, rect, pivot, pixelsPerUnit, 0, SpriteMeshType.FullRect, border);

            sprite.name = DummyAssetName;

            sprite.hideFlags = HideFlags.DontSaveInEditor;

            Image.sprite = sprite;
        }
示例#19
0
 public PasswordModeService()
 {
     log = new FixedQueue <InterceptKeyEventArgs>(this.PasswordKeyCombination.Count());
 }
示例#20
0
 public static void Stop()
 {
     Ticks       = null; //leave to GC
     CurrentTick = null; //leave to GC
     isRunning   = false;
 }