コード例 #1
0
ファイル: RenderCell.cs プロジェクト: tuita520/outquest
 public void SetContent(RefCountedSprite content)
 {
     if (content == Content)
     {
         return;
     }
     if (Content != null)
     {
         Content.Release();
         Content.SpriteChanged -= OnSpriteLoaded;
     }
     Content = content;
     if (Content == null)
     {
         _renderer.sprite = _defaultSprite;
         return;
     }
     Content.SpriteChanged += OnSpriteLoaded;
     _renderer.sprite       = Content.Sprite;
     if (_renderer.sprite == null)
     {
         _renderer.sprite = _defaultSprite;
     }
     Content.AddReference();
 }
コード例 #2
0
    public void Shift(int deltaX, int deltaY)
    {
        Grid <RefCountedSprite> contentGrid = Grid <RefCountedSprite> .CreateEmpty(_grid);

        contentGrid.SetIDOffset(_grid.IDOffsetX, _grid.IDOffsetY);

        for (int i = contentGrid.IDOffsetY; i < contentGrid.IDOffsetY + contentGrid.Height; i++)
        {
            for (int j = contentGrid.IDOffsetX; j < contentGrid.IDOffsetX + contentGrid.Width; j++)
            {
                RefCountedSprite temp = _grid[j, i].GetContent();
                if (temp != null)
                {
                    temp.AddReference();
                }
                contentGrid[j, i] = temp;
            }
        }
        _grid.ShiftIDs(-deltaX, -deltaY);
        for (int i = _grid.IDOffsetY; i < _grid.IDOffsetY + _grid.Height; i++)
        {
            for (int j = _grid.IDOffsetX; j < _grid.IDOffsetX + _grid.Width; j++)
            {
                if (_grid[j, i] is Object)
                {
                    (_grid[j, i] as Object).name = "cell_" + j + "_" + i;
                }
                _grid[j, i].SetContent(contentGrid[j, i]);
            }
        }

        for (int i = contentGrid.IDOffsetY; i < contentGrid.IDOffsetY + contentGrid.Height; i++)
        {
            for (int j = contentGrid.IDOffsetX; j < contentGrid.IDOffsetX + contentGrid.Width; j++)
            {
                RefCountedSprite temp = contentGrid[j, i];
                if (temp != null)
                {
                    temp.Release();
                }
            }
        }
    }