예제 #1
0
        private InMemoryBlockCollection ReadBlocks(EndianReader reader, XmlNode node, InMemoryBlockCollection parent, int parentBlockIndex)
        {
            var result = new InMemoryBlockCollection(this, reader, node, parent, parentBlockIndex);

            var lastBlock   = AllBlocks.LastOrDefault();
            var nextAddress = (lastBlock?.VirtualAddress + lastBlock?.AllocatedSize) ?? 0;
            var nextSize    = PageSize;

            while (nextSize < result.VirtualSize)
            {
                nextSize += PageSize;
            }

            result.Allocate(nextAddress, nextSize);
            AllBlocks.Add(result);

            var blockAddress = parent == null
                ? SourceItem.MetaPointer.Address
                : result.BlockRef.Pointer.Address;

            for (int i = 0; i < result.EntryCount; i++)
            {
                var indexAddress = blockAddress + result.EntrySize * i;
                foreach (var childNode in node.SelectNodes("tagblock").OfType <XmlNode>())
                {
                    reader.Seek(indexAddress + childNode.GetIntAttribute("offset").Value, SeekOrigin.Begin);
                    ReadBlocks(reader, childNode, result, i);
                }
            }

            return(result);
        }
예제 #2
0
 private void CheckClear()
 {
     if (AllBlocks.All(x => (x.BlockType == BlockType.Mine && x.FlagType == FlagType.Mine) || (x.BlockType == BlockType.None && x.FlagType == FlagType.Flip)))
     {
         Messenger.Default.Send <string>("clear");
     }
 }
예제 #3
0
    // Update is called once per frame
    void Update()
    {
        if (!AllBlocks.GetComponent <MoveBlocks> ().GetIsMoved())
        {
            if (blockInstNext.transform.position != BlockPosition && OnPlace == false)
            {
                blockInstNext.transform.position = Vector3.MoveTowards(blockInstNext.transform.position, BlockPosition, Time.deltaTime * 3);
            }
        }
        if (blockInstNext.transform.position == BlockPosition)
        {
            OnPlace = true;
        }


        if (Player)
        {
            if (AllBlocks.GetComponent <MoveBlocks> ().GetDoneToSpawn())
            {
                if (Player.GetComponent <MovePlayer> ().GetIsWin() && !AllBlocks.GetComponent <MoveBlocks> ().GetIsMoved() && isSpawn == false && Player.GetComponent <MovePlayer> ().GetIsReadyToSpawn())
                {
                    blockInst = blockInstNext;
                    SpawnBl();
                    OnPlace = false;
                    isSpawn = true;
                    AllBlocks.GetComponent <MoveBlocks> ().SetDoneToSpawn(false);
                    Player.GetComponent <MovePlayer> ().SetIsReadyToSpawn(false);
                }
            }
        }
    }
예제 #4
0
 //resizing the meta means existing virtual pointers are now pointing
 //to the wrong locations. not only are there now bad pointers in the
 //stream data but there are also pointers outside the stream that other
 //objects are using and we cant track or update those. rather than trying
 //to update all the pointers, this is a big hack to move all the data
 //into the positions that the pointers are now expecting it to be.
 private void ShiftAllocations(int offset)
 {
     //tag root must always start at 0
     foreach (var block in AllBlocks.Skip(1).Reverse())
     {
         block.Allocate(block.VirtualAddress + offset, block.AllocatedSize);
     }
 }
예제 #5
0
 public void Commit()
 {
     using (var writer = SourceItem.CacheFile.CreateWriter())
     {
         //save largest first: if they get reallocated then smaller blocks might be able to take their place
         foreach (var block in AllBlocks.OrderByDescending(b => b.VirtualSize))
         {
             block.Commit(writer);
         }
     }
 }
예제 #6
0
        /// <summary>
        /// Aggregate current index with next block
        /// </summary>
        /// <param name="nextBlock">nextBlock arg should be validated before</param>
        /// <returns></returns>
        public BlocksIndex Add(Block nextBlock)
        {
            if (IsEmpty)
            {
                throw new InvalidOperationException("Index in empty");
            }

            var allBlocks    = AllBlocks.Add(nextBlock);
            var blocksByHash = BlocksByHash.Add(nextBlock.Signature, nextBlock);

            return(new BlocksIndex(allBlocks, BlocksByHash));
        }
