Exemplo n.º 1
0
        public override Item getOne()
        {
            shopObject shopObject = new shopObject(this.parentSheetIndex, this.tileLocation, this.inventory, this.texturePath);

            /*
             * drawPosition = this.drawPosition;
             * defaultBoundingBox = this.defaultBoundingBox;
             * boundingBox = this.boundingBox;
             * currentRotation = this.currentRotation - 1;
             * rotations = this.rotations;
             * rotate();
             */
            return(shopObject);
        }
Exemplo n.º 2
0
        public override bool placementAction(GameLocation location, int x, int y, StardewValley.Farmer who = null)
        {
            //  Log.AsyncC(x);
            //   Log.AsyncM(y);


            if (location is FarmHouse)
            {
                Point            point = new Point(x / Game1.tileSize, y / Game1.tileSize);
                List <Rectangle> walls = FarmHouse.getWalls((location as FarmHouse).upgradeLevel);
                this.tileLocation = new Vector2((float)point.X, (float)point.Y);
                bool flag = false;
                if (this.Decoration_type == 6 || this.Decoration_type == 13 || this.parentSheetIndex == 1293)
                {
                    int  num   = (this.parentSheetIndex == 1293) ? 3 : 0;
                    bool flag2 = false;
                    foreach (Rectangle current in walls)
                    {
                        if ((this.Decoration_type == 6 || this.Decoration_type == 13 || num != 0) && current.Y + num == point.Y && current.Contains(point.X, point.Y - num))
                        {
                            flag2 = true;
                            break;
                        }
                    }
                    if (!flag2)
                    {
                        Game1.showRedMessage("Must be placed on wall");
                        return(false);
                    }
                    flag = true;
                }
                for (int i = point.X; i < point.X + this.getTilesWide(); i++)
                {
                    for (int j = point.Y; j < point.Y + this.getTilesHigh(); j++)
                    {
                        if (location.doesTileHaveProperty(i, j, "NoFurniture", "Back") != null)
                        {
                            Game1.showRedMessage("Furniture can't be placed here");
                            return(false);
                        }
                        if (!flag && Utility.pointInRectangles(walls, i, j))
                        {
                            Game1.showRedMessage("Can't place on wall");
                            return(false);
                        }
                        if (location.getTileIndexAt(i, j, "Buildings") != -1)
                        {
                            return(false);
                        }
                    }
                }
                this.boundingBox = new Rectangle(x / Game1.tileSize, y / Game1.tileSize, this.boundingBox.Width, this.boundingBox.Height);
                foreach (KeyValuePair <Vector2, StardewValley.Object> c in location.objects)
                {
                    StardewValley.Object ehh = c.Value;
                    if (((ehh.GetType()).ToString()).Contains("shopObject"))
                    {
                        shopObject current2 = (shopObject)ehh;
                        if (current2.Decoration_type == 11 && current2.heldObject == null && current2.getBoundingBox(current2.tileLocation).Intersects(this.boundingBox))
                        {
                            current2.performObjectDropInAction(this, false, (who == null) ? Game1.player : who);
                            bool result = true;
                            return(result);
                        }
                    }
                }
                foreach (StardewValley.Farmer current3 in location.getFarmers())
                {
                    if (current3.GetBoundingBox().Intersects(this.boundingBox))
                    {
                        Game1.showRedMessage("Can't place on top of a person.");
                        bool result = false;
                        return(result);
                    }
                }
                this.updateDrawPosition();

                for (int i = 0; i <= this.boundingBox.X / Game1.tileSize; i++)
                {
                    base.placementAction(location, x + 1, y, who);
                }
                for (int i = 0; i <= this.boundingBox.Y / Game1.tileSize; i++)
                {
                    base.placementAction(location, x, y + 1, who);
                }
                return(true);
            }
            else
            {
                Point point = new Point(x / Game1.tileSize, y / Game1.tileSize);
                //  List<Rectangle> walls = FarmHouse.getWalls((location as FarmHouse).upgradeLevel);
                this.tileLocation = new Vector2((float)point.X, (float)point.Y);
                bool flag = false;
                if (this.Decoration_type == 6 || this.Decoration_type == 13 || this.parentSheetIndex == 1293)
                {
                    int  num   = (this.parentSheetIndex == 1293) ? 3 : 0;
                    bool flag2 = false;

                    /*
                     * foreach (Rectangle current in walls)
                     * {
                     *  if ((this.Decoration_type == 6 || this.Decoration_type == 13 || num != 0) && current.Y + num == point.Y && current.Contains(point.X, point.Y - num))
                     *  {
                     *      flag2 = true;
                     *      break;
                     *  }
                     * }
                     */
                    if (!flag2)
                    {
                        Game1.showRedMessage("Must be placed on wall");
                        return(false);
                    }
                    flag = true;
                }
                for (int i = point.X; i < point.X + this.getTilesWide(); i++)
                {
                    for (int j = point.Y; j < point.Y + this.getTilesHigh(); j++)
                    {
                        if (location.doesTileHaveProperty(i, j, "NoFurniture", "Back") != null)
                        {
                            Game1.showRedMessage("Furniture can't be placed here");
                            return(false);
                        }

                        /*
                         * if (!flag && Utility.pointInRectangles(walls, i, j))
                         * {
                         *  Game1.showRedMessage("Can't place on wall");
                         *  return false;
                         * }
                         */
                        if (location.getTileIndexAt(i, j, "Buildings") != -1)
                        {
                            return(false);
                        }
                    }
                }
                this.boundingBox = new Rectangle(x / Game1.tileSize, y / Game1.tileSize, this.boundingBox.Width, this.boundingBox.Height);

                /*
                 * foreach (Furniture current2 in (location as FarmHouse).furniture)
                 * {
                 *  if (current2.furniture_type == 11 && current2.heldObject == null && current2.getBoundingBox(current2.tileLocation).Intersects(this.boundingBox))
                 *  {
                 *      current2.performObjectDropInAction(this, false, (who == null) ? Game1.player : who);
                 *      bool result = true;
                 *      return result;
                 *  }
                 * }
                 */
                foreach (StardewValley.Farmer current3 in location.getFarmers())
                {
                    if (current3.GetBoundingBox().Intersects(this.boundingBox))
                    {
                        Game1.showRedMessage("Can't place on top of a person.");
                        bool result = false;
                        return(result);
                    }
                }
                this.updateDrawPosition();
                this.thisLocation = Game1.player.currentLocation;
                return(Util.placementAction(this, location, x, y, who));
            }
        }
