Chuyển đến nội dung chính

Bài 9: Xóa Người và Xóa Item

 

Dạo này hơi lười giải thích nên ae cứ copy cho nhanh nhé

//Xóa Item

#Khai báo

public static bool isDelItem;

public void xoaItem()

{

for (int i = 0; i < GameScr.vItemMap.size(); i++)

{

ItemMap itemMap = (ItemMap)GameScr.vItemMap.elementAt(i);

if (itemMap != null && itemMap.playerId != Char.myCharz().charID && itemMap.playerId != -1)

{

GameScr.vItemMap.removeElementAt(i);

}

}

}

#Update

if (isDelItem)

{

gI().xoaItem();

}

#Bật/Tắt

isDelItem = !isDelItem;


//Xóa người trừ BOSS

#Khai báo

public static MyVector NBoss = new MyVector();

public static bool isDelChar;

public void XoaNguoi()

{

for (int i = 0; i < GameScr.vCharInMap.size(); i++)

{

Char @char = (Char)GameScr.vCharInMap.elementAt(i);

if (@char != null && @char.charID != Char.myCharz().charID * -1 && @char.bag != 31)

{

if (NBoss.size() > 0 && !checkBoss(@char.cName.ToLower()))

{

GameScr.vCharInMap.removeElementAt(i);

}

if ((NBoss == null || NBoss.size() <= 0) && @char.cTypePk != 5)

{

GameScr.vCharInMap.removeElementAt(i);

}

}

}

}

#Check Boss

public static bool checkBoss(string str)

{

if (NBoss.size() <= 0)

{

return true;

}

for (int i = 0; i < NBoss.size(); i++)

{

string text = (string)NBoss.elementAt(i);

if (str.ToLower().IndexOf(text) != -1 && text != string.Empty)

{

return true;

}

}

return false;

}

#Update

if (isDelChar)

{

XoaNguoi();

}

#Bật tắt

isDelChar = !isDelChar;

Nhận xét

Bài đăng phổ biến từ blog này

Bài 7: Tạo Menu Dùng Chức Năng Nhanh

Bài 2: Liên Kết Chức Năng Vào Class Riêng

Bài 1: Hướng Dẫn Tạo Class Riêng