public User(string user, int userId, int teamId, int inDisplay) : base() { delta = Vector2.Zero; username = user; id = userId; display = inDisplay; scale = 1.0f; dampening = 0.8f; maxSpeed = 20f; action = (int)Actions.Idling; spriteBatch = ScreenManager.spriteBatch; collector = CollectorManager.CollectorByID(teamId); collector.AddUser(this); pointsNotification = new Notification(2.5f); badgeNotification = new Notification(3f); pointsAbsorbDelay = new Durationizer(0.5f); usernameFont = ContentManager.Font("user_name"); userpointsFont = ContentManager.Font("user_points"); teamRing = ContentManager.Sprite("user_team"); SetupOffsets(); SetupAnimations(); Audio.Play("user.spawn", display); }
public override void Initialize() { users = new List <User>(); EventManager.On("user:new", (o) => { int id = (int)o["id"]; int teamId = (int)o["teamId"]; int display = (int)o["display"]; users.Add(new User((string)o["username"], id, teamId, display)); }); EventManager.On("user:disconnect", (o) => { int id = (int)o["id"]; var user = users.FirstOrDefault(u => u.id == id); if (user != null) { user.Disconnect(); } }); EventManager.On("user:getPoints", (o) => { User user = UserByID((int)o["id"]); if (user != null) { user.GetPoints((int)o["value"]); } }); EventManager.On("user:getBadge", (o) => { User user = UserByID((int)o["id"]); if (user != null) { user.GetBadge((string)o["type"]); } }); EventManager.On("user:touch", (o) => { User user = UserByID((int)o["id"]); if (user != null) { user.SetDelta((int)o["x"], (int)o["y"]); } }); EventManager.On("user:touchEnd", (o) => { User user = UserByID((int)o["id"]); if (user != null) { user.SetDelta(0, 0); } }); EventManager.On("user:bloat", (o) => { User user = UserByID((int)o["id"]); if (user != null) { user.BloatStart(); } }); EventManager.On("user:pinch", (o) => { User user = UserByID((int)o["id"]); if (user != null) { user.PinchStart(); } }); EventManager.On("user:bloatEnd", (o) => { User user = UserByID((int)o["id"]); if (user != null) { user.BloatEnd(); } }); EventManager.On("user:pinchEnd", (o) => { User user = UserByID((int)o["id"]); if (user != null) { user.PinchEnd(); } }); EventManager.On("user:newTeam", (o) => { User user = UserByID((int)o["id"]); if (user != null) { user.collector = CollectorManager.CollectorByID((int)o["teamId"]); } }); base.Initialize(); }