private void OnPlayerInfo(MsgBase b) { var selfMsg = (Msg_AgarPlayInfo)b; uint id = selfMsg.UserId; if (selfMsg.Operat == Msg_AgarPlayInfo.Add) { var player = new DefaultUserCircle( new Vector2(selfMsg.X, selfMsg.Y), selfMsg.Radius, selfMsg.Color, selfMsg.Name); CircleList[id] = player; this.AddChind(player, OtherPlayerZOrder); } else if (selfMsg.Operat == Msg_AgarPlayInfo.Remove) { if (!CircleList.ContainsKey(id)) { return; } var player = CircleList[id]; this.RemoveChild(player); CircleList.Remove(id); } else if (selfMsg.Operat == Msg_AgarPlayInfo.Changed) { if (!CircleList.ContainsKey(id)) { return; } uint tag = selfMsg.Tag; var player = CircleList[id]; if (GameMessageHelper.Is_Changed(tag, GameMessageHelper.POSITION_TAG)) { player.Position = new Vector2(selfMsg.X, selfMsg.Y); } if (GameMessageHelper.Is_Changed(tag, GameMessageHelper.RADIUS_TAG)) { player.Radius = selfMsg.Radius; } if (GameMessageHelper.Is_Changed(tag, GameMessageHelper.COLOR_TAG)) { player.ColorProperty = selfMsg.Color.ToColor(); } if (GameMessageHelper.Is_Changed(tag, GameMessageHelper.NAME_TAG)) { player.Name = selfMsg.Name; } } }
private void OnPlayInfoPack(MsgBase b) { var selfMsg = (Msg_AgarPlayInfoPack)b; foreach (var obj in selfMsg.PLayerList) { uint pid = obj.Item1; var player = new DefaultUserCircle( new Vector2(obj.Item2, obj.Item3), obj.Item4, obj.Item5, obj.Item6); CircleList[pid] = player; this.AddChind(player, OtherPlayerZOrder); } }
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); } }