/// <summary>
        /// 玩家特殊魔法,带终点
        /// </summary>
        public void MsgPlayerMagicEndpoint(Player player, BaseProtocol baseProtocol)
        {
            //玩家特殊魔法,终点生成
            //消息结构: (string)PlayerMagic + (string)playerName + (int)magicItemID + (float)endposX+(float)endposY+(float)endposZ
            if (player.playerStatus.status != PlayerStatus.Status.Gaming)
            {
                return;
            }
            Room room = player.playerStatus.room;

            int startIndex = 0;
            BytesProtocol p = baseProtocol as BytesProtocol;
            p.GetString(startIndex, ref startIndex);
            string playerName = p.GetString(startIndex, ref startIndex);
            int magicItemID = p.GetInt(startIndex, ref startIndex);
            float posX = p.GetFloat(startIndex, ref startIndex);
            float posY = p.GetFloat(startIndex, ref startIndex);
            float posZ = p.GetFloat(startIndex, ref startIndex);

            //转发魔法消息
            BytesProtocol p_broadcast = new BytesProtocol();
            p_broadcast.SpliceString("PlayerMagicEndpoint");
            p_broadcast.SpliceString(player.name);
            p_broadcast.SpliceInt(magicItemID);
            p_broadcast.SpliceFloat(posX);
            p_broadcast.SpliceFloat(posY);
            p_broadcast.SpliceFloat(posZ);
            room.Broadcast(p_broadcast);
        }
Beispiel #2
0
        /// <summary>
        /// 毒圈协议
        /// </summary>
        /// <returns></returns>
        public BytesProtocol CirclefieldProtocol()
        {
            BytesProtocol p = new BytesProtocol();

            p.SpliceString("Circlefield");
            Point point = CalcCircleCenter(0, 0, R, circlefieldInfo.Circlefields[circlefieldIndex].ShrinkPercent);

            p.SpliceFloat(point.X);
            p.SpliceFloat(point.Y);
            p.SpliceFloat(circlefieldInfo.Circlefields[circlefieldIndex].ShrinkPercent);
            p.SpliceInt(circlefieldInfo.Circlefields[circlefieldIndex].Movetime);
            Console.WriteLine("pointX:{0} pointY:{1} per:{2} mt{3}", point.X, point.Y, circlefieldInfo.Circlefields[circlefieldIndex].ShrinkPercent, circlefieldInfo.Circlefields[circlefieldIndex].Movetime);
            return(p);
        }
        /// <summary>
        /// 玩家获得有害状态,转发
        /// </summary>
        public void MsgPlayerGetBuff(Player player, BaseProtocol baseProtocol)
        {
            //消息结构: (string)PlayerName + (int)BuffType +(float)buffTime 
            int startIndex = 0;
            BytesProtocol get = baseProtocol as BytesProtocol;
            Room room = player.playerStatus.room;
            get.GetString(startIndex, ref startIndex);
            string PlayerName = get.GetString(startIndex, ref startIndex);
            int bufftype = get.GetInt(startIndex, ref startIndex);
            float bufftime = get.GetFloat(startIndex, ref startIndex);
            if (room.playerDict.ContainsKey(PlayerName))
            {
                room.playerDict[PlayerName].playerStatus.buffType = bufftype;
                room.playerDict[PlayerName].playerStatus.buffTime = bufftime;
            }



            BytesProtocol p = new BytesProtocol();
            p.SpliceString("PlayerGetBuff");
            p.SpliceString(PlayerName);
            p.SpliceInt(bufftype);
            p.SpliceFloat(bufftime);
            foreach (Player pr in room.playerDict.Values)
            {
                p.SpliceString(pr.name);
            }
            player.Send(p);
        }