Exemplo n.º 3
0
        public override bool canBePlacedHere(GameLocation l, Vector2 tile)
        {
            if ((l is FarmHouse))
            {
                for (int i = 0; i < this.boundingBox.Width / Game1.tileSize; i++)
                {
                    for (int j = 0; j < this.boundingBox.Height / Game1.tileSize; j++)
                    {
                        Vector2 vector = tile * (float)Game1.tileSize + new Vector2((float)i, (float)j) * (float)Game1.tileSize;
                        vector.X += (float)(Game1.tileSize / 2);
                        vector.Y += (float)(Game1.tileSize / 2);
                        foreach (KeyValuePair <Vector2, StardewValley.Object> something in l.objects)
                        {
                            StardewValley.Object obj = something.Value;
                            if ((obj.GetType()).ToString().Contains("shopObject"))
                            {
                                shopObject current = (shopObject)obj;
                                if (current.Decoration_type == 11 && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y) && current.heldObject == null && this.getTilesWide() == 1)
                                {
                                    bool result = true;
                                    return(result);
                                }
                                if ((current.Decoration_type != 12 || this.Decoration_type == 12) && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y))
                                {
                                    bool result = false;
                                    return(result);
                                }
                            }
                        }
                    }
                }
                return(base.canBePlacedHere(l, tile));
            }
            else
            {
                // Game1.showRedMessage("NOT FARMHOUSE");
                for (int i = 0; i < this.boundingBox.Width / Game1.tileSize; i++)
                {
                    for (int j = 0; j < this.boundingBox.Height / Game1.tileSize; j++)
                    {
                        Vector2 vector = tile * (float)Game1.tileSize + new Vector2((float)i, (float)j) * (float)Game1.tileSize;
                        vector.X += (float)(Game1.tileSize / 2);
                        vector.Y += (float)(Game1.tileSize / 2);

                        /*
                         * foreach (shopObject current in (l as FarmHouse).shopObject)
                         * {
                         *  if (current.Decoration_type == 11 && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y) && current.heldObject == null && this.getTilesWide() == 1)
                         *  {
                         *      bool result = true;
                         *      return result;
                         *  }
                         *  if ((current.Decoration_type != 12 || this.Decoration_type == 12) && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y))
                         *  {
                         *      bool result = false;
                         *      return result;
                         *  }
                         * }
                         */
                    }
                }
                return(base.canBePlacedHere(l, tile));
            }
        }