Beispiel #1
0
        public void MsgShooting(Player player, ProtocolBase protoBase)
        {
            //获取数值
            ProtocolBytes protocol  = (ProtocolBytes)protoBase;
            int           start     = 0;
            string        protoName = protocol.GetString(start, ref start);
            float         posx      = protocol.GetFloat(start, ref start);
            float         posy      = protocol.GetFloat(start, ref start);
            float         posz      = protocol.GetFloat(start, ref start);
            float         rotx      = protocol.GetFloat(start, ref start);
            float         roty      = protocol.GetFloat(start, ref start);
            float         rotz      = protocol.GetFloat(start, ref start);

            if (player.tempData.status != PlayerTempData.Status.Fight)
            {
                return;
            }
            Room room = player.tempData.room;

            ProtocolBytes protocolRet = new ProtocolBytes();

            protocolRet.AddString("Shooting");
            protocolRet.AddString(player.id);
            protocolRet.AddFloat(posx);
            protocolRet.AddFloat(posy);
            protocolRet.AddFloat(posz);
            protocolRet.AddFloat(rotx);
            protocolRet.AddFloat(roty);
            protocolRet.AddFloat(rotz);
            room.Broadcast(protocolRet);
        }
Beispiel #2
0
        public void MsgHit(Player player, ProtocolBase protoBase)
        {
            int           start         = 0;
            ProtocolBytes protocol      = (ProtocolBytes)protoBase;
            string        protoName     = protocol.GetString(start, ref start);
            string        enemyName     = protocol.GetString(start, ref start);
            float         damage        = protocol.GetFloat(start, ref start);
            long          lastShootTime = player.tempData.lastShootTime;

            if (Sys.Getimetamp() - lastShootTime < 1)
            {
                Console.WriteLine("有点问题");
                return;
            }
            player.tempData.lastShootTime = Sys.Getimetamp();
            //Get Room
            if (player.tempData.status != PlayerTempData.Status.Fight)
            {
                return;
            }
            Room room = player.tempData.room;

            //life
            if (!room.list.ContainsKey(enemyName))
            {
                Console.WriteLine("MsgHit net Contains enemy " + enemyName);
                return;
            }
            Player enemy = room.list[enemyName];

            if (enemy == null)
            {
                return;
            }
            if (enemy.tempData.hp <= 0)
            {
                return;
            }
            enemy.tempData.hp -= damage;
            Console.WriteLine("MsgHit enemyname" + enemyName);
            ProtocolBytes protocolRet = new ProtocolBytes();

            protocolRet.AddString("Hit");
            protocolRet.AddString(player.id);
            protocolRet.AddString(enemy.id);
            protocolRet.AddFloat(damage);
            room.Broadcast(protocolRet);
            room.UpdateWin();
        }
Beispiel #3
0
        //更新信息
        public void MsgUpdateInfo(Player player, ProtocolBase protoBase)
        {
            //获取分数
            int           start     = 0;
            ProtocolBytes protocol  = (ProtocolBytes)protoBase;
            string        protoname = protocol.GetString(start, ref start);
            float         x         = protocol.GetFloat(start, ref start);
            float         y         = protocol.GetFloat(start, ref start);
            float         z         = protocol.GetFloat(start, ref start);
            int           score     = protocol.GetInt(start, ref start);

            Scene.Scener.instance.UpdateInfo(protoname, x, y, z, score);

            //广播
            ProtocolBytes protocolret = new ProtocolBytes();

            protocolret.AddString("UpdateInfo");
            protocolret.AddString(player.id);
            protocolret.AddFloat(x);
            protocolret.AddFloat(y);
            protocolret.AddFloat(z);
            protocolret.AddInt(score);
            ServNet.instance.Broadcast(protocolret);
        }
Beispiel #4
0
        public void MsgUpdateUnitInfo(Player player, ProtocolBase protocolBase)
        {
            int           start     = 0;
            ProtocolBytes protocol  = (ProtocolBytes)protocolBase;
            string        protoName = protocol.GetString(start, ref start);
            float         posx      = protocol.GetFloat(start, ref start);
            float         posy      = protocol.GetFloat(start, ref start);
            float         posz      = protocol.GetFloat(start, ref start);
            float         rotx      = protocol.GetFloat(start, ref start);
            float         roty      = protocol.GetFloat(start, ref start);
            float         rotz      = protocol.GetFloat(start, ref start);

            float gunRot  = protocol.GetFloat(start, ref start);
            float gunRoll = protocol.GetFloat(start, ref start);

            //获取房间
            if (player.tempData.status != PlayerTempData.Status.Fight)
            {
                return;
            }
            Room room = player.tempData.room;

            player.tempData.posX           = posx;
            player.tempData.posY           = posy;
            player.tempData.posZ           = posz;
            player.tempData.lastUpdateTime = Sys.Getimetamp();

            ProtocolBytes protocolRet = new ProtocolBytes();

            protocolRet.AddString("UpdateUnitInfo");
            protocolRet.AddString(player.id);
            protocolRet.AddFloat(posx);
            protocolRet.AddFloat(posy);
            protocolRet.AddFloat(posz);
            protocolRet.AddFloat(rotx);
            protocolRet.AddFloat(roty);
            protocolRet.AddFloat(rotz);

            protocolRet.AddFloat(gunRot);
            protocolRet.AddFloat(gunRoll);
            room.Broadcast(protocolRet);
        }