Exemplo n.º 1
0
        public static bool UpdatePlayer(uint id, ref PlayerBall ball)
        {
            bool PlayerDeadFlag = false;

            foreach (var obj in PlayerBallMgr.ToList())
            {
                if (obj.Key != id && CanEat(ball, obj.Value))
                {
                    PlayerDeadFlag = true;
                    ball.Radius   += obj.Value.Radius;
                    PlayerBallMgr.Dead(obj.Key);
                }
            }
            return(PlayerDeadFlag);
        }
Exemplo n.º 2
0
        public static bool UpdateOtherPlayer(uint id, PlayerBall ball, out uint EatId)
        {
            bool PlayerDeadFlag = false;
            uint did            = 0;

            foreach (var obj in PlayerBallMgr.ToList())
            {
                if (obj.Key != id && CanEat(obj.Value, ball))
                {
                    PlayerDeadFlag = true;
                    did            = obj.Key;
                    PlayerBallMgr.Dead(id);
                    break;
                }
            }
            EatId = did;
            return(PlayerDeadFlag);
        }
Exemplo n.º 3
0
        private static bool OnProcessLogin(NetServer server, int id, NetIncomingMessage msg)
        {
            uint uid = AgarGameId;

            Msg_AgarLogin r = new Msg_AgarLogin();

            r.R(msg);

            Msg_AgarLoginRsp rr = new Msg_AgarLoginRsp();

            rr.Uid    = uid;
            rr.Width  = GameWidth;
            rr.Height = GameHeight;
            SendMessage(server, rr, msg.SenderConnection);

            // 推送之前加入的玩家数据到新玩家
            var PlayerList     = PlayerBallMgr.ToList();
            var PlayerPackList =
                from p
                in PlayerList
                select Tuple.Create <uint, float, float, int, uint, string>
                    (p.Key, p.Value.X, p.Value.Y, p.Value.Radius, p.Value.Color, p.Value.Name);

            var PlayerPack = new Msg_AgarPlayInfoPack();

            PlayerPack.PLayerList = PlayerPackList.ToList();
            SendMessage(server, PlayerPack, msg.SenderConnection);

            // 为新加入的玩家推送FixedBall
            var FixedList     = FixedBallMgr.ToList();
            var FixedPackList =
                from f
                in FixedList
                select Tuple.Create <uint, float, float, int, uint>(f.Key, f.Value.X, f.Value.Y,
                                                                    f.Value.Radius, f.Value.Color);

            var FixedPack = new Msg_AgarFixBallPack();

            FixedPack.FixedList = FixedPackList.ToList();
            SendMessage(server, FixedPack, msg.SenderConnection);
            return(true);
        }