NodeBB

    • Login
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    sử dụng ACTk unity cho hiệu quả

    Developer Discussion
    1
    2
    5
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      changx last edited by changx

      đố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 1 Reply Last reply Reply Quote 0
      • C
        changx @changx last edited by

        // 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;
            } 
        }
        
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Powered by NodeBB | Contributors