Esempio n. 1
0
        private void StartFillSequence(PointerEventInfo info)
        {
            if (!SourceValid)
            {
                return;
            }

            TileCoord location = TileLocation(info);

            if (!TileInRange(location))
            {
                return;
            }

            if (SourceType == TileSourceType.Brush)
            {
                Layer.TileAdding   += TileAddingHandler;
                Layer.TileRemoving += TileRemovingHandler;
            }

            _fillLayer   = Layer;
            _sourceStack = new TileStack();
            _sourceStack.Add(ActiveTile);

            _fillCommand = new TileReplace2DCommand(Layer);
            FloodFill(location.X, location.Y);

            if (SourceType == TileSourceType.Brush)
            {
                Layer.TileAdding   -= TileAddingHandler;
                Layer.TileRemoving -= TileRemovingHandler;
            }

            History.Execute(_fillCommand);
        }
        public void QueueReplacement(TileCoord coord, Tile replacement)
        {
            TileStack srcStack = null;

            if (_tileSource.InRange(coord))
            {
                srcStack = new TileStack(_tileSource[coord]);
            }

            TileStack stack = null;

            if (replacement != null)
            {
                stack = new TileStack();
                stack.Add(replacement);
            }

            if (_tiles.ContainsKey(coord))
            {
                _tiles[coord] = new TileRecord(_tiles[coord].Original, stack);
            }
            else
            {
                _tiles[coord] = new TileRecord(srcStack, stack);
            }
        }
Esempio n. 3
0
        public void FloodFill(int x, int y)
        {
            _ranges = new FloodFillRangeQueue((_fillLayer.TilesWide + _fillLayer.TilesHigh) / 2 * 5);

            _matchStack = _fillLayer[x, y];

            LinearFill(ref x, ref y);

            while (_ranges.Count > 0)
            {
                FloodFillRange range = _ranges.Dequeue();

                int upY   = range.Y - 1;
                int downY = range.Y + 1;

                TileCoord tid;
                for (int i = range.StartX; i <= range.EndX; i++)
                {
                    tid = new TileCoord(i, upY);
                    if (range.Y > 0 && /*!_sourceStack.Equals(_fillLayer[tid]) &&*/
                        (_matchStack == null ? _matchStack == _fillLayer[tid] : _matchStack.Equals(_fillLayer[tid])))
                    {
                        LinearFill(ref i, ref upY);
                    }

                    tid = new TileCoord(i, downY);
                    if (range.Y < (_fillLayer.TilesHigh - 1) && /*!_sourceStack.Equals(_fillLayer[tid]) &&*/
                        (_matchStack == null ? _matchStack == _fillLayer[tid] : _matchStack.Equals(_fillLayer[tid])))
                    {
                        LinearFill(ref i, ref downY);
                    }
                }
            }
        }
Esempio n. 4
0
        internal TileLayer(ContentReader reader, TileRegistry registry)
            : base(reader)
        {
            _registry = registry;

            TileWidth = reader.ReadInt16();
            TileHeight = reader.ReadInt16();
            Width = reader.ReadInt16();
            Height = reader.ReadInt16();

            _tiles = new TileGrid(Width, Height);

            int stackCount = reader.ReadInt32();
            for (int i = 0; i < stackCount; i++) {
                int dx = reader.ReadInt16();
                int dy = reader.ReadInt16();

                int tcount = reader.ReadInt16();
                Tile[] st = new Tile[tcount];

                for (int j = 0; j < tcount; j++) {
                    st[j] = _registry[reader.ReadInt16()];
                }

                _tiles[dx, dy] = new TileStack(st);
            }
        }
        public void QueueAdd(TileCoord coord, TileStack stack)
        {
            if (stack != null)
            {
                TileStack srcStack = null;
                if (_tileSource.InRange(coord))
                {
                    srcStack = new TileStack(_tileSource[coord]);
                }

                TileStack newStack = new TileStack(srcStack);
                foreach (Tile t in stack)
                {
                    newStack.Add(t);
                }

                if (_tiles.ContainsKey(coord))
                {
                    _tiles[coord] = new TileRecord(_tiles[coord].Original, stack);
                }
                else
                {
                    _tiles[coord] = new TileRecord(srcStack, newStack);
                }
            }
        }