예제 #7
0
 void Awake()
 {
     if (blocks == null)
     {
         DontDestroyOnLoad(gameObject);
         blocks = this;
     }
     else if (blocks != this)
     {
         Destroy(gameObject);
     }
 }
예제 #8
0
        private void Start()
        {
            allBackgroundCells = new GameObject[Width * Height];
            for (int x = 0; x < Width; ++x)
            {
                for (int y = 0; y < Height; ++y)
                {
                    GameObject newCell = Instantiate <GameObject>(emptyCell, ConvertGridToWorldPosition(x, y), Quaternion.identity);
                    newCell.transform.SetParent(gridBackgroundParent);
                    allBackgroundCells[y + (x * Height)] = newCell;
                }
            }

            if (LastGameSettings.Instance.RestoreGridSettings() == false)
            {
                AllBlocks.FillGrid(this, numRowsFilledOnStart, NumberOfBlockTypes, difficulty.BlocksInARow);
            }
            scanner.Setup();
        }
예제 #9
0
 protected override void SetChecksums()
 {
     BoxLayout.SaveBattleTeams();
     AllBlocks.SetChecksums(Data);
 }
        public SequencerViewModel(Timeline model)
        {
            this.model = model;

            ActionManager  = new GuiLabs.Undo.ActionManager();
            SelectedBlocks = new ObservableCollection <BlockViewModel>();
            SelectionData  = new SelectionProperties(this);
            Tracks         = model.Tracks.Select(g => new TrackViewModel(this, g));
            MusicSegments  = model.MusicSegments.Select(seg => new MusicSegmentViewModel(this, seg));
            AllBlocks      = model.Blocks.Select(b => BlockViewModel.FromModel(this, b));

            if (Tracks.Count > 0)
            {
                SelectedTrack = Tracks[0];
            }

            ActiveMusicSegment = MusicSegments[model.DefaultMusicSegment.GetIndex()];
            Playback           = new PlaybackViewModel(this);
            Visualization      = new VisualizationViewModel(this);
            Notes = new NotesViewModel(this);

            if (model.MusicFileName != null)
            {
                Playback.LoadFileAsync(model.MusicFileName).Forget();
            }

            Action <BlockViewModel> fn_SubscribeToBlock = bvm => ForwardPropertyEvents(nameof(bvm.EndTimeOccupied), bvm, nameof(TimelineLength));

            AllBlocks.ToList().ForEach(fn_SubscribeToBlock);
            AllBlocks.CollectionChanged += (_, e) =>
            {
                if (e.NewItems != null)
                {
                    e.NewItems.Cast <BlockViewModel>().ToList().ForEach(fn_SubscribeToBlock);
                }
                Notify(nameof(TimelineLength));
            };

            ForwardPropertyEvents(nameof(PipetteTarget), this, nameof(IsPipetteActive));
            ForwardPropertyEvents(nameof(CursorPosition), this,
                                  nameof(CursorPixelPosition), nameof(CursorPixelPositionOnViewport));
            ForwardPropertyEvents(nameof(TimePixelScale), this,
                                  nameof(CursorPixelPosition), nameof(CursorPixelPositionOnViewport),
                                  nameof(CurrentViewLeftPositionTime), nameof(CurrentViewRightPositionTime),
                                  nameof(TimelineWidth), nameof(GridInterval));
            ForwardPropertyEvents(nameof(ActiveMusicSegment), this,
                                  nameof(GridInterval));

            ForwardPropertyEvents(nameof(Playback.MusicDuration), Playback, nameof(TimelineLength));
            ForwardPropertyEvents(nameof(TimelineLength), this, nameof(TimelineWidth));

            ForwardCollectionEvents(SelectedBlocks,
                                    nameof(CanConvertToColor), nameof(CanConvertToRamp),
                                    nameof(CanConvertToAutoDeduced), nameof(ConvertAutoDeduceGestureText));

            Tracks.CollectionChanged += (_, e) =>
            {
                foreach (var b in AllBlocks)
                {
                    b.OnTracksCollectionChanged();
                }
            };

            // Disable pipette whenever the selection is modified.
            SelectedBlocks.CollectionChanged += (_, __) => PipetteTarget = null;
        }
