private TilePlacement(TilePlacement copy)
 {
     this.Name      = copy.Name;
     this.Inversion = copy.Inversion;
     this.Rotation  = copy.Rotation;
     this.Height    = copy.Height;
 }
        public void Given_ARightRotatedTile_When_GettingRightEdge_Then_ReturnsBottomEdge()
        {
            // Arrange
            var field = new Field(ImmutableHashSet.Create(
                                      Segment.RightTop,
                                      Segment.Right,
                                      Segment.RightBottom
                                      ));

            var tile = new TileBuilder()
                       .CreateTile(new IFeature[]
            {
                field,
            })
                       .ValueOrFailure();

            var placement = new TilePlacement(tile, Rotation.Quarter);

            // Act
            var actualEdge = placement.GetFeaturesAt(Edge.Bottom);

            // Assert
            IFeature[] expectedEdge =
            {
                field, field, field
            };

            Assert.Equal(expectedEdge, actualEdge);
        }
Beispiel #3
0
        public void Click()
        {
            TilePlacement placement = new TilePlacement();

            placement.SetType(new TileType(_type), Behaviour);
            PlacementController.Instance.TakePlacement(placement);
        }
        public void Given_AnUnrotatedTile_When_GettingTopEdge_Then_ReturnsTopEdge()
        {
            // Arrange
            var field = new Field(ImmutableHashSet.Create(
                                      Segment.TopLeft,
                                      Segment.Top,
                                      Segment.TopRight
                                      ));

            var tile = new TileBuilder()
                       .CreateTile(new IFeature[]
            {
                field,
            })
                       .ValueOrFailure();

            var placement = new TilePlacement(tile, Rotation.None);

            // Act
            var actualEdge = placement.GetFeaturesAt(Edge.Top);

            // Assert
            IFeature[] expectedEdge =
            {
                field, field, field
            };

            Assert.Equal(expectedEdge, actualEdge);
        }
    public static void SaveTileProperties(Vector3Int pos, TilePlacement info)
    {
        GameObject rmc       = TileObjectsArray[pos.z, pos.x];
        string     name      = info.Name;
        int        rotation  = info.Rotation;
        bool       inversion = info.Inversion;
        byte       height    = info.Height;

        SaveTileProperties(rmc, name, inversion, rotation, pos, height);
    }
        /// <summary>
        /// Creates copy of the tile placement.
        /// </summary>
        /// <returns>Copy of the tile placement.</returns>
        public TilePlacement Copy()
        {
            var copy = new TilePlacement();

            copy.Scheme         = Scheme.Copy();
            copy.Orientation    = Orientation;
            copy.PlacedFollower = (PlacedFollower == null ? null : PlacedFollower.Copy());

            return(copy);
        }
        private static void Postfix(TilePlacement __instance, Character source)
        {
            try
            {
                if (!Recording)
                {
                    return;
                }

                var drop = from obj in DropItemsPatch.CapturedDrops
                           let dropITem = obj.GetComponent <DropItem>()
                                          where SeedID.Contains(dropITem.itemInfo.id)
                                          select dropITem;
                if (drop.Count() > 0)
                {
                    var seed = drop.Single();

                    var seedData = ConfigItem.Table[seed.itemInfo.id];
                    PlacementSetup.SetThing(__instance.TiledObject.X, __instance.TiledObject.Y, seedData.PlacenmentId);

                    if (DropItemsPatch.CapturedDrops.Count == 1 && seed.itemInfo.count == 1)
                    {
                        (source.Weapon.Proto as ItemWeaponProto).item.curDurability++;
                    }
                    else
                    {
                        Recording = false;
                        SoundsPublicPatch.CapturedData.Do(x => SoundsPublic.PlaySound(x.Item1, x.Item2, x.Item3, x.Item4, x.Item5, x.Item6));
                    }

                    var scytheIndex = ConfigPatch.ScytheID.ToList().IndexOf(source.Weapon.WeaponId);
                    if (DropItemsPatch.CapturedDrops.Count == 1 || UnityEngine.Random.value > ConfigPatch.ExtraYieldChances[scytheIndex])
                    {
                        seed.itemInfo.count--;
                        UpdateDropItemText(seed);
                        if (seed.itemInfo.count == 0)
                        {
                            DropItemDelete.Invoke(seed, null);
                        }
                    }
                }
            }
            catch (Exception e) { Log.ExceptionOnce(e); }

            Recording = false;
            DropItemsPatch.CapturedDrops.Clear();
            SoundsPublicPatch.CapturedData.Clear();
        }
 void XTileSelection()
 {
     Outline_underlying();
     if (Input.GetKeyDown(KeyCode.X))
     {
         DelLastPrefab();
     }
     if (Input.GetMouseButtonDown(0) && outlined_element)
     {
         Vector3Int    pos  = Vpos2tpos(outlined_element);
         TilePlacement info = Consts.TilePlacementArray[pos.z, pos.x].Copy();
         DeleteTile(pos);
         LMBclicked = false;
         UndoBuffer.ApplyTileOperation(pos, info, BufferOperationType.REMOVE);
     }
 }