Beispiel #4
0
        public BytesProtocol CirclefieldProtocol2()
        {
            BytesProtocol p = new BytesProtocol();

            p.SpliceString("Circlefield");
            //Point point= CalcCircleCenter(0, 0, R, circlefieldInfo.Circlefields[circlefieldIndex].ShrinkPercent);
            if (CalcCenterOnce)
            {
                CalcCenterOnce = false;
                lastPoint.X    = (float)Utility.NextDouble(new Random(), 20, 60);
                lastPoint.Y    = (float)Utility.NextDouble(new Random(), 20, 60);
            }
            p.SpliceFloat(lastPoint.X);
            p.SpliceFloat(lastPoint.Y);
            p.SpliceFloat(circlefieldInfo.Circlefields[circlefieldIndex].ShrinkPercent);
            p.SpliceInt(circlefieldInfo.Circlefields[circlefieldIndex].Movetime);
            Console.WriteLine("pointX:{0} pointY:{1} Shrinkper:{2} movetime{3} Round:{4}", lastPoint.X, lastPoint.Y, circlefieldInfo.Circlefields[circlefieldIndex].ShrinkPercent, circlefieldInfo.Circlefields[circlefieldIndex].Movetime, circlefieldIndex);
            return(p);
        }
        /// <summary>
        /// 玩家扔物品
        /// </summary>
        public void MsgDropItem(Player player, BaseProtocol baseProtocol)
        {
            //拾取物品
            //消息结构: (string)PickItem + (int)GroundItemID
            int startIndex = 0;
            BytesProtocol p = baseProtocol as BytesProtocol;
            p.GetString(startIndex, ref startIndex);
            int GroundItemID = p.GetInt(startIndex, ref startIndex);
            float posX = p.GetFloat(startIndex, ref startIndex);
            float posY = p.GetFloat(startIndex, ref startIndex);
            float posZ = p.GetFloat(startIndex, ref startIndex);

            //转发魔法消息
            BytesProtocol p_broadcast = new BytesProtocol();
            p_broadcast.SpliceString("DropItem");
            p_broadcast.SpliceInt(GroundItemID);
            p_broadcast.SpliceFloat(posX);
            p_broadcast.SpliceFloat(posY);
            p_broadcast.SpliceFloat(posZ);
            player.playerStatus.room.Broadcast(p);
        }
        /// <summary>
        /// 玩家一般魔法,起点位置,起点旋转度
        /// </summary>
        /// <param name="player"></param>
        /// <param name="baseProtocol"></param>
        public void MsgPlayerMagic(Player player, BaseProtocol baseProtocol)
        {

            //玩家魔法
            //消息结构: (string)PlayerMagic  + (string)magicName + (float)posX + (float)posY +(float)posZ+ (float)rotX + (float)rotY + (float)rotZ
            //if (player.playerStatus.status != PlayerStatus.Status.Gaming)
            //{
            //    return;
            //}
            Room room = player.playerStatus.room;

            int startIndex = 0;
            BytesProtocol p = baseProtocol as BytesProtocol;
            p.GetString(startIndex, ref startIndex);
            string magicName = p.GetString(startIndex, ref startIndex);
            float posX = p.GetFloat(startIndex, ref startIndex);
            float posY = p.GetFloat(startIndex, ref startIndex);
            float posZ = p.GetFloat(startIndex, ref startIndex);
            float rotX = p.GetFloat(startIndex, ref startIndex);
            float rotY = p.GetFloat(startIndex, ref startIndex);
            float rotZ = p.GetFloat(startIndex, ref startIndex);

            //转发魔法消息
            BytesProtocol p_broadcast = new BytesProtocol();
            p_broadcast.SpliceString("PlayerMagic");
            p_broadcast.SpliceString(magicName);
            p_broadcast.SpliceFloat(posX);
            p_broadcast.SpliceFloat(posY);
            p_broadcast.SpliceFloat(posZ);
            p_broadcast.SpliceFloat(rotX);
            p_broadcast.SpliceFloat(rotY);
            p_broadcast.SpliceFloat(rotZ);
            room.Broadcast(p_broadcast);
        }
Beispiel #7
0
        /// <summary>
        /// 开始战局
        /// </summary>
        public void StartGame()
        {
            BytesProtocol p = new BytesProtocol();

            p.SpliceString("StartGame");
            status = Status.Ongame;
            lock (playerDict)
            {
                //玩家数
                p.SpliceInt(playerDict.Count);
                foreach (Player player in playerDict.Values)
                {
                    player.playerStatus.HP = 100f;
                    p.SpliceString(player.name);
                    p.SpliceFloat(player.playerStatus.HP);
                }
                Broadcast(p);
            }
        }
        /// <summary>
        /// 更新玩家信息
        /// </summary>
        public void MsgUpdatePlayerInfo(Player player, BaseProtocol baseProtocol)
        {
            //if (player.playerStatus.status != PlayerStatus.Status.Gaming)
            //{
            //    return;
            //}
            BytesProtocol p = baseProtocol as BytesProtocol;
            int startIndex = 0;
            p.GetString(startIndex, ref startIndex);
            float posX = p.GetFloat(startIndex, ref startIndex);
            float posY = p.GetFloat(startIndex, ref startIndex);
            float posZ = p.GetFloat(startIndex, ref startIndex);
            float rotX = p.GetFloat(startIndex, ref startIndex);
            float rotY = p.GetFloat(startIndex, ref startIndex);
            float rotZ = p.GetFloat(startIndex, ref startIndex);
            string CurrentAction = p.GetString(startIndex, ref startIndex);

            player.playerStatus.posX = posX;
            player.playerStatus.posY = posY;
            player.playerStatus.posZ = posZ;
            player.playerStatus.CurrentAction = CurrentAction;
            player.playerStatus.LastUpdateTime = Utility.GetTimeStamp();

            BytesProtocol protocolReturn = new BytesProtocol();
            protocolReturn.SpliceString("UpdatePlayerInfo");
            protocolReturn.SpliceString(player.name);
            protocolReturn.SpliceFloat(player.playerStatus.HP);
            protocolReturn.SpliceFloat(posX);
            protocolReturn.SpliceFloat(posY);
            protocolReturn.SpliceFloat(posZ);
            protocolReturn.SpliceFloat(rotX);
            protocolReturn.SpliceFloat(rotY);
            protocolReturn.SpliceFloat(rotZ);
            protocolReturn.SpliceString(CurrentAction);
            player.playerStatus.room.Broadcast(protocolReturn);
        }