Esempio n. 6
0
        public void FloodFill(int x, int y)
        {
            _ranges = new FloodFillRangeQueue((_fillLayer.TilesWide + _fillLayer.TilesHigh) / 2 * 5);

            _matchStack = _fillLayer[x, y];

            LinearFill(ref x, ref y);

            while (_ranges.Count > 0) {
                FloodFillRange range = _ranges.Dequeue();

                int upY = range.Y - 1;
                int downY = range.Y + 1;

                TileCoord tid;
                for (int i = range.StartX; i <= range.EndX; i++) {
                    tid = new TileCoord(i, upY);
                    if (range.Y > 0 && /*!_sourceStack.Equals(_fillLayer[tid]) &&*/
                        (_matchStack == null ? _matchStack == _fillLayer[tid] : _matchStack.Equals(_fillLayer[tid])))
                        LinearFill(ref i, ref upY);

                    tid = new TileCoord(i, downY);
                    if (range.Y < (_fillLayer.TilesHigh - 1) && /*!_sourceStack.Equals(_fillLayer[tid]) &&*/
                        (_matchStack == null ? _matchStack == _fillLayer[tid] : _matchStack.Equals(_fillLayer[tid])))
                        LinearFill(ref i, ref downY);
                }
            }
        }
Esempio n. 7
0
        public TileReplace2DCommand(MultiTileGridLayer source, Dictionary<TileCoord, Tile> tileData)
            : this(source)
        {
            foreach (KeyValuePair<TileCoord, Tile> kv in tileData) {
                TileStack stack = new TileStack();
                stack.Add(kv.Value);

                _tiles[kv.Key] = new TileRecord(_tileSource[kv.Key], stack);
            }
        }
Esempio n. 8
0
        public void ClearEmptyTest()
        {
            TileStack stack = new TileStack();
            AttachEvents(stack);

            stack.Clear();

            Assert.AreEqual(EventFlags.None, _eventsFired);
            Assert.AreEqual(0, stack.Count);
        }
Esempio n. 9
0
        public void ClearEmptyTest()
        {
            TileStack stack = new TileStack();

            AttachEvents(stack);

            stack.Clear();

            Assert.AreEqual(EventFlags.None, _eventsFired);
            Assert.AreEqual(0, stack.Count);
        }
Esempio n. 10
0
        public void AddTileTest()
        {
            TileStack stack = new TileStack();
            AttachEvents(stack);

            stack.Add(_tile1);

            Assert.AreEqual(EventFlags.Modified, _eventsFired);
            Assert.AreEqual(1, stack.Count);
            Assert.AreSame(_tile1, stack.Top);
        }
Esempio n. 11
0
        public void AddTileDuplicateTest()
        {
            TileStack stack = new TileStack();

            stack.Add(_tile1);
            stack.Add(_tile1);

            Assert.AreEqual(2, stack.Count);
            Assert.AreEqual(_tile1, stack[0]);
            Assert.AreEqual(_tile1, stack[1]);
        }
Esempio n. 12
0
        public TileReplace2DCommand(MultiTileGridLayer source, Dictionary <TileCoord, Tile> tileData)
            : this(source)
        {
            foreach (KeyValuePair <TileCoord, Tile> kv in tileData)
            {
                TileStack stack = new TileStack();
                stack.Add(kv.Value);

                _tiles[kv.Key] = new TileRecord(_tileSource[kv.Key], stack);
            }
        }
Esempio n. 13
0
        public void AddTileDuplicateTest()
        {
            TileStack stack = new TileStack();

            stack.Add(_tile1);
            stack.Add(_tile1);

            Assert.AreEqual(2, stack.Count);
            Assert.AreEqual(_tile1, stack[0]);
            Assert.AreEqual(_tile1, stack[1]);
        }
Esempio n. 14
0
        public void AddTileTest2()
        {
            TileStack stack = new TileStack();

            stack.Add(_tile1);
            stack.Add(_tile2);

            Assert.AreEqual(2, stack.Count);
            Assert.AreEqual(_tile1, stack[0]);
            Assert.AreEqual(_tile2, stack[1]);
            Assert.AreEqual(_tile2, stack.Top);
        }
Esempio n. 15
0
        public void AddTileTest()
        {
            TileStack stack = new TileStack();

            AttachEvents(stack);

            stack.Add(_tile1);

            Assert.AreEqual(EventFlags.Modified, _eventsFired);
            Assert.AreEqual(1, stack.Count);
            Assert.AreSame(_tile1, stack.Top);
        }
