Inheritance: MonoBehaviour
コード例 #1
0
ファイル: DoorTrigger.cs プロジェクト: Hammer94/AdventureFVTC
 void Start()
 {
     DoorOpener[] doors = GameObject.FindObjectsOfType<DoorOpener>();
     for (int i = 0; i < doors.Length; i++)
     {
         if (doors[i].Channel == Channel)
         {
             door = doors[i];
             break;
         }
     }
 }
コード例 #2
0
        public static bool OpenDoor(int x, int y, int direction, bool state = false, DoorOpener opener = DoorOpener.SERVER, ISender sender = null)
        {
            if (sender == null)
            {
                sender = new ConsoleSender();
            }

            if (Program.properties.NPCDoorOpenCancel && opener == DoorOpener.NPC)
                return false;

            DoorStateChangeEvent doorEvent = new DoorStateChangeEvent();
            doorEvent.Sender = sender;
            doorEvent.X = x;
            doorEvent.Y = y;
            doorEvent.Direction = direction;
            doorEvent.Opener = opener;
            doorEvent.isOpened = state;
            Program.server.PluginManager.processHook(Hooks.DOOR_STATECHANGE, doorEvent);
            if (doorEvent.Cancelled)
            {
                NetMessage.SendData(19, -1, -1, "", 1, (float)x, (float)y, 0); //Inform the client of the update
                return false;
            }

            int num = 0;
            if (Main.tile.At(x, y - 1).FrameY == 0 && Main.tile.At(x, y - 1).Type == Main.tile.At(x, y).Type)
            {
                num = y - 1;
            }
            else if (Main.tile.At(x, y - 2).FrameY == 0 && Main.tile.At(x, y - 2).Type == Main.tile.At(x, y).Type)
            {
                num = y - 2;
            }
            else if (Main.tile.At(x, y + 1).FrameY == 0 && Main.tile.At(x, y + 1).Type == Main.tile.At(x, y).Type)
            {
                num = y + 1;
            }
            else
            {
                num = y;
            }
            int num2 = x;
            short num3 = 0;
            int num4;
            if (direction == -1)
            {
                num2 = x - 1;
                num3 = 36;
                num4 = x - 1;
            }
            else
            {
                num2 = x;
                num4 = x + 1;
            }
            bool flag = true;
            for (int k = num; k < num + 3; k++)
            {
                if (Main.tile.At(num4, k).Active)
                {
                    if (Main.tile.At(num4, k).Type != 3 && Main.tile.At(num4, k).Type != 24 && Main.tile.At(num4, k).Type != 52 && Main.tile.At(num4, k).Type != 61 && Main.tile.At(num4, k).Type != 62 && Main.tile.At(num4, k).Type != 69 && Main.tile.At(num4, k).Type != 71 && Main.tile.At(num4, k).Type != 73 && Main.tile.At(num4, k).Type != 74)
                    {
                        flag = false;
                        break;
                    }
                    WorldModify.KillTile(num4, k, false, false, false);
                }
            }
            if (flag)
            {
                Main.tile.At(num2, num).SetActive (true);
                Main.tile.At(num2, num).SetType (11);
                Main.tile.At(num2, num).SetFrameY (0);
                Main.tile.At(num2, num).SetFrameX (num3);
                Main.tile.At(num2 + 1, num).SetActive (true);
                Main.tile.At(num2 + 1, num).SetType (11);
                Main.tile.At(num2 + 1, num).SetFrameY (0);
                Main.tile.At(num2 + 1, num).SetFrameX ((short)(num3 + 18));
                Main.tile.At(num2, num + 1).SetActive (true);
                Main.tile.At(num2, num + 1).SetType (11);
                Main.tile.At(num2, num + 1).SetFrameY (18);
                Main.tile.At(num2, num + 1).SetFrameX (num3);
                Main.tile.At(num2 + 1, num + 1).SetActive (true);
                Main.tile.At(num2 + 1, num + 1).SetType (11);
                Main.tile.At(num2 + 1, num + 1).SetFrameY (18);
                Main.tile.At(num2 + 1, num + 1).SetFrameX ((short)(num3 + 18));
                Main.tile.At(num2, num + 2).SetActive (true);
                Main.tile.At(num2, num + 2).SetType (11);
                Main.tile.At(num2, num + 2).SetFrameY (36);
                Main.tile.At(num2, num + 2).SetFrameX (num3);
                Main.tile.At(num2 + 1, num + 2).SetActive (true);
                Main.tile.At(num2 + 1, num + 2).SetType (11);
                Main.tile.At(num2 + 1, num + 2).SetFrameY (36);
                Main.tile.At(num2 + 1, num + 2).SetFrameX ((short)(num3 + 18));
                for (int l = num2 - 1; l <= num2 + 2; l++)
                {
                    for (int m = num - 1; m <= num + 2; m++)
                    {
                        WorldModify.TileFrame(l, m, false, false);
                    }
                }
            }
            return flag;
        }
