/// <summary> /// 接收帧消息 并解析消息 /// </summary> /// <param name="protocol">服务器发过来的帧信息</param> public void ReceiveStep(ProtocolBase protocol) { //获取玩家客户端个数 int length = protocol.getByte(); _m_serverStep++; Debug.Log("分布解析:" + protocol.Length); for (int i = 0; i < length; i++) { //解析各个玩家输入 _m_inputs[i].ReceiveStep(protocol); } //执行帧调用函数 for (; _m_clientStep < _m_serverStep; _m_clientStep++) { if (frameUpdate != null) { frameUpdate(); Tree4.CheckTree(); } this._time += FSClient.deltaTime; } }
public void BasicTests_ToString() { var v = new FixedNumber(123123, 3); var value = v.ToString(); Assert.Equal("123.123", value); }
public override void Init() { base.Init(); physics.enable = true; isTrigger = true; startTime = InputCenter.Time; }
public override void Init(FSClient client) { base.Init(client); rigibody.useCheckCallBack = true; isTrigger = true; startTime = client.inputCenter.Time; }
public void Init(float firingRate, NetData User) { this.firingInterval = new FixedNumber(1 / firingRate); lastTime = FixedNumber.Zero; // gunSetting = DataManager.Instance.gunManager.gun; this.user = User; timer = FixedNumber.Zero; }
public override void Init() { key = KeyNum.Skill1; time = new FixedNumber(0.7f); timer = new FixedNumber(0); gun = new GunBase(); gun.Init(20, data); }
public void BasicTests_Splits() { var v = new FixedNumber(12312345678, 3); Assert.Equal(12312345, v.WholePart); Assert.Equal(678, v.Fraction); Assert.Equal(11, v.Precision); Assert.Equal(3, v.Scale); }
public BoxShap(FixedNumber x, FixedNumber y) { Fixed2[] v2s = new Fixed2[4]; v2s[0] = new Fixed2(x / 2, y / 2); v2s[1] = new Fixed2(-x / 2, y / 2); v2s[2] = new Fixed2(x / 2, -y / 2); v2s[3] = new Fixed2(-x / 2, -y / 2); Points = v2s; }
protected virtual void ShootBullet(Fixed2 position, FixedNumber rotation) { Bullet data = new Bullet(); data.user = this.user; data.Init(user.client); data.Reset(position, rotation); user.client.objectManager.Instantiate(data); }
protected void ShootBullet(Fixed2 position, FixedNumber rotation) { Bullet bullet = new Bullet(); bullet.user = data; bullet.Init(); bullet.Reset(position, rotation); NetObjectManager.Instantiate <Bullet>(bullet); // UnityEngine.Debug.LogError("bullet" + rotation); }
public virtual void GetHurt(FixedNumber atk) { if (!isDead) { _m_Hp -= atk; Debug.Log(this.name + " GetHurt " + atk + " Hp:" + _m_Hp); if (_m_Hp <= 0) { Die(); } } }
public void BasicTests_Operators() { var v = new FixedNumber(123123, 3); Assert.Equal(123, v.WholePart); Assert.Equal(123, v.Fraction); v += 100; Assert.Equal(223, v.WholePart); Assert.Equal(123, v.Fraction); v -= 100; Assert.Equal(123, v.WholePart); Assert.Equal(123, v.Fraction); }
public void Fire(NetData user, FixedNumber rotation) { var t = user.client.inputCenter.Time - lastTime; if (t > 0.1f) { FixedNumber rote = new FixedNumber(0); lastTime = user.client.inputCenter.Time; ShootBullet(user.transform.Position, rotation + rote); } else { } }
public CircleShap(FixedNumber r, int num) { FixedNumber t360 = new FixedNumber(360); FixedNumber tmp = t360 / num; Fixed2[] v2s = new Fixed2[num]; int i = 0; for (FixedNumber tr = new FixedNumber(0); tr < t360 && i < num; tr += tmp, i++) { v2s[i] = Fixed2.Parse(tr) * r; } Points = v2s; }
public override void Update() { if (timer > 0) { timer -= data.deltaTime; } else { if (data.Input.GetKey(key)) { StayUse(); } if (data.Input.GetKeyUp(key)) { UseOver(); } } }
public void Fire(Fixed2 position, FixedNumber rotation) { var t = InputCenter.Time - lastTime; if (t > gunSetting.fireRate) { timer += (gunSetting.recoilTime + gunSetting.fireRate - t); if (timer <= 0) { timer = new FixedNumber(0); } FixedNumber rote = new FixedNumber(gunSetting.recoilFrouceCurve.Evaluate(timer.ToFloat()) - 1) * gunSetting.recoilScale; lastTime = InputCenter.Time; ShootBullet(position, rotation + rote); } else { } }
public void BasicTests_Conversion() { FixedNumber @float = 123.123f; Assert.Equal(123, @float.WholePart); Assert.Equal(123, @float.Fraction); Assert.Equal(6, @float.Precision); Assert.Equal(3, @float.Scale); FixedNumber @double = 123.123d; Assert.Equal(123, @double.WholePart); Assert.Equal(123, @double.Fraction); Assert.Equal(6, @double.Precision); Assert.Equal(3, @double.Scale); FixedNumber @decimal = 123.123m; Assert.Equal(123, @decimal.WholePart); Assert.Equal(123, @decimal.Fraction); Assert.Equal(6, @decimal.Precision); Assert.Equal(3, @decimal.Scale); }
public void BasicTests_Parsing(string s, int wholePart, int fraction) { Assert.True(FixedNumber.TryParse(s, out var v)); Assert.Equal(wholePart, v.WholePart); Assert.Equal(fraction, v.Fraction); }
public override void Init() { key = KeyNum.Skill1; time = new FixedNumber(0.7f); timer = new FixedNumber(0); }
public virtual void UseOver() { timer = time; UnityEngine.Debug.LogError("UseOver"); }
public void Reset(Fixed2 position, FixedNumber rotation) { transform.Reset(position, rotation); }