Esempio n. 16
0
        public void AddTileTest2()
        {
            TileStack stack = new TileStack();

            stack.Add(_tile1);
            stack.Add(_tile2);

            Assert.AreEqual(2, stack.Count);
            Assert.AreEqual(_tile1, stack[0]);
            Assert.AreEqual(_tile2, stack[1]);
            Assert.AreEqual(_tile2, stack.Top);
        }
Esempio n. 17
0
 private void AddTile(MultiTileGridLayer layer, TileCoord location)
 {
     if (!_tiles.ContainsKey(location))
     {
         TileStack stack = layer.TileStacksAt(location);
         if (!TileStack.NullOrEmpty(stack))
         {
             _tiles.Add(location, stack);
         }
         _tileAnnot.AddTileLocation(location);
     }
 }
Esempio n. 18
0
        public void CloneStackTest()
        {
            TileStack stack = new TileStack();

            stack.Add(_tile1);
            stack.Add(_tile2);

            TileStack stack2 = stack.Clone() as TileStack;

            Assert.AreEqual(2, stack2.Count);
            Assert.AreSame(_tile1, stack2[0]);
            Assert.AreSame(_tile2, stack2[1]);
        }
Esempio n. 19
0
        public void CreateStackCopyConstructorTest()
        {
            TileStack stack = new TileStack();

            stack.Add(_tile1);
            stack.Add(_tile2);

            TileStack stack2 = new TileStack(stack);

            Assert.AreEqual(2, stack2.Count);
            Assert.AreSame(_tile1, stack2[0]);
            Assert.AreSame(_tile2, stack2[1]);
        }
Esempio n. 20
0
 public TileSelectionClipboard(IDictionary <TileCoord, TileStack> tiles)
 {
     _tiles = new Dictionary <TileCoord, Guid[]>();
     foreach (KeyValuePair <TileCoord, TileStack> kvp in tiles)
     {
         Guid[] stack = TileStack.NullOrEmpty(kvp.Value) ? new Guid[0] : new Guid[kvp.Value.Count];
         for (int i = 0; i < stack.Length; i++)
         {
             stack[i] = kvp.Value[i].Uid;
         }
         _tiles.Add(kvp.Key, stack);
     }
 }
Esempio n. 21
0
 public void AddTiles(IDictionary <TileCoord, TileStack> tiles)
 {
     foreach (KeyValuePair <TileCoord, TileStack> kvp in tiles)
     {
         if (!_tiles.ContainsKey(kvp.Key))
         {
             if (!TileStack.NullOrEmpty(kvp.Value))
             {
                 _tiles.Add(kvp.Key, kvp.Value);
             }
             _tileAnnot.AddTileLocation(kvp.Key);
         }
     }
 }
Esempio n. 22
0
        public void ClearTest()
        {
            TileStack stack = new TileStack();

            stack.Add(_tile1);
            stack.Add(_tile2);

            AttachEvents(stack);

            stack.Clear();

            Assert.AreEqual(EventFlags.Modified, _eventsFired);
            Assert.AreEqual(0, stack.Count);
        }
Esempio n. 23
0
 public void AddTiles(IEnumerable <LocatedTileStack> tiles)
 {
     foreach (LocatedTileStack stack in tiles)
     {
         if (!_tiles.ContainsKey(stack.Location))
         {
             if (!TileStack.NullOrEmpty(stack.Stack))
             {
                 _tiles.Add(stack.Location, stack.Stack);
             }
             _tileAnnot.AddTileLocation(stack.Location);
         }
     }
 }
Esempio n. 24
0
        public void QueueAdd(TileCoord coord, Tile tile)
        {
            if (tile != null) {
                TileStack srcStack = null;
                if (_tileSource.InRange(coord))
                    srcStack = new TileStack(_tileSource[coord]);

                TileStack stack = new TileStack(srcStack);
                stack.Add(tile);

                if (_tiles.ContainsKey(coord))
                    _tiles[coord] = new TileRecord(_tiles[coord].Original, stack);
                else
                    _tiles[coord] = new TileRecord(srcStack, stack);
            }
        }
