sử dụng ACTk unity cho hiệu quả
-
đối với property
// không an toàn vì khi build ra nó sẽ thành public int get_coin() { // chỗ này quá dễ để cheat chỉnh sửa } public int coin => s_coin; private ObscuredInt s_coin; // chỗ này cũng như property coin bên trên, không sử dụng public int getCoin() { return s_coin; }đổi lại thành
// khó để return 1 ObscuredInt hơn trong memory public ObscuredInt coin => s_coin; private ObscuredInt s_coin;trong hàm
void ChangeGemToCoin() { // 2 cái gemCost và coinRecv không an toàn ObscuredInt gemCost = 10; ObscuredInt coinRecv = 100; // vd logic để thay đổi tiền applicationUser.gem -= gemCost; applicationUser.coin += coinRecv; }đổi lại thành
// cái này này đảm bảo việc GEM_COST và COIN_RECV phải được tạo ra khi vừa start chương trình public class GlobalConstance { public static readonly ObscuredInt GEM_COST = 10; public static readonly ObscuredInt COIN_RECV = 100; } void ChangeGemToCoin() { ObscuredInt gemCost = GlobalConstance.GEM_COST; ObscuredInt coinRecv = GlobalConstance.COIN_RECV; // vd logic để thay đổi tiền applicationUser.gem -= gemCost; applicationUser.coin += coinRecv; } -
// cả 2 cái initValue1 và initValue2 có 5 và 3 đều dễ bị chỉnh sửa, thay thành dạng GlobalConstance hoặc static readonly ObscuredInt INIT_VALUE_1= 5; public class ConfigItem { public ObscuredInt initValue1 = 5; public ObscuredInt initValue2; public ConfigItem () { initValue2 = 3; } }