Esempio n. 1
0
 public void Change(uint id, PlayerBall newBall)
 {
     if (PlayerDictionary.ContainsKey(id))
     {
         PlayerDictionary[id] = newBall;
     }
 }
Esempio n. 2
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;
 }
Esempio n. 3
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;
 }
Esempio n. 4
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;
 }
Esempio n. 5
0
 public void Add(uint id, PlayerBall player)
 {
     PlayerDictionary[id] = player;
 }
Esempio n. 6
0
        private static bool OnProcessBorn(NetServer server, int id, NetIncomingMessage msg)
        {
            var r = new Msg_AgarBorn();
            r.R(msg);

            uint uid    = r.UserId;
            string name = r.Name;

            int x       = RandomMaker.Next(GameWidth);
            int y       = RandomMaker.Next(GameHeight);
            int radius  = PlayerBall.DefaultPlayerRadius;
            uint c      = CustomColors.RandomColor;

            // 添加Player到Manager
            PlayerBall player   = new PlayerBall();
            player.X            = x;
            player.Y            = y;
            player.Radius       = radius;
            player.Color        = c;
            player.Name         = name;
            PlayerBallMgr.Add(uid, player);

            MarkMgr.Update(uid, radius);

            // 更新链接对应的ID
            AgarConnMgr.Modify(msg.SenderConnection, uid);

            // 向自身发送出生位置等信息
            var selfMsg         = new Msg_AgarSelf();
            selfMsg.Operat      = Msg_AgarSelf.Born;
            selfMsg.X           = x;
            selfMsg.Y           = y;
            selfMsg.Radius      = radius;
            selfMsg.Color       = c;
            SendMessage(server, selfMsg, msg.SenderConnection);

            // 向之前加入的玩家推送新用户出生信息
            var oMsg        = new Msg_AgarPlayInfo();
            oMsg.Operat     = Msg_AgarPlayInfo.Add;
            oMsg.UserId     = uid;
            oMsg.Tag        = GameMessageHelper.ALL_TAG;
            oMsg.X          = x;
            oMsg.Y          = y;
            oMsg.Radius     = radius;
            oMsg.Color      = c;
            oMsg.Name       = name;
            SendMessageExceptOne(server, oMsg, msg.SenderConnection);
            return true;
        }