Esempio n. 25
0
        public void RemoveTileNullTest()
        {
            TileStack stack = new TileStack();

            stack.Add(_tile1);
            stack.Add(_tile2);

            AttachEvents(stack);

            stack.Remove(null);

            Assert.AreEqual(EventFlags.None, _eventsFired);
            Assert.AreEqual(2, stack.Count);
            Assert.AreEqual(_tile1, stack[0]);
            Assert.AreEqual(_tile2, stack[1]);
        }
Esempio n. 26
0
        public void RemoveTileNotPresentTest()
        {
            TileStack stack = new TileStack();

            stack.Add(_tile1);
            stack.Add(_tile2);

            AttachEvents(stack);

            Texture2D texture = new Texture2D(_service.GraphicsDevice, 16, 16);
            Tile      tile3   = _pool.GetTile(_pool.AddTile(texture));

            stack.Remove(tile3);

            Assert.AreEqual(EventFlags.None, _eventsFired);
            Assert.AreEqual(2, stack.Count);
            Assert.AreEqual(_tile1, stack[0]);
            Assert.AreEqual(_tile2, stack[1]);
        }
        private void Start()
        {
            _adventureMap = new Map();
            _mapView      = new MapView(_adventureMap);

            SetUpPlayers(AdventureManager.GetDefaultPlayers());
            _adventureController = new AdventureController(new Adventure(AdventureManager.GetDefaultAdventure1()), _adventureMap, _uiController);
            _adventureMap.SetStartingPlayersPosition(_players.ToArray());

            _tileStack = new TileStack();
            _adventureController.PrepareTileStackForAdventure(_tileStack, AdventureManager.CurrentAdventureName);

            AttachEventHandlers();

            _turnController.TakeTurn(_players[NextplayerIndex()]);

            _uiController.UpdateUI();
            TriggerEvent("StartTile");
        }
Esempio n. 28
0
        public void QueueReplacement(TileCoord coord, TileStack replacement)
        {
            TileStack srcStack = null;

            if (_tileSource.InRange(coord))
            {
                srcStack = new TileStack(_tileSource[coord]);
            }

            replacement = (replacement != null) ? new TileStack(replacement) : null;

            if (_tiles.ContainsKey(coord))
            {
                _tiles[coord] = new TileRecord(_tiles[coord].Original, replacement);
            }
            else
            {
                _tiles[coord] = new TileRecord(srcStack, replacement);
            }
        }
Esempio n. 29
0
        public TileSelection GetAsTileSelection(Project project, int tileWidth, int tileHeight)
        {
            Dictionary<TileCoord, TileStack> xlat = new Dictionary<TileCoord, TileStack>();
            foreach (KeyValuePair<TileCoord, Guid[]> item in _tiles) {
                TileStack stack = new TileStack();

                foreach (Guid tileId in item.Value) {
                    TilePool pool = project.TilePoolManager.PoolFromItemKey(tileId);
                    Tile tile = pool.GetTile(tileId);
                    stack.Add(tile);
                }

                xlat.Add(item.Key, stack);
            }

            TileSelection selection = new TileSelection(tileWidth, tileHeight);
            selection.AddTiles(xlat);

            return selection;
        }
Esempio n. 30
0
        public void QueueRemove(TileCoord coord, Tile tile)
        {
            if (tile != null)
            {
                TileStack srcStack = null;
                if (_tileSource.InRange(coord))
                {
                    srcStack = new TileStack(_tileSource[coord]);
                }

                TileStack stack = new TileStack(srcStack);
                stack.Remove(tile);

                if (_tiles.ContainsKey(coord))
                {
                    _tiles[coord] = new TileRecord(_tiles[coord].Original, stack);
                }
                else
                {
                    _tiles[coord] = new TileRecord(srcStack, stack);
                }
            }
        }
Esempio n. 31
0
        public TileSelection GetAsTileSelection(Project project, int tileWidth, int tileHeight)
        {
            Dictionary <TileCoord, TileStack> xlat = new Dictionary <TileCoord, TileStack>();

            foreach (KeyValuePair <TileCoord, Guid[]> item in _tiles)
            {
                TileStack stack = new TileStack();

                foreach (Guid tileId in item.Value)
                {
                    TilePool pool = project.TilePoolManager.PoolFromItemKey(tileId);
                    Tile     tile = pool.GetTile(tileId);
                    stack.Add(tile);
                }

                xlat.Add(item.Key, stack);
            }

            TileSelection selection = new TileSelection(tileWidth, tileHeight);

            selection.AddTiles(xlat);

            return(selection);
        }
