public void AbilityChanged2_0(HasContactInfo player, Car car, ref List <string> notifyMsgs, string pType) { string fromUrl; int webSocketID; player.GetUrlAndWebsocket(out fromUrl, out webSocketID); var carIndexStr = car.IndexString; long costValue = 0; long sumValue = 1; switch (pType) { case "mile": { costValue = car.ability.costMiles; sumValue = car.ability.mile; }; break; case "business": { costValue = car.ability.costBusiness; sumValue = car.ability.Business; }; break; case "volume": { costValue = car.ability.costVolume; sumValue = car.ability.Volume; }; break; case "speed": { sumValue = car.ability.Speed; costValue = car.ability.Speed; }; break; } var obj = new BradCastAbility { c = "BradCastAbility", WebSocketID = webSocketID, pType = pType, carIndexStr = carIndexStr, costValue = costValue, sumValue = sumValue }; var json = Newtonsoft.Json.JsonConvert.SerializeObject(obj); notifyMsgs.Add(fromUrl); notifyMsgs.Add(json); //throw new NotImplementedException(); }
// enum CostOrSum { Cost, Sum } /// <summary> /// 这里要通知前台,值发生了变化。 /// </summary> /// <param name="player"></param> /// <param name="car"></param> /// <param name="notifyMsgs"></param> /// <param name="pType"></param> public void AbilityChanged2_0(Player player, Car car, ref List <string> notifyMsgs, string pType) { var carIndexStr = car.IndexString; long costValue = 0; long sumValue = 1; switch (pType) { case "mile": { costValue = car.ability.costMiles; sumValue = car.ability.mile; }; break; case "business": { costValue = car.ability.costBusiness; sumValue = car.ability.Business; }; break; case "volume": { costValue = car.ability.costVolume; sumValue = car.ability.Volume; }; break; case "speed": { sumValue = car.ability.Speed; costValue = car.ability.Speed; }; break; } var obj = new BradCastAbility { c = "BradCastAbility", WebSocketID = player.WebSocketID, pType = pType, carIndexStr = carIndexStr, costValue = costValue, sumValue = sumValue }; var json = Newtonsoft.Json.JsonConvert.SerializeObject(obj); notifyMsgs.Add(player.FromUrl); notifyMsgs.Add(json); }