private static object process(SetWorldSize wsize) { if (wsize == null) { return(null); } return(wsize); }
private void catchMessage(object obj) { if (obj == null) { return; } Type type = obj.GetType(); switch (type.Name.ToString()) { case "CollectableData": CollectableData cd = (CollectableData)Convert.ChangeType(obj, type); process(cd); break; case "ScoreData": ScoreData sd = (ScoreData)Convert.ChangeType(obj, type); process(sd); break; case "PlayerData": PlayerData pd = (PlayerData)Convert.ChangeType(obj, type); process(pd); break; //case "LeavingData": // process(ld); // LeavingData ld = (LeavingData)Convert.ChangeType(obj, type); // break; case "ErrorMess": ErrorMess err = (ErrorMess)Convert.ChangeType(obj, type); process(err); break; case "GameMessage": GameMessage msg = (GameMessage)Convert.ChangeType(obj, type); process(msg); break; case "MoveMessage": MoveMessage moveMsg = (MoveMessage)Convert.ChangeType(obj, type); process(moveMsg); break; case "SetWorldSize": SetWorldSize wsize = (SetWorldSize)Convert.ChangeType(obj, type); process(wsize); break; case "TimerData": TimerData tmess = (TimerData)Convert.ChangeType(obj, type); process(tmess); break; default: break; } }
private object process(SetWorldSize wsize) { if (wsize == null) { return(null); } //if (player != null) //{ // Camera must not be reset on a broadcast message if (worldSize == Vector2.Zero) { worldSize = new Vector2(wsize.X, wsize.Y); worldRect = new Rectangle(new Point(0, 0), worldSize.ToPoint()); Vector2 CenterView = new Vector2(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2); followCamera = new FollowCamera(this, Vector2.Zero, worldSize); } //} //else new FadeText(this, new Vector2(20, 20), "Problem setting up world size for camera"); return(wsize); }