Esempio n. 32
0
 private void AttachEvents(TileStack stack)
 {
     stack.Modified += (s, e) => { _eventsFired |= EventFlags.Modified; };
 }
Esempio n. 33
0
 public LocatedTileStack(TileStack tileStack, int x, int y)
 {
     _tileStack = tileStack;
     _tileCoord = new TileCoord(x, y);
 }
    IEnumerator Start()
    {
        // Create Input Textures
        _inputTexture  = new Texture2D(INPUT_WIDTH, INPUT_HEIGHT);
        _outputTexture = new Texture2D(OutputSizeX, OutputSizeY);

        // Step 1: Input Texture 5x5, white outer, black ring, red inner
        SetInput();

        // Step 2: Render The Input Texture
        SetInputTextureColors();
        InputRenderer.material.mainTexture = _inputTexture;

        // Step 3: Profit, create 3x3 tiles
        List <Tile> tiles = CreateTiles();

        // Step 4: Create Stacks
        int pixelCount = OutputSizeX * OutputSizeY;

        TileStack[] tileStacks = new TileStack[pixelCount];
        for (int i = 0; i < pixelCount; i++)
        {
            tileStacks[i] = new TileStack();
            tileStacks[i].AddRange(tiles);
        }

        yield return(null);

        // Step 5: Pick random pixel and tile, set it's color
        Color[] outputColors = new Color[pixelCount];
        for (int i = 0; i < pixelCount; i++)
        {
            outputColors[i] = Color.magenta;
        }

        int lowestEntropyStackIndex = Random.Range(0, pixelCount);         // Pick random first stack

        // Step 6: Collapse the Waveform!
        bool allStacksResolved = false;

        while (!allStacksResolved)
        {
            // Pick Random Tile from lowest entropy stack
            Tile resolvedTile = PickRandomTile(tileStacks, lowestEntropyStackIndex);
            _consideredStacks.Add(lowestEntropyStackIndex);

            // TODO: Only pick tilesif there are valid options remaining on all adjacent pixels?
            // Q: This should happen automatically with a valid input set?
            // Might also be possible to backtrack if all stacks are removed by a choice, however an input validator is probably easier

            outputColors[lowestEntropyStackIndex] = resolvedTile.GetColor(1, 1);
            // TODO: Stamp full tile not just center position

            int x = lowestEntropyStackIndex % OutputSizeX, y = lowestEntropyStackIndex / OutputSizeX;
            int stackIndex = 0;
            for (int xOffset = x - 1; xOffset <= x + 1; xOffset++)
            {
                for (int yOffset = y - 1; yOffset <= y + 1; yOffset++)
                {
                    if (xOffset >= 0 && yOffset >= 0 && xOffset < OutputSizeX && yOffset < OutputSizeY && !(xOffset == x && yOffset == y))
                    {
                        stackIndex = xOffset + yOffset * OutputSizeX;
                        var stack = tileStacks[stackIndex];
                        for (int index = stack.Count - 1; index >= 0; index--)
                        {
                            // TODO: Check against all resolved output colours
                            if (!stack[index].HasValidOverlap(outputColors[lowestEntropyStackIndex], xOffset - x, yOffset - y))
                            {
                                if (stack.Count > 1)
                                {
                                    stack.RemoveAt(index);
                                }
                                else
                                {
                                    Debug.LogError("Ran out of valid tiles");
                                }
                            }
                        }
                    }
                }
            }

            allStacksResolved = _consideredStacks.Count == tileStacks.Length;

            if (!allStacksResolved)
            {
                lowestEntropyStackIndex = GetLowestEntropyStackIndex(tileStacks);
            }

            SetOutputTextureColors(outputColors);
            OutputRenderer.material.mainTexture = _outputTexture;

            yield return(null);
        }

        // Step 7: Render the output
        SetOutputTextureColors(outputColors);
        OutputRenderer.material.mainTexture = _outputTexture;
    }