Beispiel #9
0
    }                                                          // singleton instance
    private void Awake()
    {
        if (null == Instance)
        {
            Instance = this;
        }
        else if (this != Instance)
        {
            Destroy(this);
        }

        GameStateManager.Instance.cleanupGameplay += (() =>
        {
            DisplayTile.SelectedTile?.DeselectTile();
            display?.DeselectTile();
            UpdateDisplay();
        });
    }
Beispiel #10
0
 public TilePlacement(TilePlacement tilePlacement)
 {
     Tile   = tilePlacement.Tile;
     XCoord = tilePlacement.XCoord;
     YCoord = tilePlacement.YCoord;
 }
Beispiel #11
0
 public PlaceTileGameAction(Point point, TilePlacement placement)
 {
     this.Point     = point;
     this.Placement = placement;
 }
 public static void PlaceTile(Vector3Int pos, TilePlacement info, bool mixing)
 {
     PlaceTile(pos, info.Name, info.Rotation, info.Inversion, info.Height, mixing);
 }
        private void DrawBaseLayer(Matrix matrix, Graphics g)
        {
            TilePlacementCache _tilePlacement = new TilePlacementCache();
            //foreach (Image img in GetImageTiles(this.ViewBounds, map.ActualWidth, map.ActualHeight))
            int numTilesTotal             = 0;
            int numTilesDisc              = 0;
            int numTilesInternet          = 0;
            int numTilesNull              = 0;
            int numTilesMemory            = 0;
            List <GeoBitmap> v_listImages = GetImageTiles(matrix);

            foreach (GeoBitmap img in v_listImages)
            {
                try
                {
                    if (img == null || img.Bitmap == null)
                    {
                        numTilesNull++;
                    }
                    else
                    {
                        switch (img.Origin)
                        {
                        case TileOrigin.Disk: numTilesDisc++; break;

                        case TileOrigin.Download: numTilesInternet++; break;

                        case TileOrigin.Memory: numTilesMemory++; break;
                        }

                        PointF hg        = new PointF((float)img.BBox.XMin, (float)img.BBox.YMax);
                        PointF hgLogical = GeoToLogical(matrix, hg);
                        PointF bd        = new PointF((float)img.BBox.XMax, (float)img.BBox.YMin);
                        PointF bdLogical = GeoToLogical(matrix, bd);
                        float  width     = bdLogical.X - hgLogical.X;
                        float  height    = bdLogical.Y - hgLogical.Y;

                        if (width > 0 && height > 0)
                        {
                            TilePlacement placement = _tilePlacement.Suggest(img.Index.X, img.Index.Y, (int)Math.Round(hgLogical.X, 0), (int)Math.Round(hgLogical.Y, 0), (int)Math.Ceiling(width), (int)Math.Ceiling(height));

                            if (_opacity < 1f)
                            {
                                using (Image image = img.Bitmap.SetImageOpacity(_opacity))
                                {
                                    g.DrawImage(image, placement.PosX, placement.PosY, placement.Width, placement.Height);
                                }
                            }
                            else
                            {
                                //Trace.TraceInformation("Image {0} at X: {1}, Y: {2} ({3} x {4})", img.TileInfo, hgLogical.X, bdLogical.Y, width, height);
                                g.DrawImage(img.Bitmap, placement.PosX, placement.PosY, placement.Width, placement.Height);
                            }
                        }
                        // No dispose here, as the memory cache handles image disposing
                        //img.Dispose();
                    }
                }
                catch (Exception ex)
                {
                    Trace.TraceError("DrawBaseLayer: " + ex.Message);
                    numTilesNull++;
                    break;
                }
                numTilesTotal++;
            }
            Trace.TraceInformation("{0} tiles processed. Null: {1}, Disk: {2}, Downloaded: {3}, Memory: {4}", numTilesTotal, numTilesNull, numTilesDisc, numTilesInternet, numTilesMemory);
        }
