private static object process(MoveMessage moveMessage) { if (moveMessage == null) { return(null); } return(moveMessage); }
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 void process(MoveMessage moveMsg) { OtherPlayer found = OtherPlayers.FirstOrDefault(o => o.playerData.playerID == moveMsg.playerID); if (found != null) { found.Position = new Vector2(moveMsg.NewX, moveMsg.NewY); } }