Esempio n. 35
0
        public TileStack this[int x, int y]
        {
            get
            {
                CheckBoundsFail(x, y);
                return _tiles[YIndex(y), XIndex(x)];
            }

            set
            {
                CheckBoundsFail(x, y);

                int xi = XIndex(x);
                int yi = YIndex(y);

                if (_tiles[yi, xi] != null) {
                    _tiles[yi, xi].Modified -= TileStackModifiedHandler;
                }

                if (value != null) {
                    _tiles[yi, xi] = new TileStack(value);
                    _tiles[yi, xi].Modified += TileStackModifiedHandler;
                }
                else {
                    _tiles[yi, xi] = null;
                }

                OnModified(EventArgs.Empty);
            }
        }
Esempio n. 36
0
 public void CreateStack()
 {
     tileStack = new TileStack(tilesNames, tilesCounts);
 }
Esempio n. 37
0
        private void StartFillSequence(PointerEventInfo info)
        {
            if (!SourceValid)
                return;

            TileCoord location = TileLocation(info);
            if (!TileInRange(location))
                return;

            if (SourceType == TileSourceType.Brush) {
                Layer.TileAdding += TileAddingHandler;
                Layer.TileRemoving += TileRemovingHandler;
            }

            _fillLayer = Layer;
            _sourceStack = new TileStack();
            _sourceStack.Add(ActiveTile);

            _fillCommand = new TileReplace2DCommand(Layer);
            FloodFill(location.X, location.Y);

            if (SourceType == TileSourceType.Brush) {
                Layer.TileAdding -= TileAddingHandler;
                Layer.TileRemoving -= TileRemovingHandler;
            }

            History.Execute(_fillCommand);
        }
Esempio n. 38
0
        public void CloneStackTest()
        {
            TileStack stack = new TileStack();

            stack.Add(_tile1);
            stack.Add(_tile2);

            TileStack stack2 = stack.Clone() as TileStack;

            Assert.AreEqual(2, stack2.Count);
            Assert.AreSame(_tile1, stack2[0]);
            Assert.AreSame(_tile2, stack2[1]);
        }
Esempio n. 39
0
        public void QueueReplacement(TileCoord coord, TileStack replacement)
        {
            TileStack srcStack = null;
            if (_tileSource.InRange(coord))
                srcStack = new TileStack(_tileSource[coord]);

            replacement = (replacement != null) ? new TileStack(replacement) : null;

            if (_tiles.ContainsKey(coord))
                _tiles[coord] = new TileRecord(_tiles[coord].Original, replacement);
            else
                _tiles[coord] = new TileRecord(srcStack, replacement);
        }
Esempio n. 40
0
 public LocatedTileStack(TileStack tileStack, TileCoord location)
 {
     _tileStack = tileStack;
     _tileCoord = location;
 }
Esempio n. 41
0
 public LocatedTileStack(TileStack tileStack, TileCoord location)
 {
     _tileStack = tileStack;
     _tileCoord = location;
 }
Esempio n. 42
0
        public void ClearTest()
        {
            TileStack stack = new TileStack();

            stack.Add(_tile1);
            stack.Add(_tile2);

            AttachEvents(stack);

            stack.Clear();

            Assert.AreEqual(EventFlags.Modified, _eventsFired);
            Assert.AreEqual(0, stack.Count);
        }
Esempio n. 43
0
        protected override void ResizeLayer(int newOriginX, int newOriginY, int newTilesWide, int newTilesHigh)
        {
            TileStack[,] newTiles = new TileStack[newTilesHigh, newTilesWide];
            int copyLimX = Math.Min(TilesWide, newTilesWide);
            int copyLimY = Math.Min(TilesHigh, newTilesHigh);

            for (int y = 0; y < copyLimY; y++) {
                for (int x = 0; x < copyLimX; x++) {
                    newTiles[y, x] = _tiles[y, x];
                }
            }

            _tiles = newTiles;
        }
Esempio n. 44
0
 private void AttachEvents(TileStack stack)
 {
     stack.Modified += (s, e) => { _eventsFired |= EventFlags.Modified; };
 }
Esempio n. 45
0
 public TileRecord(TileStack original, TileStack replacement)
 {
     Original    = original;
     Replacement = replacement;
 }
Esempio n. 46
0
 public LocatedTileStack(TileStack tileStack, int x, int y)
 {
     _tileStack = tileStack;
     _tileCoord = new TileCoord(x, y);
 }
Esempio n. 47
0
 public BoardHex(TileStack stack, bool isDropTarget)
 {
     _stack       = stack;
     IsDropTarget = isDropTarget;
 }