コード例 #3
0
        public static bool CloseDoor(int x, int y, bool forced = false, DoorOpener opener = DoorOpener.SERVER, ISender sender = null)
        {
            if (sender == null)
            {
                sender = new ConsoleSender ();
            }

            if (Program.properties.NPCDoorOpenCancel && opener == DoorOpener.NPC)
                return false;

            DoorStateChangeEvent doorEvent = new DoorStateChangeEvent();
            doorEvent.Sender = sender;
            doorEvent.X = x;
            doorEvent.Y = y;
            doorEvent.Direction = 1;
            doorEvent.Opener = opener;
            doorEvent.isOpened = forced;
            Program.server.PluginManager.processHook(Hooks.DOOR_STATECHANGE, doorEvent);
            if (doorEvent.Cancelled)
            {
                NetMessage.SendData(19, -1, -1, "", 0, (float)x, (float)y, 0); //Inform the client of the update
                return false;
            }

            int num = 0;
            int num2 = x;
            int num3 = y;

            int frameX = (int)Main.tile.At(x, y).FrameX;
            int frameY = (int)Main.tile.At(x, y).FrameY;
            if (frameX == 0)
            {
                num2 = x;
                num = 1;
            }
            else if (frameX == 18)
            {
                num2 = x - 1;
                num = 1;
            }
            else if (frameX == 36)
            {
                num2 = x + 1;
                num = -1;
            }
            else if (frameX == 54)
            {
                num2 = x;
                num = -1;
            }
            if (frameY == 0)
            {
                num3 = y;
            }
            else if (frameY == 18)
            {
                num3 = y - 1;
            }
            else if (frameY == 36)
            {
                num3 = y - 2;
            }
            int num4 = num2;
            if (num == -1)
            {
                num4 = num2 - 1;
            }
            if (!forced)
            {
                for (int k = num3; k < num3 + 3; k++)
                {
                    if (!Collision.EmptyTile(num2, k, true))
                    {
                        return false;
                    }
                }
            }
            for (int l = num4; l < num4 + 2; l++)
            {
                for (int m = num3; m < num3 + 3; m++)
                {
                    if (l == num2)
                    {
                        Main.tile.At(l, m).SetType (10);
                        Main.tile.At(l, m).SetFrameX ((short)(WorldModify.genRand.Next(3) * 18));
                    }
                    else
                    {
                        Main.tile.At(l, m).SetActive (false);
                    }
                }
            }
            for (int n = num2 - 1; n <= num2 + 1; n++)
            {
                for (int num5 = num3 - 1; num5 <= num3 + 2; num5++)
                {
                    WorldModify.TileFrame(n, num5, false, false);
                }
            }
            return true;
        }
コード例 #4
0
 public void setOpener(DoorOpener Opener)
 {
     opener = Opener;
 }
