示例#1
0
        private void OnRadioButtonClicked(object sender, RoutedEventArgs e) {
            RadioButton radioButton = sender as RadioButton;

            Tile.Types type;
            Enum.TryParse(radioButton?.Tag.ToString(), out type);
            TileType = type;
        }
示例#2
0
文件: Import.cs 项目: Bargsteen/p2
        internal static void EffectuateFloorPlanSettings(BuildingInformationCollection buildingInformation, ref IFloorPlan floorPlan, ref Dictionary <int, Person> allPeople)
        {
            const int freeTypeIntRepresentation = (int)Tile.Types.Free;

            /* Step 1: Subject the types of each tile to the type of the tile in the BuildingInformationCollection */
            for (int z = 0; z < buildingInformation.Floors; z++)
            {
                for (int y = 0; y < buildingInformation.Height; y++)
                {
                    for (int x = 0; x < buildingInformation.Width; x++)
                    {
                        int type = int.Parse(buildingInformation.FloorCollection[z].Rows[y][x].ToString());
                        /* If the point is already marked as free, continue - no need to force-convert it to free */
                        if (type == freeTypeIntRepresentation)
                        {
                            continue;
                        }

                        Tile.Types newType = (Tile.Types)type;

                        if (newType == Tile.Types.Person)
                        {
                            PersonInformation personInfo = buildingInformation.PeopleCollection.FirstOrDefault(p => p.Position == Coordinate(x, y, z));
                            allPeople.Add(personInfo.ID, new Person(personInfo.ID, personInfo.MovementSpeed, floorPlan.Tiles[personInfo.Position] as BuildingBlock));
                        }

                        floorPlan.Tiles[Coordinate(x, y, z)].Type = newType;
                    }
                }
            }
        }
示例#3
0
 public static void SetSection(Tile[,] partition, Tile.Types type)
 {
     foreach (var item in partition)
     {
         item.Type = type;
     }
 }
示例#4
0
        private void DrawLine(BuildingBlock block, Tile.Types targetType)
        {
            if (block.X == previousBlock.X && block.Y == previousBlock.Y)
            {
                // The same block has been pressed twice.
                return;
            }
            int deltaX = block.X - previousBlock.X;
            int deltaY = block.Y - previousBlock.Y;

            // deltaTilt is the tilt of the line per pixel
            double deltaTilt = Math.Min(Math.Abs((double)deltaY / (double)deltaX), Math.Abs((double)deltaY)) * Math.Sign((double)deltaY / (double)deltaX);
            double tilt      = 0;

            int i = 0;

            // Iterates through each line in X
            do
            {
                int j = 0;
                // Iterates though each pixel in the current X line, until j is bigger or equal to deltaTilt
                do
                {
                    int x = i + previousBlock.X;
                    int y = (int)(tilt) + previousBlock.Y + j;

                    SetBlockType((BuildingBlock)LocalFloorPlan.Tiles[Coordinate(x, y, block.Z)], targetType);

                    j += Math.Sign(deltaY);
                } while (Math.Abs(j) < Math.Abs(deltaTilt));

                tilt += deltaTilt * Math.Sign(deltaX);
                i    += Math.Sign(deltaX);
            } while (Math.Abs(i) < Math.Abs(deltaX));
        }
示例#5
0
        private void OnRadioButtonClicked(object sender, RoutedEventArgs e)
        {
            RadioButton radioButton = sender as RadioButton;

            Tile.Types type;
            Enum.TryParse(radioButton?.Tag.ToString(), out type);
            TileType = type;
        }
示例#6
0
 private void SetBlockType(BuildingBlock block, Tile.Types targetType)
 {
     if (targetType != Tile.Types.Person)
     {
         UserInterface.BuildingHasBeenChanged = true;
     }
     block.Type         = targetType;
     block.OriginalType = targetType;
     ColorizeBuildingBlock(block.Figure, targetType);
 }
        public bool SetTile(int tileX, int tileY, Tile.Types type)
        {
            if (!InTileBounds(tileX, tileY))
            {
                return(false);
            }
            int chunkX     = (tileX >> Chunk.Bits);
            int chunkY     = (tileY >> Chunk.Bits);
            int chunkTileX = (tileX & Chunk.Modulo);
            int chunkTileY = (tileY & Chunk.Modulo);

            return(SetTile(chunkX, chunkY, chunkTileX, chunkTileY, type));
        }
示例#8
0
        public Tile CreateTile(Tile.Types type, Vector2Int coords)
        {
            var tile = Tile.CreateTile(this, type, coords);

            if (!this.Board.PlaceTile(tile, coords))
            {
                Destroy(tile.gameObject);

                return(null);
            }

            this.Tiles.Add(tile);

            return(tile);
        }
示例#9
0
        private void ColorizeBuildingBlock(Rectangle buildingBlockRepresentation, Tile.Types type)
        {
            Color newColor;

            switch (type)
            {
            case Tile.Types.Free:
                newColor = Colors.White;
                break;

            case Tile.Types.Occupied:
                newColor = Colors.Green;
                break;

            case Tile.Types.Furniture:
                newColor = Colors.Gray;
                break;

            case Tile.Types.Wall:
                newColor = Colors.Black;
                break;

            case Tile.Types.Door:
                newColor = Colors.Pink;
                break;

            case Tile.Types.Exit:
                newColor = Colors.Blue;
                break;

            case Tile.Types.Person:
                newColor = Colors.BlueViolet;
                break;

            case Tile.Types.Stair:
                newColor = Colors.Thistle;
                break;

            default:
                newColor = Colors.BlanchedAlmond;
                break;
            }

            ColorRectangle(buildingBlockRepresentation, newColor);
        }
示例#10
0
        private void OnBuildingBlockClick(object sender, MouseButtonEventArgs e)
        {
            Tile.Types type            = (Tile.Types)OnBuildingBlockTypeFetch?.Invoke(); //Get the type of the currently radio'ed FloorPlanControl-type
            Rectangle  senderRectangle = sender as Rectangle;                            //Get a reference to the sender rectangle

            if (senderRectangle == null)
            {
                throw new GeneralInternalException();
            }
            BuildingBlock senderBlock = (BuildingBlock)LocalFloorPlan.Tiles[senderRectangle.Tag.ToString()];

            SetBlockType(senderBlock, type);
            if (Keyboard.IsKeyDown(Settings.LineToolKey))
            {
                if (previousBlock != null)
                {
                    DrawLine(senderBlock, type);
                }
                previousBlock = senderBlock;
            }
        }
示例#11
0
 virtual public Tile CreateTile(Tile.Types type, Vector2Int coords)
 {
     return(this.Puzzle.CreateTile(type, coords));
 }
示例#12
0
 internal virtual bool SetTile(int chunkX, int chunkY, int chunkTileX, int chunkTileY, Tile.Types type)
 {
     if (Chunks[chunkX, chunkY].Tiles[chunkTileX, chunkTileY].Type != type)
     {
         Chunks[chunkX, chunkY].Tiles[chunkTileX, chunkTileY].Type = type;
         if (Chunks[chunkX, chunkY].Texture != null)
         {
             Chunks[chunkX, chunkY].Bake();
             Bake();
         }
         return(true);
     }
     return(false);
 }
示例#13
0
 public void SetTile(char ch, int[] pos, Color4 color, Tile.Types type)
 => tiles[pos[0], pos[1]] = new Tile(ch, color, type);
示例#14
0
 public void SetTile(char ch, Vector2 pos, Tile.Types type)
 => tiles[pos.X, pos.Y] = new Tile(ch, Color4.White, type);