예제 #1
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);
        }
예제 #2
0
        public static bool UpdateFood(uint id, ref PlayerBall ball)
        {
            bool FoodRemoveFlag = false;

            foreach (var obj in FixedBallMgr.ToList())
            {
                if (CanEat(ball, obj.Value))
                {
                    FoodRemoveFlag = true;
                    if (ball.Radius < PlayerBall.DefaultPlayerNoFoodRadius)
                    {
                        ball.Radius++;
                    }
                    FixedBallMgr.Remove(obj.Key);
                }
            }
            if (FoodRemoveFlag)
            {
                FixedBallMgr.Update();
            }
            return(FoodRemoveFlag);
        }