コード例 #1
0
ファイル: BallGameDataEvent.cs プロジェクト: xxy1991/cozy
        private void OnLoginRsp(MsgBase b)
        {
            var selfMsg     = (Msg_AgarLoginRsp)b;
            Uid             = selfMsg.Uid;
            int X_Size      = selfMsg.Width;
            int Y_Size      = selfMsg.Height;
            MapSize         = new Point(X_Size, Y_Size);

            string RdName   = "TestName-" + RandomMaker.NextString(5);
            var bornMsg     = new Msg_AgarBorn();
            bornMsg.UserId  = Uid;
            bornMsg.Name    = RdName;
            Name            = RdName;

            client.SendMessage(bornMsg);
        }
コード例 #2
0
ファイル: AgarMessageProcess.cs プロジェクト: xxy1991/cozy
        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;
        }
コード例 #3
0
ファイル: BallGameDataEvent.cs プロジェクト: xxy1991/cozy
        private void OnSelf(MsgBase b)
        {
            var selfMsg = (Msg_AgarSelf)b;

            if (selfMsg.Operat == Msg_AgarSelf.Born)
            {
                float x = selfMsg.X;
                float y = selfMsg.Y;
                int r   = selfMsg.Radius;
                uint c  = selfMsg.Color;

                DefaultRadius = r;
                Player = new DefaultUserCircle(new Vector2(x, y), r, c, Name);

                this.AddChind(Player, PlayerZOrder);

                if (ScoreShow != null)
                    ScoreShow.Text = String.Format("Score : {0}", Player.Radius - DefaultRadius);
            }
            else if (selfMsg.Operat == Msg_AgarSelf.GroupUp)
            {
                Player.Radius = selfMsg.Radius;
                if (ScoreShow != null)
                    ScoreShow.Text = String.Format("Score : {0}", Player.Radius - DefaultRadius);
            }
            else if (selfMsg.Operat == Msg_AgarSelf.Dead)
            {
                this.RemoveChild(Player);
                Player = null;

                // 玩家重生
                string RdName   = "TestName-" + RandomMaker.NextString(5);
                var bornMsg     = new Msg_AgarBorn();
                bornMsg.UserId  = Uid;
                bornMsg.Name    = RdName;
                Name            = RdName;

                client.SendMessage(bornMsg);
            }
        }