コード例 #1
0
        private void AddZoneTriggers(MapPropertiesBrush brush, MapProperties properties)
        {
            brush.Selection.HasDifferentHasZoneTrigger = false;
            if (!brush.ActiveTileInfo.HasZoneTrigger)
            {
                brush.ActiveTileInfo.HasZoneTrigger = true;
                brush.ActiveTileInfo.HasZoneTrigger = true;
                brush.ActiveTileInfo.Zone           = new ZoneTrigger()
                {
                    TargetZone  = brush.ActiveTileInfo.Zone.TargetZone,
                    Transition  = brush.ActiveTileInfo.Zone.Transition,
                    TargetSpawn = brush.ActiveTileInfo.Zone.TargetSpawn
                };
            }

            foreach (var position in brush.Selection.Bounds.allPositionsWithin)
            {
                var tile = properties.AddOrGetTile(new Vector2Int(position.x, position.y));
                if (!tile.HasZoneTrigger)
                {
                    tile.HasZoneTrigger = true;
                    tile.Zone           = new ZoneTrigger()
                    {
                        TargetZone  = brush.ActiveTileInfo.Zone.TargetZone,
                        Transition  = brush.ActiveTileInfo.Zone.Transition,
                        TargetSpawn = brush.ActiveTileInfo.Zone.TargetSpawn
                    };
                }
            }

            properties.UpdateBounds();
        }
コード例 #2
0
        private void AddSpawnPoints(MapPropertiesBrush brush, MapProperties properties)
        {
            brush.Selection.HasDifferentHasSpawnPoint = false;
            if (!brush.ActiveTileInfo.HasSpawnPoint)
            {
                brush.ActiveTileInfo.HasSpawnPoint = true;
                brush.ActiveTileInfo.SpawnPoint    = new SpawnPoint()
                {
                    Name      = brush.ActiveTileInfo.SpawnPoint.Name,
                    Direction = brush.ActiveTileInfo.SpawnPoint.Direction,
                    Position  = brush.ActiveTileInfo.Position,
                    Layer     = CollisionLayer.One
                };
            }

            foreach (var position in brush.Selection.Bounds.allPositionsWithin)
            {
                var tile = properties.AddOrGetTile(new Vector2Int(position.x, position.y));
                if (!tile.HasSpawnPoint)
                {
                    tile.HasSpawnPoint = true;
                    tile.SpawnPoint    = new SpawnPoint()
                    {
                        Name      = brush.ActiveTileInfo.SpawnPoint.Name,
                        Direction = brush.ActiveTileInfo.SpawnPoint.Direction,
                        Position  = tile.Position,
                        Layer     = CollisionLayer.One
                    };
                }
            }

            properties.UpdateBounds();
        }
コード例 #3
0
        private void SetZoneTransitions(MapPropertiesBrush brush, MapProperties properties)
        {
            brush.Selection.HasDifferentZoneTransitions = false;

            foreach (var position in brush.Selection.Bounds.allPositionsWithin)
            {
                var tile = properties.AddOrGetTile(new Vector2Int(position.x, position.y));
                tile.Zone.Transition = brush.ActiveTileInfo.Zone.Transition;
            }

            properties.UpdateBounds();
        }
コード例 #4
0
        private void SetInstructions(MapPropertiesBrush brush, MapProperties properties, Instruction instructions)
        {
            brush.Selection.HasDifferentInstructions = false;
            brush.ActiveTileInfo.Instructions        = instructions;

            foreach (var position in brush.Selection.Bounds.allPositionsWithin)
            {
                var tile = properties.AddOrGetTile(new Vector2Int(position.x, position.y));
                tile.Instructions = instructions;
            }

            properties.UpdateBounds();
        }
コード例 #5
0
        private void SetTargetEncounters(MapPropertiesBrush brush, MapProperties properties, Encounter encounter)
        {
            brush.Selection.HasDifferentEncounters = false;
            brush.ActiveTileInfo.Encounter         = encounter;

            foreach (var position in brush.Selection.Bounds.allPositionsWithin)
            {
                var tile = properties.AddOrGetTile(new Vector2Int(position.x, position.y));
                tile.Encounter = encounter;
            }

            properties.UpdateBounds();
        }
