Exemple #1
0
        public override bool NewRightClick(int i, int j)
        {
            Tile tile = Main.tile[i, j];
            int  left = i - tile.frameX % 36 / 18;
            int  top  = j - tile.frameY / 18;

            int index = GetInstance <TESpeaker>().Find(left, top);

            if (index != -1)
            {
                TESpeaker speakerEnt = (TESpeaker)TileEntity.ByID[index];
                //Main.NewText(speakerEnt.soundId + " " + speakerEnt.global + " " + speakerEnt.volume + " " + speakerEnt.pitch);

                //Main.NewText("Scores:");

                //Random rnd = new Random();
                //int snd = rnd.Next(0, 41);
                //speakerEnt.soundId = snd;
                //speakerEnt.changed = true;
                //Main.PlaySound(speakerEnt.soundId, i * 16, j * 16);

                MoreMechanisms.instance.speakerUIState.i = i * 16;
                MoreMechanisms.instance.speakerUIState.j = j * 16;
                if (!MoreMechanisms.instance.SpeakerUIVisible())
                {
                    MoreMechanisms.instance.ShowSpeakerUI();
                }
            }

            //Activate(i, j);

            //Tile tile = Main.tile[i, j];
            //int left = i - tile.frameX % 36 / 18;
            //int top = j - tile.frameY / 18;

            //int index = GetInstance<TESpeaker>().Find(left, top);
            //if (index == -1) {
            //    return false;
            //}
            //Main.NewText("Scores:");
            //TEScoreBoard tEScoreBoard = (TEScoreBoard)TileEntity.ByID[index];
            //foreach (var item in tEScoreBoard.scores) {
            //    Main.NewText(item.Key + ": " + item.Value);
            //}

            return(true);
        }
Exemple #2
0
        public override void HitWire(int i, int j)
        {
            Tile tile = Main.tile[i, j];
            int  left = i - tile.frameX % 36 / 18;
            int  top  = j - tile.frameY / 18;

            int index = GetInstance <TESpeaker>().Find(left, top);

            if (index != -1)
            {
                TESpeaker speakerEnt = (TESpeaker)TileEntity.ByID[index];

                if (Main.netMode == NetmodeID.Server)
                {
                    ModPacket myPacket = MoreMechanisms.instance.GetPacket();
                    myPacket.Write((byte)2); // id
                    myPacket.Write((short)speakerEnt.Position.X);
                    myPacket.Write((short)speakerEnt.Position.Y);
                    myPacket.Send();
                }

                speakerEnt.PlaySound();
            }
        }