コード例 #1
0
ファイル: ActionWindow.cs プロジェクト: zixela/l2net
        private void button_attack_Click(object sender, EventArgs e)
        {
            switch (Globals.gamedata.my_char.CurrentTargetType)
            {
                case TargetType.ERROR:
                case TargetType.NONE:
                    break;
                case TargetType.SELF:
                    break;
                case TargetType.MYPET:
                    ServerPackets.Force_Attack(Globals.gamedata.my_char.TargetID, Util.Float_Int32(Globals.gamedata.my_pet.X), Util.Float_Int32(Globals.gamedata.my_pet.Y), Util.Float_Int32(Globals.gamedata.my_pet.Z), false);
                    break;
                case TargetType.MYPET1:
                    ServerPackets.Force_Attack(Globals.gamedata.my_char.TargetID, Util.Float_Int32(Globals.gamedata.my_pet1.X), Util.Float_Int32(Globals.gamedata.my_pet1.Y), Util.Float_Int32(Globals.gamedata.my_pet1.Z), false);
                    break;
                case TargetType.MYPET2:
                    ServerPackets.Force_Attack(Globals.gamedata.my_char.TargetID, Util.Float_Int32(Globals.gamedata.my_pet2.X), Util.Float_Int32(Globals.gamedata.my_pet2.Y), Util.Float_Int32(Globals.gamedata.my_pet2.Z), false);
                    break;
                case TargetType.MYPET3:
                    ServerPackets.Force_Attack(Globals.gamedata.my_char.TargetID, Util.Float_Int32(Globals.gamedata.my_pet3.X), Util.Float_Int32(Globals.gamedata.my_pet3.Y), Util.Float_Int32(Globals.gamedata.my_pet3.Z), false);
                    break;
                case TargetType.PLAYER:
                    Globals.PlayerLock.EnterReadLock();
                    try
                    {
                        CharInfo player = Util.GetChar(Globals.gamedata.my_char.TargetID);

                        if (player != null)
                        {
                            ServerPackets.Force_Attack(Globals.gamedata.my_char.TargetID, Util.Float_Int32(player.X), Util.Float_Int32(player.Y), Util.Float_Int32(player.Z), false);
                        }
                    }
                    finally
                    {
                        Globals.PlayerLock.ExitReadLock();
                    }
                    break;
                case TargetType.NPC:
                    Globals.NPCLock.EnterReadLock();
                    try
                    {
                        NPCInfo npc = Util.GetNPC(Globals.gamedata.my_char.TargetID);

                        if (npc != null)
                        {
                            ServerPackets.Force_Attack(Globals.gamedata.my_char.TargetID, Util.Float_Int32(npc.X), Util.Float_Int32(npc.Y), Util.Float_Int32(npc.Z), false);
                        }
                    }
                    finally
                    {
                        Globals.NPCLock.ExitReadLock();
                    }
                    break;
            }
        }