Beispiel #14
0
        //Dropping letter on board
        private void Button_DragDrop(object sender, DragEventArgs e)
        {
            bool   blankTile = false;
            Button btn       = (Button)sender;//The tile the letter is being placed on

            int[] index = BoardHandler.getRowCol(int.Parse(btn.Tag.ToString()));

            //Make sure an adjacent tile contains a letter or is the center piece
            if (!TilePlacement.CheckAdjacent(index[0], index[1], gameBoard))
            {
                e.Effect = DragDropEffects.None;
                return;
            }
            //Save premodified values
            boardAtTurnStart.Add(btn, btn.Text);
            handAtTurnStart.Add(currentTile, currentTile.Text);

            if (currentTile.Text == " ")
            {
                InputBox.SetLanguage(InputBox.Language.English);
                DialogResult res = InputBox.ShowDialog("Select a letter for your tile:",
                                                       "Select a letter",                                                                //Text message (mandatory), Title (optional)
                                                       InputBox.Icon.Information,                                                        //Set icon type (default info)
                                                       InputBox.Buttons.Ok,                                                              //Set buttons (default ok)
                                                       InputBox.Type.ComboBox,                                                           //Set type (default nothing)
                                                       new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
                                                                      "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" }, //String field as ComboBox items (default null)
                                                       false,                                                                            //Set visible in taskbar (default false)
                                                       new System.Drawing.Font("Calibri", 10F, System.Drawing.FontStyle.Bold));          //Set font (default by system)
                currentTile.SetTileLetter(InputBox.ResultValue);
                blankTile = true;
            }

            //If it's a preimum board tile, record the multiplier
            if (btn.Text.Equals("Double Word Score") || btn.Text.Equals("*"))
            {
                scoreMultiplier *= 2;
            }
            else if (btn.Text.Equals("Triple Word Score"))
            {
                scoreMultiplier *= 3;
            }
            //Calculate value for premium tiles
            score += CalculateScore.CaluclatePlacedTileScore(btn, currentTile);
            tilesThisTurn.Add(currentTile.Text);

            //Potentially useless
            currentTile.SetBoardPosition(int.Parse(btn.Tag.ToString()));
            //Update board tile
            ib.addTile(new LetterTile(currentTile.Text, currentTile.GetBoardPosition()));

            if (blankTile)
            {
                btn.Text = currentTile.Text;
            }
            else
            {
                btn.Text = e.Data.GetData(DataFormats.StringFormat).ToString();
            }

            btn.AllowDrop = false;
            placements.Add(int.Parse(btn.Tag.ToString()));
            currentTile.Text = "";
        }