コード例 #5
0
        public static bool OpenDoor(int x, int y, int direction, bool state = false, DoorOpener opener = DoorOpener.SERVER, ISender sender = null)
        {
            if (sender == null)
            {
                ConsoleSender cSender = new ConsoleSender(Program.server);
                cSender.ConsoleCommand.Sender = new Sender();
                sender = cSender;
            }

            DoorStateChangeEvent doorEvent = new DoorStateChangeEvent();
            doorEvent.Sender = sender;
            doorEvent.X = x;
            doorEvent.Y = y;
            doorEvent.Direction = direction;
            doorEvent.Opener = opener;
            doorEvent.isOpened = state;
            Program.server.PluginManager.processHook(Hooks.DOOR_STATECHANGE, doorEvent);
            if (doorEvent.Cancelled)
            {
                return true;
            }

            int num = 0;
            if (Main.tile.At(x, y - 1).FrameY == 0 && Main.tile.At(x, y - 1).Type == Main.tile.At(x, y).Type)
            {
                num = y - 1;
            }
            else
            {
                if (Main.tile.At(x, y - 2).FrameY == 0 && Main.tile.At(x, y - 2).Type == Main.tile.At(x, y).Type)
                {
                    num = y - 2;
                }
                else
                {
                    if (Main.tile.At(x, y + 1).FrameY == 0 && Main.tile.At(x, y + 1).Type == Main.tile.At(x, y).Type)
                    {
                        num = y + 1;
                    }
                    else
                    {
                        num = y;
                    }
                }
            }
            int num2 = x;
            short num3 = 0;
            int num4;
            if (direction == -1)
            {
                num2 = x - 1;
                num3 = 36;
                num4 = x - 1;
            }
            else
            {
                num2 = x;
                num4 = x + 1;
            }
            bool flag = true;
            for (int k = num; k < num + 3; k++)
            {
                if (Main.tile.At(num4, k).Active)
                {
                    if (Main.tile.At(num4, k).Type != 3 && Main.tile.At(num4, k).Type != 24 && Main.tile.At(num4, k).Type != 52 && Main.tile.At(num4, k).Type != 61 && Main.tile.At(num4, k).Type != 62 && Main.tile.At(num4, k).Type != 69 && Main.tile.At(num4, k).Type != 71 && Main.tile.At(num4, k).Type != 73 && Main.tile.At(num4, k).Type != 74)
                    {
                        flag = false;
                        break;
                    }
                    WorldGen.KillTile(num4, k, false, false, false);
                }
            }
            if (flag)
            {
                Main.tile.At(num2, num).SetActive (true);
                Main.tile.At(num2, num).SetType (11);
                Main.tile.At(num2, num).SetFrameY (0);
                Main.tile.At(num2, num).SetFrameX (num3);
                Main.tile.At(num2 + 1, num).SetActive (true);
                Main.tile.At(num2 + 1, num).SetType (11);
                Main.tile.At(num2 + 1, num).SetFrameY (0);
                Main.tile.At(num2 + 1, num).SetFrameX ((short)(num3 + 18));
                Main.tile.At(num2, num + 1).SetActive (true);
                Main.tile.At(num2, num + 1).SetType (11);
                Main.tile.At(num2, num + 1).SetFrameY (18);
                Main.tile.At(num2, num + 1).SetFrameX (num3);
                Main.tile.At(num2 + 1, num + 1).SetActive (true);
                Main.tile.At(num2 + 1, num + 1).SetType (11);
                Main.tile.At(num2 + 1, num + 1).SetFrameY (18);
                Main.tile.At(num2 + 1, num + 1).SetFrameX ((short)(num3 + 18));
                Main.tile.At(num2, num + 2).SetActive (true);
                Main.tile.At(num2, num + 2).SetType (11);
                Main.tile.At(num2, num + 2).SetFrameY (36);
                Main.tile.At(num2, num + 2).SetFrameX (num3);
                Main.tile.At(num2 + 1, num + 2).SetActive (true);
                Main.tile.At(num2 + 1, num + 2).SetType (11);
                Main.tile.At(num2 + 1, num + 2).SetFrameY (36);
                Main.tile.At(num2 + 1, num + 2).SetFrameX ((short)(num3 + 18));
                for (int l = num2 - 1; l <= num2 + 2; l++)
                {
                    for (int m = num - 1; m <= num + 2; m++)
                    {
                        WorldGen.TileFrame(l, m, false, false);
                    }
                }
            }
            return flag;
        }
