Ejemplo n.º 1
0
        public override void Select(GridLayout grid, GameObject brushTarget, BoundsInt bounds)
        {
            var translate = new Vector3Int(Mathf.FloorToInt(brushTarget.transform.position.x), Mathf.FloorToInt(brushTarget.transform.position.y), Mathf.FloorToInt(brushTarget.transform.position.z));

            bounds.SetMinMax(bounds.min + translate, bounds.max + translate);

            Selection.Reset(grid, brushTarget, bounds);

            var properties = AddOrGetProperties(grid);

            foreach (var position in Selection.Bounds.allPositionsWithin)
            {
                var tile = properties.GetTile(new Vector2Int(position.x, position.y));
                if (tile != null)
                {
                    Selection.SelectedTiles.Add(tile);
                }
                else
                {
                    Selection.HasEmptySelected = true;
                }
            }

            ActiveTileInfo = Selection.SelectedTiles.Count == 0 ? new TileInfo() : Selection.SelectedTiles[0];

            foreach (var tile in Selection.SelectedTiles)
            {
                if (ActiveTileInfo.CollisionLayer != tile.CollisionLayer || (ActiveTileInfo.CollisionLayer != CollisionLayer.None && Selection.HasEmptySelected))
                {
                    Selection.HasDifferentCollisionLayer = true;
                }

                if (ActiveTileInfo.CollisionLayerIncrement != tile.CollisionLayerIncrement || (ActiveTileInfo.CollisionLayerIncrement != CollisionLayer.None && Selection.HasEmptySelected))
                {
                    Selection.HasDifferentCollisionIncrement = true;
                }

                if ((!ActiveTileInfo.HasSpawnPoint && tile.HasSpawnPoint) || (ActiveTileInfo.HasSpawnPoint && Selection.HasEmptySelected))
                {
                    Selection.HasDifferentHasSpawnPoint = true;
                }

                if ((!ActiveTileInfo.HasZoneTrigger && tile.HasZoneTrigger) || (ActiveTileInfo.HasZoneTrigger && Selection.HasEmptySelected))
                {
                    Selection.HasDifferentHasZoneTrigger = true;
                }

                if ((!ActiveTileInfo.HasEncounter && tile.HasEncounter) || (ActiveTileInfo.HasEncounter && Selection.HasEmptySelected))
                {
                    Selection.HasDifferentHasEncounter = true;
                }

                if ((!ActiveTileInfo.HasInstructions && tile.HasInstructions) || (ActiveTileInfo.HasInstructions && Selection.HasEmptySelected))
                {
                    Selection.HasDifferentHasInstructions = true;
                }
            }

            if (ActiveTileInfo.HasSpawnPoint && !Selection.HasDifferentHasSpawnPoint)
            {
                foreach (var tile in Selection.SelectedTiles)
                {
                    if (ActiveTileInfo.SpawnPoint.Name != tile.SpawnPoint.Name)
                    {
                        Selection.HasDifferentSpawnPointNames = true;
                    }

                    if (ActiveTileInfo.SpawnPoint.Direction != tile.SpawnPoint.Direction)
                    {
                        Selection.HasDifferentSpawnPointDirections = true;
                    }

                    if (ActiveTileInfo.SpawnPoint.Layer != tile.SpawnPoint.Layer)
                    {
                        Selection.HasDifferentSpawnPointLayers = true;
                    }
                }
            }

            if (ActiveTileInfo.HasZoneTrigger && !Selection.HasDifferentHasZoneTrigger)
            {
                foreach (var tile in Selection.SelectedTiles)
                {
                    if (ActiveTileInfo.Zone.TargetZone != tile.Zone.TargetZone)
                    {
                        Selection.HasDifferentTargetZones = true;
                    }

                    if (ActiveTileInfo.Zone.HasTransition != tile.Zone.HasTransition || (ActiveTileInfo.Zone.HasTransition && Selection.HasEmptySelected))
                    {
                        Selection.HasDifferentHasZoneTransitions = true;
                    }
                }

                if (ActiveTileInfo.Zone.HasTransition && !Selection.HasDifferentHasZoneTransitions)
                {
                    foreach (var tile in Selection.SelectedTiles)
                    {
                        if (ActiveTileInfo.Zone.Transition != tile.Zone.Transition)
                        {
                            Selection.HasDifferentZoneTransitions = true;
                        }

                        if (ActiveTileInfo.Zone.TargetSpawn != tile.Zone.TargetSpawn)
                        {
                            Selection.HasDifferentZoneTargetSpwans = true;
                        }
                    }
                }
            }

            if (ActiveTileInfo.HasEncounter && !Selection.HasDifferentHasEncounter)
            {
                foreach (var tile in Selection.SelectedTiles)
                {
                    if (ActiveTileInfo.Encounter != tile.Encounter)
                    {
                        Selection.HasDifferentEncounters = true;
                    }
                }
            }

            if (ActiveTileInfo.HasInstructions && !Selection.HasDifferentHasInstructions)
            {
                foreach (var tile in Selection.SelectedTiles)
                {
                    if (ActiveTileInfo.Instructions != tile.Instructions)
                    {
                        Selection.HasDifferentInstructions = true;
                    }
                }
            }
        }