InfiniteSigns.Sign.GetSign C# (CSharp) Method

GetSign() public static method

public static GetSign ( int X, int Y ) : System.Point
X int
Y int
return System.Point
        public static Point GetSign(int X, int Y)
        {
            if (Main.tile[X, Y].frameY != 0)
                Y--;
            if (Main.tile[X, Y].frameX % 36 != 0)
                X--;
            return new Point(X, Y);
        }

Usage Example

コード例 #1
0
        void KillSign(int x, int y, int plr)
        {
            TSPlayer player = TShock.Players[plr];

            bool[] attached     = new bool[4];
            bool[] attachedNext = new bool[4];
            var    positions    = new List <Point>();

            if (Main.tile[x, y].IsSign())
            {
                if (TryKillSign(Sign.GetSign(x, y).X, Sign.GetSign(x, y).Y, plr))
                {
                    WorldGen.KillTile(x, y);
                    TSPlayer.All.SendTileSquare(x, y, 3);
                    return;
                }
                else
                {
                    player.SendErrorMessage("This sign is protected.");
                    player.SendTileSquare(x, y, 5);
                    return;
                }
            }
            else
            {
                if (TileValid(x - 1, y) && Main.tile[x - 1, y].IsSign())
                {
                    positions.Add(Sign.GetSign(x - 1, y));
                }
                if (TileValid(x + 1, y) && Main.tile[x + 1, y].IsSign())
                {
                    positions.Add(Sign.GetSign(x + 1, y));
                }
                if (TileValid(x, y - 1) && Main.tile[x, y - 1].IsSign())
                {
                    positions.Add(Sign.GetSign(x, y - 1));
                }
                if (TileValid(x, y + 1) && Main.tile[x, y + 1].IsSign())
                {
                    positions.Add(Sign.GetSign(x, y + 1));
                }
                foreach (Point p in positions)
                {
                    attached[0] = TileValid(p.X, p.Y + 2) && Main.tile[p.X, p.Y + 2].IsSolid() &&
                                  TileValid(p.X + 1, p.Y + 2) && Main.tile[p.X + 1, p.Y + 2].IsSolid();
                    attached[1] = TileValid(p.X, p.Y - 1) && Main.tile[p.X, p.Y - 1].IsSolid() &&
                                  TileValid(p.X + 1, p.Y - 1) && Main.tile[p.X + 1, p.Y - 1].IsSolid();
                    attached[2] = TileValid(p.X - 1, p.Y) && Main.tile[p.X - 1, p.Y].IsSolid() &&
                                  TileValid(p.X - 1, p.Y + 1) && Main.tile[p.X - 1, p.Y + 1].IsSolid();
                    attached[3] = TileValid(p.X + 2, p.Y) && Main.tile[p.X + 2, p.Y].IsSolid() &&
                                  TileValid(p.X + 2, p.Y + 1) && Main.tile[p.X + 2, p.Y + 1].IsSolid();
                    bool prev = Main.tile[x, y].active();
                    Main.tile[x, y].active(false);
                    attachedNext[0] = TileValid(p.X, p.Y + 2) && Main.tile[p.X, p.Y + 2].IsSolid() &&
                                      TileValid(p.X + 1, p.Y + 2) && Main.tile[p.X + 1, p.Y + 2].IsSolid();
                    attachedNext[1] = TileValid(p.X, p.Y - 1) && Main.tile[p.X, p.Y - 1].IsSolid() &&
                                      TileValid(p.X + 1, p.Y - 1) && Main.tile[p.X + 1, p.Y - 1].IsSolid();
                    attachedNext[2] = TileValid(p.X - 1, p.Y) && Main.tile[p.X - 1, p.Y].IsSolid() &&
                                      TileValid(p.X - 1, p.Y + 1) && Main.tile[p.X - 1, p.Y + 1].IsSolid();
                    attachedNext[3] = TileValid(p.X + 2, p.Y) && Main.tile[p.X + 2, p.Y].IsSolid() &&
                                      TileValid(p.X + 2, p.Y + 1) && Main.tile[p.X + 2, p.Y + 1].IsSolid();
                    Main.tile[x, y].active(prev);
                    if (attached.Count(b => b) > 1 || attached.Count(b => b) == attachedNext.Count(b => b))
                    {
                        continue;
                    }
                    if (TryKillSign(p.X, p.Y, plr))
                    {
                        WorldGen.KillTile(p.X, p.Y);
                        TSPlayer.All.SendTileSquare(p.X, p.Y, 3);
                    }
                    else
                    {
                        player.SendErrorMessage("This sign is protected.");
                        player.SendTileSquare(x, y, 5);
                    }
                }
            }
        }
All Usage Examples Of InfiniteSigns.Sign::GetSign