コード例 #6
0
        public static bool CloseDoor(int i, int j, bool forced = false, DoorOpener opener = DoorOpener.SERVER, ISender sender = null)
        {
            if (sender == null)
            {
                ConsoleSender cSender = new ConsoleSender(Program.server);
                cSender.ConsoleCommand.Sender = new Sender();
                sender = cSender;
            }

            DoorStateChangeEvent doorEvent = new DoorStateChangeEvent();
            doorEvent.Sender = sender;
            doorEvent.X = i;
            doorEvent.Y = j;
            doorEvent.Direction = 1;
            doorEvent.Opener = opener;
            doorEvent.isOpened = forced;
            Program.server.PluginManager.processHook(Hooks.DOOR_STATECHANGE, doorEvent);
            if (doorEvent.Cancelled)
            {
                return true;
            }

            int num = 0;
            int num2 = i;
            int num3 = j;

            int frameX = (int)Main.tile.At(i, j).FrameX;
            int frameY = (int)Main.tile.At(i, j).FrameY;
            if (frameX == 0)
            {
                num2 = i;
                num = 1;
            }
            else
            {
                if (frameX == 18)
                {
                    num2 = i - 1;
                    num = 1;
                }
                else
                {
                    if (frameX == 36)
                    {
                        num2 = i + 1;
                        num = -1;
                    }
                    else
                    {
                        if (frameX == 54)
                        {
                            num2 = i;
                            num = -1;
                        }
                    }
                }
            }
            if (frameY == 0)
            {
                num3 = j;
            }
            else
            {
                if (frameY == 18)
                {
                    num3 = j - 1;
                }
                else
                {
                    if (frameY == 36)
                    {
                        num3 = j - 2;
                    }
                }
            }
            int num4 = num2;
            if (num == -1)
            {
                num4 = num2 - 1;
            }
            if (!forced)
            {
                for (int k = num3; k < num3 + 3; k++)
                {
                    if (!Collision.EmptyTile(num2, k, true))
                    {
                        return false;
                    }
                }
            }
            for (int l = num4; l < num4 + 2; l++)
            {
                for (int m = num3; m < num3 + 3; m++)
                {
                    if (l == num2)
                    {
                        Main.tile.At(l, m).SetType (10);
                        Main.tile.At(l, m).SetFrameX ((short)(WorldGen.genRand.Next(3) * 18));
                    }
                    else
                    {
                        Main.tile.At(l, m).SetActive (false);
                    }
                }
            }
            for (int n = num2 - 1; n <= num2 + 1; n++)
            {
                for (int num5 = num3 - 1; num5 <= num3 + 2; num5++)
                {
                    WorldGen.TileFrame(n, num5, false, false);
                }
            }
            return true;
        }