예제 #11
0
파일: SAV8SWSH.cs 프로젝트: sukitpr/PKHeX
 public override SaveFile Clone() => new SAV8SWSH(BAK, AllBlocks.Select(z => z.Clone()).ToArray());
예제 #12
0
        public override void Rotate(TetrisGrid tetris)
        {
            int[][] grid = tetris.GetGrid();
            int     maxRight = grid[0].Length - 1, maxTop = grid.Length - 1;

            if (BottomedOut(tetris))
            {
                return;
            }
            UnDraw(tetris);
            switch (DegreesRotated)
            {
            case 0:
                if (PivotBlock.X + 1 > maxTop)
                {
                    PivotBlock.X -= 3;
                }
                else if (PivotBlock.X + 2 > maxTop)
                {
                    PivotBlock.X -= 2;
                }
                else if (PivotBlock.X + 3 > maxTop)
                {
                    PivotBlock.X -= 1;
                }
                AllBlocks.Clear();
                AllBlocks.Add(PivotBlock);
                AllBlocks.Add(new Block(PivotBlock.X + 1, PivotBlock.Y));
                AllBlocks.Add(new Block(PivotBlock.X + 2, PivotBlock.Y));
                AllBlocks.Add(new Block(PivotBlock.X + 3, PivotBlock.Y));
                LowestPoint          = PivotBlock.X + 3;
                this.DegreesRotated += 90;
                break;

            case 90:
                if (PivotBlock.Y - 1 < 0)
                {
                    PivotBlock.Y += 3;
                }
                else if (PivotBlock.Y - 2 < 0)
                {
                    PivotBlock.Y += 2;
                }
                else if (PivotBlock.Y - 3 < 0)
                {
                    PivotBlock.Y += 1;
                }
                AllBlocks.Clear();
                AllBlocks.Add(PivotBlock);
                AllBlocks.Add(new Block(PivotBlock.X, PivotBlock.Y - 1));
                AllBlocks.Add(new Block(PivotBlock.X, PivotBlock.Y - 2));
                AllBlocks.Add(new Block(PivotBlock.X, PivotBlock.Y - 3));
                LowestPoint          = PivotBlock.X;
                this.DegreesRotated += 90;
                break;

            case 180:
                if (PivotBlock.X - 1 < 0)
                {
                    PivotBlock.X += 3;
                }
                else if (PivotBlock.X - 2 < 0)
                {
                    PivotBlock.X += 2;
                }
                else if (PivotBlock.X - 3 < 0)
                {
                    PivotBlock.X += 1;
                }
                AllBlocks.Clear();
                AllBlocks.Add(PivotBlock);
                AllBlocks.Add(new Block(PivotBlock.X - 1, PivotBlock.Y));
                AllBlocks.Add(new Block(PivotBlock.X - 2, PivotBlock.Y));
                AllBlocks.Add(new Block(PivotBlock.X - 3, PivotBlock.Y));
                LowestPoint          = PivotBlock.X;
                this.DegreesRotated += 90;
                break;

            case 270:
                if (PivotBlock.Y + 1 > maxRight)
                {
                    PivotBlock.Y -= 3;
                }
                else if (PivotBlock.Y + 2 > maxRight)
                {
                    PivotBlock.Y -= 2;
                }
                else if (PivotBlock.Y + 3 > maxRight)
                {
                    PivotBlock.Y -= 1;
                }
                AllBlocks.Clear();
                AllBlocks.Add(PivotBlock);
                AllBlocks.Add(new Block(PivotBlock.X, PivotBlock.Y + 1));
                AllBlocks.Add(new Block(PivotBlock.X, PivotBlock.Y + 2));
                AllBlocks.Add(new Block(PivotBlock.X, PivotBlock.Y + 3));
                LowestPoint         = PivotBlock.X;
                this.DegreesRotated = 0;
                break;
            }
            Draw(tetris);
        }
예제 #13
0
 //if the block has no entries it will have zero virtual size, but if it has the right address we still want to return it so entries can be added
 public IBlockEditor GetBlockEditor(long address) => AllBlocks.FirstOrDefault(b => b.VirtualAddress == address || b.ContainsVirtualAddress(address));