LockInt
Posted rexzhao
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LockInt相关的知识,希望对你有一定的参考价值。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Game.LockNumbers
{
public struct LockInt
{
int vbase;
int vadd;
static readonly int base_flag = 29173;
static readonly int add_flag = 16829;
public int Value{
get { return ( (~vbase + base_flag) >> 1) + vadd + add_flag; }
set
{
var _base = (int)(value * 0.37134f);
vbase = (_base << 1) - base_flag;
vbase = ~vbase;
vadd = (value - _base);
vadd -= add_flag;
}
}
public LockInt(int v)
{
vbase = 0;
vadd = 0;
Value = v;
}
public static implicit operator int(LockInt v)
{
return v.Value;
}
public static implicit operator LockInt(int b)
{
LockInt d ;
d.vadd = 0;
d.vbase = 0;
d.Value = b;
return d;
}
public static LockInt operator + (LockInt v1, LockInt v2)
{
return v1.Value + v2.Value;
}
public static LockInt operator -(LockInt v1, LockInt v2)
{
return v1.Value - v2.Value;
}
public static LockInt operator *(LockInt v1, LockInt v2)
{
return v1.Value * v2.Value;
}
public static LockInt operator /(LockInt v1, LockInt v2)
{
return v1.Value / v2.Value;
}
}
}
lockint +=1;
locakint =1;
以上是关于LockInt的主要内容,如果未能解决你的问题,请参考以下文章