コード例 #7
0
        public static bool CloseDoor(int i, int j, bool forced = false, DoorOpener opener = DoorOpener.SERVER, Sender sender = null)
        {
            if (sender == null)
            {
                ConsoleSender cSender = new ConsoleSender(Program.server);
                cSender.ConsoleCommand.Sender = new Sender();
                sender = cSender;
            }

            DoorStateChangeEvent doorEvent = new DoorStateChangeEvent();
            doorEvent.Sender = sender;
            doorEvent.setVector(new Vector2(i, j));
            doorEvent.setDirection(1);
            doorEvent.setOpener(opener);
            doorEvent.setOpened(forced);
            Program.server.getPluginManager().processHook(Hooks.DOOR_STATECHANGE, doorEvent);
            if (doorEvent.Cancelled)
            {
                return true;
            }
            int num = 0;
            int num2 = i;
            int num3 = j;
            if (Main.tile[i, j] == null)
            {
                Main.tile[i, j] = new Tile();
            }
            int frameX = (int)Main.tile[i, j].frameX;
            int frameY = (int)Main.tile[i, j].frameY;
            if (frameX == 0)
            {
                num2 = i;
                num = 1;
            }
            else
            {
                if (frameX == 18)
                {
                    num2 = i - 1;
                    num = 1;
                }
                else
                {
                    if (frameX == 36)
                    {
                        num2 = i + 1;
                        num = -1;
                    }
                    else
                    {
                        if (frameX == 54)
                        {
                            num2 = i;
                            num = -1;
                        }
                    }
                }
            }
            if (frameY == 0)
            {
                num3 = j;
            }
            else
            {
                if (frameY == 18)
                {
                    num3 = j - 1;
                }
                else
                {
                    if (frameY == 36)
                    {
                        num3 = j - 2;
                    }
                }
            }
            int num4 = num2;
            if (num == -1)
            {
                num4 = num2 - 1;
            }
            if (!forced)
            {
                for (int k = num3; k < num3 + 3; k++)
                {
                    if (!Collision.EmptyTile(num2, k, true))
                    {
                        return false;
                    }
                }
            }
            for (int l = num4; l < num4 + 2; l++)
            {
                for (int m = num3; m < num3 + 3; m++)
                {
                    if (l == num2)
                    {
                        if (Main.tile[l, m] == null)
                        {
                            Main.tile[l, m] = new Tile();
                        }
                        Main.tile[l, m].type = 10;
                        Main.tile[l, m].frameX = (short)(WorldGen.genRand.Next(3) * 18);
                    }
                    else
                    {
                        if (Main.tile[l, m] == null)
                        {
                            Main.tile[l, m] = new Tile();
                        }
                        Main.tile[l, m].Active = false;
                    }
                }
            }
            for (int n = num2 - 1; n <= num2 + 1; n++)
            {
                for (int num5 = num3 - 1; num5 <= num3 + 2; num5++)
                {
                    WorldGen.TileFrame(n, num5, false, false);
                }
            }
            return true;
        }
