示例#1
0
        /// <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;
            }
        }
示例#2
0
        public void BasicTests_ToString()
        {
            var v     = new FixedNumber(123123, 3);
            var value = v.ToString();

            Assert.Equal("123.123", value);
        }
示例#3
0
 public override void Init()
 {
     base.Init();
     physics.enable = true;
     isTrigger      = true;
     startTime      = InputCenter.Time;
 }
示例#4
0
 public override void Init(FSClient client)
 {
     base.Init(client);
     rigibody.useCheckCallBack = true;
     isTrigger = true;
     startTime = client.inputCenter.Time;
 }
示例#5
0
 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;
 }
示例#6
0
 public override void Init()
 {
     key   = KeyNum.Skill1;
     time  = new FixedNumber(0.7f);
     timer = new FixedNumber(0);
     gun   = new GunBase();
     gun.Init(20, data);
 }
示例#7
0
        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);
        }
示例#8
0
 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;
 }
示例#9
0
        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);
        }
示例#10
0
    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);
    }
示例#11
0
 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();
         }
     }
 }
示例#12
0
        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);
        }
示例#13
0
        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
            {
            }
        }
示例#14
0
        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;
        }
示例#15
0
 public override void Update()
 {
     if (timer > 0)
     {
         timer -= data.deltaTime;
     }
     else
     {
         if (data.Input.GetKey(key))
         {
             StayUse();
         }
         if (data.Input.GetKeyUp(key))
         {
             UseOver();
         }
     }
 }
示例#16
0
        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
            {
            }
        }
示例#17
0
        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);
        }
示例#18
0
 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);
 }
示例#19
0
 public override void Init()
 {
     key   = KeyNum.Skill1;
     time  = new FixedNumber(0.7f);
     timer = new FixedNumber(0);
 }
示例#20
0
 public virtual void UseOver()
 {
     timer = time;
     UnityEngine.Debug.LogError("UseOver");
 }
示例#21
0
 public void Reset(Fixed2 position, FixedNumber rotation)
 {
     transform.Reset(position, rotation);
 }