コード例 #6
0
        private void SetSpawnPointDirections(MapPropertiesBrush brush, MapProperties properties, Vector2 direction)
        {
            brush.Selection.HasDifferentSpawnPointDirections = false;
            brush.ActiveTileInfo.SpawnPoint.Direction        = direction;

            foreach (var position in brush.Selection.Bounds.allPositionsWithin)
            {
                var tile = properties.AddOrGetTile(new Vector2Int(position.x, position.y));
                tile.SpawnPoint.Direction = direction;
            }

            properties.UpdateBounds();
        }
コード例 #7
0
        private void SetSpawnPointLayers(MapPropertiesBrush brush, MapProperties properties, int index)
        {
            var layer = (CollisionLayer)MathHelper.IntExponent(2, index);

            brush.Selection.HasDifferentSpawnPointLayers = false;
            brush.ActiveTileInfo.SpawnPoint.Layer        = layer;

            foreach (var position in brush.Selection.Bounds.allPositionsWithin)
            {
                var tile = properties.AddOrGetTile(new Vector2Int(position.x, position.y));
                tile.SpawnPoint.Layer = layer;
            }

            properties.UpdateBounds();
        }
コード例 #8
0
        private void AddEncounterTriggers(MapPropertiesBrush brush, MapProperties properties)
        {
            brush.Selection.HasDifferentHasEncounter = false;
            brush.ActiveTileInfo.HasEncounter        = true;

            foreach (var position in brush.Selection.Bounds.allPositionsWithin)
            {
                var tile = properties.AddOrGetTile(new Vector2Int(position.x, position.y));
                if (!tile.HasEncounter)
                {
                    tile.HasEncounter = true;
                    tile.Encounter    = brush.ActiveTileInfo.Encounter;
                }
            }

            properties.UpdateBounds();
        }
コード例 #9
0
        private void ChangeCollisionLayers(MapPropertiesBrush brush, MapProperties properties, CollisionLayer layer)
        {
            brush.Selection.HasDifferentCollisionLayer = false;
            brush.ActiveTileInfo.CollisionLayer        = layer;

            foreach (var position in brush.Selection.Bounds.allPositionsWithin)
            {
                if (layer == CollisionLayer.None)
                {
                    var tile = properties.GetTile(new Vector2Int(position.x, position.y));
                    if (tile != null)
                    {
                        tile.CollisionLayer = CollisionLayer.None;
                    }
                }
                else
                {
                    var tile = properties.AddOrGetTile(new Vector2Int(position.x, position.y));
                    tile.CollisionLayer = layer;
                }
            }

            var size      = brush.Selection.Bounds.size.x * brush.Selection.Bounds.size.y;
            var tileArray = Enumerable.Repeat(brush.CollisionTile, size).ToArray();
            var nullArray = new TileBase[size];

            for (int index = 0, value = 1; index < CollisionLayerData.LayerCount; index++, value *= 2)
            {
                if ((value & (int)layer) > 0)
                {
                    var tilemap = properties.AddOrGetCollisionLayer(index);
                    tilemap.SetTilesBlock(brush.Selection.Bounds, tileArray);
                }
                else
                {
                    var tilemap = properties.GetCollisionLayer(index);
                    if (tilemap)
                    {
                        tilemap.SetTilesBlock(brush.Selection.Bounds, nullArray);
                        properties.CheckForCollisionRemoval(tilemap, index);
                    }
                }
            }

            properties.UpdateBounds();
        }
コード例 #10
0
        private void SetCollisionIncrements(MapPropertiesBrush brush, MapProperties properties, int index)
        {
            var layer = index == 0 ? CollisionLayer.None : (CollisionLayer)MathHelper.IntExponent(2, index - 1);

            brush.Selection.HasDifferentCollisionIncrement = false;
            brush.ActiveTileInfo.CollisionLayerIncrement   = layer;

            foreach (var position in brush.Selection.Bounds.allPositionsWithin)
            {
                if (layer == CollisionLayer.None)
                {
                    var tile = properties.GetTile(new Vector2Int(position.x, position.y));
                    tile.CollisionLayerIncrement = CollisionLayer.None;
                }
                else
                {
                    var tile = properties.AddOrGetTile(new Vector2Int(position.x, position.y));
                    tile.CollisionLayerIncrement = layer;
                }
            }

            properties.UpdateBounds();
        }