コード例 #8
0
        public static bool OpenDoor(int i, int j, int direction, bool state = false, DoorOpener opender = DoorOpener.SERVER, Sender sender = null)
        {
            if (sender == null)
            {
                ConsoleSender cSender = new ConsoleSender(Program.server);
                cSender.ConsoleCommand.Sender = new Sender();
                sender = cSender;
            }

            DoorStateChangeEvent doorEvent = new DoorStateChangeEvent();
            doorEvent.Sender = sender;
            doorEvent.setVector(new Vector2(i, j));
            doorEvent.setDirection(direction);
            doorEvent.setOpener(opender);
            doorEvent.setOpened(state);
            Program.server.getPluginManager().processHook(Hooks.DOOR_STATECHANGE, doorEvent);
            if (doorEvent.Cancelled)
            {
                return true;
            }

            int num = 0;
            if (Main.tile[i, j - 1] == null)
            {
                Main.tile[i, j - 1] = new Tile();
            }
            if (Main.tile[i, j - 2] == null)
            {
                Main.tile[i, j - 2] = new Tile();
            }
            if (Main.tile[i, j + 1] == null)
            {
                Main.tile[i, j + 1] = new Tile();
            }
            if (Main.tile[i, j] == null)
            {
                Main.tile[i, j] = new Tile();
            }
            if (Main.tile[i, j - 1].frameY == 0 && Main.tile[i, j - 1].type == Main.tile[i, j].type)
            {
                num = j - 1;
            }
            else
            {
                if (Main.tile[i, j - 2].frameY == 0 && Main.tile[i, j - 2].type == Main.tile[i, j].type)
                {
                    num = j - 2;
                }
                else
                {
                    if (Main.tile[i, j + 1].frameY == 0 && Main.tile[i, j + 1].type == Main.tile[i, j].type)
                    {
                        num = j + 1;
                    }
                    else
                    {
                        num = j;
                    }
                }
            }
            int num2 = i;
            short num3 = 0;
            int num4;
            if (direction == -1)
            {
                num2 = i - 1;
                num3 = 36;
                num4 = i - 1;
            }
            else
            {
                num2 = i;
                num4 = i + 1;
            }
            bool flag = true;
            for (int k = num; k < num + 3; k++)
            {
                if (Main.tile[num4, k] == null)
                {
                    Main.tile[num4, k] = new Tile();
                }
                if (Main.tile[num4, k].Active)
                {
                    if (Main.tile[num4, k].type != 3 && Main.tile[num4, k].type != 24 && Main.tile[num4, k].type != 52 && Main.tile[num4, k].type != 61 && Main.tile[num4, k].type != 62 && Main.tile[num4, k].type != 69 && Main.tile[num4, k].type != 71 && Main.tile[num4, k].type != 73 && Main.tile[num4, k].type != 74)
                    {
                        flag = false;
                        break;
                    }
                    WorldGen.KillTile(num4, k, false, false, false);
                }
            }
            if (flag)
            {
                Main.tile[num2, num].Active = true;
                Main.tile[num2, num].type = 11;
                Main.tile[num2, num].frameY = 0;
                Main.tile[num2, num].frameX = num3;
                if (Main.tile[num2 + 1, num] == null)
                {
                    Main.tile[num2 + 1, num] = new Tile();
                }
                Main.tile[num2 + 1, num].Active = true;
                Main.tile[num2 + 1, num].type = 11;
                Main.tile[num2 + 1, num].frameY = 0;
                Main.tile[num2 + 1, num].frameX = (short)(num3 + 18);
                if (Main.tile[num2, num + 1] == null)
                {
                    Main.tile[num2, num + 1] = new Tile();
                }
                Main.tile[num2, num + 1].Active = true;
                Main.tile[num2, num + 1].type = 11;
                Main.tile[num2, num + 1].frameY = 18;
                Main.tile[num2, num + 1].frameX = num3;
                if (Main.tile[num2 + 1, num + 1] == null)
                {
                    Main.tile[num2 + 1, num + 1] = new Tile();
                }
                Main.tile[num2 + 1, num + 1].Active = true;
                Main.tile[num2 + 1, num + 1].type = 11;
                Main.tile[num2 + 1, num + 1].frameY = 18;
                Main.tile[num2 + 1, num + 1].frameX = (short)(num3 + 18);
                if (Main.tile[num2, num + 2] == null)
                {
                    Main.tile[num2, num + 2] = new Tile();
                }
                Main.tile[num2, num + 2].Active = true;
                Main.tile[num2, num + 2].type = 11;
                Main.tile[num2, num + 2].frameY = 36;
                Main.tile[num2, num + 2].frameX = num3;
                if (Main.tile[num2 + 1, num + 2] == null)
                {
                    Main.tile[num2 + 1, num + 2] = new Tile();
                }
                Main.tile[num2 + 1, num + 2].Active = true;
                Main.tile[num2 + 1, num + 2].type = 11;
                Main.tile[num2 + 1, num + 2].frameY = 36;
                Main.tile[num2 + 1, num + 2].frameX = (short)(num3 + 18);
                for (int l = num2 - 1; l <= num2 + 2; l++)
                {
                    for (int m = num - 1; m <= num + 2; m++)
                    {
                        WorldGen.TileFrame(l, m, false, false);
                    }
                }
            }
            return flag;
        }