Esempio n. 48
0
        public void CreateStackCopyConstructorTest()
        {
            TileStack stack = new TileStack();

            stack.Add(_tile1);
            stack.Add(_tile2);

            TileStack stack2 = new TileStack(stack);

            Assert.AreEqual(2, stack2.Count);
            Assert.AreSame(_tile1, stack2[0]);
            Assert.AreSame(_tile2, stack2[1]);
        }
Esempio n. 49
0
        public void QueueReplacement(TileCoord coord, Tile replacement)
        {
            TileStack srcStack = null;
            if (_tileSource.InRange(coord))
                srcStack = new TileStack(_tileSource[coord]);

            TileStack stack = null;
            if (replacement != null) {
                stack = new TileStack();
                stack.Add(replacement);
            }

            if (_tiles.ContainsKey(coord))
                _tiles[coord] = new TileRecord(_tiles[coord].Original, stack);
            else
                _tiles[coord] = new TileRecord(srcStack, stack);
        }
Esempio n. 50
0
 public void AddTileStack(int x, int y, TileStack stack)
 {
     if (stack != null) {
         foreach (Tile t in stack) {
             AddTile(x, y, t);
         }
     }
 }
Esempio n. 51
0
 public TileRecord(TileStack original, TileStack replacement)
 {
     Original = original;
     Replacement = replacement;
 }
Esempio n. 52
0
        protected override void AddTileImpl(int x, int y, Tile tile)
        {
            int xi = XIndex(x);
            int yi = YIndex(y);

            if (_tiles[yi, xi] == null) {
                _tiles[yi, xi] = new TileStack();
                _tiles[yi, xi].Modified += TileStackModifiedHandler;
            }

            _tiles[yi, xi].Remove(tile);
            _tiles[yi, xi].Add(tile);
        }
 public void PrepareTileStackForAdventure(TileStack tileStack, string adventureName)
 {
     tileStack.SetSpecialTile("UndergroundRiver", 8);
     tileStack.GenerateTileStack();
     tileStack.ShuffleTileStack();
 }
Esempio n. 54
0
        protected override void ResizeLayer(int newOriginX, int newOriginY, int newTilesWide, int newTilesHigh)
        {
            int originDiffX = newOriginX - TileOriginX;
            int originDiffY = newOriginY - TileOriginY;

            int maxOriginX = Math.Max(newOriginX, TileOriginX);
            int maxOriginY = Math.Max(newOriginY, TileOriginY);
            int minEndX = Math.Min(newOriginX + newTilesWide, TileOriginX + TilesWide);
            int minEndY = Math.Min(newOriginY + newTilesHigh, TileOriginY + TilesHigh);

            int startX = maxOriginX - TileOriginX;
            int startY = maxOriginY - TileOriginY;
            int limitX = minEndX - maxOriginX;
            int limitY = minEndY - maxOriginY;

            TileStack[,] newTiles = new TileStack[newTilesHigh, newTilesWide];

            for (int y = startY; y < limitY; y++) {
                for (int x = startX; x < limitX; x++) {
                    newTiles[y - originDiffY, x - originDiffX] = _tiles[y, x];
                }
            }

            _tiles = newTiles;
        }
Esempio n. 55
0
        public void RemoveTileNullTest()
        {
            TileStack stack = new TileStack();

            stack.Add(_tile1);
            stack.Add(_tile2);

            AttachEvents(stack);

            stack.Remove(null);

            Assert.AreEqual(EventFlags.None, _eventsFired);
            Assert.AreEqual(2, stack.Count);
            Assert.AreEqual(_tile1, stack[0]);
            Assert.AreEqual(_tile2, stack[1]);
        }
Esempio n. 56
0
        public void RemoveTileNotPresentTest()
        {
            TileStack stack = new TileStack();

            stack.Add(_tile1);
            stack.Add(_tile2);

            AttachEvents(stack);

            Texture2D texture = new Texture2D(_service.GraphicsDevice, 16, 16);
            Tile tile3 = _pool.GetTile(_pool.AddTile(texture));

            stack.Remove(tile3);

            Assert.AreEqual(EventFlags.None, _eventsFired);
            Assert.AreEqual(2, stack.Count);
            Assert.AreEqual(_tile1, stack[0]);
            Assert.AreEqual(_tile2, stack[1]);
        }