本文整理汇总了C#中Weather类的典型用法代码示例。如果您正苦于以下问题:C# Weather类的具体用法?C# Weather怎么用?C# Weather使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Weather类属于命名空间,在下文中一共展示了Weather类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
/*
@"<response>
<version>0.1</version>
<current_observation>
<display_location>
<city>Moscow</city>
</display_location>
<temp_c>-2</temp_c>
<relative_humidity>93%</relative_humidity>
<pressure_mb>1016</pressure_mb>
</current_observation>
</response>";
*/
public override Weather Parse(string str)
{
try
{
var xdoc = XDocument.Parse(str);
var ver = xdoc.XPathSelectValue("/response/version/text()");
if (ver != "0.1")
{
throw new FormatException("Version incompatibility (not equal 0.1)");
}
var weather = new Weather();
var rootPrefix = "/response/current_observation";
var tempStr = xdoc.XPathSelectValue(rootPrefix + "/temp_c/text()");
weather.TemperatureC = float.Parse(tempStr);
var humidityStr = xdoc.XPathSelectValue(rootPrefix + "/relative_humidity/text()");
humidityStr = humidityStr.Replace("%", "");
weather.HumidityPct = float.Parse(humidityStr) / 100;
var presStr = xdoc.XPathSelectValue(rootPrefix + "/pressure_mb/text()");
weather.PressureMB = float.Parse(presStr);
return weather;
}
catch (Exception e)
{
throw new ParseException("Wunderground service response parse error", e);
}
}
示例2: CalcScore
private static int CalcScore(IPlayerState state, Weather weather, int maxCard)
{
// winter -> drummer -> spring
// winter makes everything worth 1
// spring makes the global largest card worth +3
// sum the normal cards & apply winter
var score = state.Desk
.Where(card => !card.IsSpecial && card.HasValue)
.Sum(card => weather == Weather.Winter ? 1 : card.Value);
if (IsDebugEnabled) log.Debug("Value card sum: " + score);
// drummer
if (state.Desk.FirstOrDefault(c => c.Kind == CardType.Drummer) != null)
{
score *= 2;
if (IsDebugEnabled) log.Debug("With drummer: " + score);
}
// spring
if (weather == Weather.Spring)
{
// apply spring
var maxCardNum = state.Desk
.Where(card => !card.IsSpecial && card.HasValue && card.Value == maxCard)
.Count();
score += maxCardNum * 3;
if (IsDebugEnabled)
{
log.Debug("Found {0} cards with maxValue {1}", maxCardNum, maxCard);
log.Debug("With spring: " + score);
}
}
// special value cards (modifiers do not apply)
score += state.Desk.Where(c => c.IsSpecial && c.HasValue).Sum(c => c.Value);
if (IsDebugEnabled)
{
log.Debug("With specials: " + score);
log.Debug("Scoring done.");
}
return score;
}
示例3: Start
// Use this for initialization
void Start () {
waterZones = GameObject.FindGameObjectsWithTag("InteractableWater");
currentWeather = Weather.CLEAR;
day = true;
skybox = RenderSettings.skybox;
skybox.SetFloat("_DayToNight", 0f);
skybox.SetFloat("_RainToSnow", 0f);
skybox.SetFloat("_NormalToRainSnow", 0f);
skybox.SetFloat("_RainSnowToSpecial", 0f);
mainLight = FindObjectOfType<Light>();
foreach (Material m in materials)
{
m.SetFloat("_Snow", 0f);
}
rain = GameObject.Find("PS_Rain");
snow = GameObject.Find("PS_Snowflakes");
other = GameObject.Find("PS_weather");
rain.SetActive(false);
snow.SetActive(false);
other.SetActive(false);
tM = FindObjectOfType<TrackManager>();
SetAurore(false);
}
示例4: Ball
public Ball(Game game, Weather weather)
: base(game)
{
//size = texture.Width;
Size = 15;
Shot = false;
Pass = false;
FreeKick = true;
//set the initial position and acceleration
Reset();
//bound box rectangle
Rectangle = new Rectangle((int)Position.X, (int)Position.Y, Size, Size);
//current player who has the ball
CurrentPlayer = null;
switch (weather)
{
case Weather.sunny:
frictionFactor = 0.9f; break;
case Weather.rainy:
frictionFactor = 2.0f; break;
}
}
示例5: getAllWithTags
public List<Weather> getAllWithTags()
{
try
{
List<Weather> weathers = new List<Weather>();
ISession session = cluster.Connect("maltmusic");
String todo = ("select * from weathertags");
PreparedStatement ps = session.Prepare(todo);
BoundStatement bs = ps.Bind();
// Execute Query
RowSet rows = session.Execute(bs);
foreach (Row row in rows)
{
Guid tid = (Guid) row["track_id"];
List<String> theSet = (List<String>)row["tags"];
Weather toadd = new Weather(tid, theSet);
weathers.Add(toadd);
}
return weathers;
}
catch (Exception e)
{
Console.WriteLine("Broken returning weather tags " + e);
return null;
}
}
示例6: WeatherReply
public WeatherReply(WeatherQuery query, Weather weather, DateTime replyTime, Exception exception = null)
{
Query = query;
Weather = weather;
ReplyTime = replyTime;
Exception = exception;
}
示例7: AddDynamicWeather
public static void AddDynamicWeather( int temperature, int chanceOfPercipitation, int chanceOfExtremeTemperature, int moveSpeed, int width, int height, Rectangle2D bounds )
{
for ( int i = 0; i < m_Facets.Length; ++i )
{
Rectangle2D area = new Rectangle2D();
bool isValid = false;
for ( int j = 0; j < 10; ++j )
{
area = new Rectangle2D( bounds.X + Utility.Random( bounds.Width - width ), bounds.Y + Utility.Random( bounds.Height - height ), width, height );
if ( !CheckWeatherConflict( m_Facets[i], null, area ) )
isValid = true;
if ( isValid )
break;
}
if ( !isValid )
continue;
Weather w = new Weather( m_Facets[i], new Rectangle2D[]{ area }, temperature, chanceOfPercipitation, chanceOfExtremeTemperature, TimeSpan.FromSeconds( 30.0 ) );
w.m_Bounds = bounds;
w.m_MoveSpeed = moveSpeed;
}
}
示例8: Parse
public override Weather Parse(string str)
{
try
{
var serializer = new XmlSerializer(typeof(OpenWeatherMapResponse));
OpenWeatherMapResponse owmResponse;
using (var strReader = new StringReader(str))
{
owmResponse = (OpenWeatherMapResponse)serializer.Deserialize(strReader);
}
if (owmResponse.Humidity.unit != "%"
&& owmResponse.Pressure.unit != "hPa"
&& owmResponse.Temperature.unit != "metric")
{
throw new FormatException("Value invalid unit");
}
var weather = new Weather()
{
HumidityPct = owmResponse.Humidity.value / 100,
TemperatureC = owmResponse.Temperature.value,
PressureMB = owmResponse.Pressure.value,
};
return weather;
}
catch (Exception e)
{
throw new ParseException("OpenWeatherMap service response parse error", e);
}
}
示例9: Turn
private readonly PokemonOutward[] pokemons; //onBoardOnly
#endregion Fields
#region Constructors
/// <summary>
/// 为了节约流量,只在用户第一次进入房间的时候给出teams/pms/weather信息
/// </summary>
internal Turn(TeamOutward[] teams, PokemonOutward[] pms, Weather weather)
{
Teams = teams;
pokemons = pms;
Weather = weather;
Events = new List<GameEvent>();
}
示例10: WeatherData
public WeatherData(WeatherData data)
{
mType = data.mType;
mTemp = data.mTemp;
mLength = data.mLength;
mWeight = data.mWeight;
}
示例11: SettingsMenu
public SettingsMenu(Weather weather, ScreenManager screenManager)
{
this.weather = weather;
this.screenManager = screenManager;
btnBack = new Button("Buttons", new Vector2(600, 400), new Rectangle(0, 120 * 6, 250, 120), false, false);
btnChangeWeather = new Button("Buttons", new Vector2(200, 200), new Rectangle(250, 120 * 1, 250, 120), false, false);
btnChangePlayer = new Button("Buttons", new Vector2(200, 400), new Rectangle(250, 120 * 0, 250, 120), false, false);
LoadContent();
}
示例12: WeatherMenu
public WeatherMenu(ScreenManager screenManager, Weather weather)
{
this.screenManager = screenManager;
this.weather = weather;
btnBack = new Button("Buttons", new Vector2(600, 400), new Rectangle(0, 120 * 6, 250, 120), false, false);
btnSunny = new Button("Buttons", new Vector2(200, 100), new Rectangle(250, 120 * 2, 250, 120), false, false);
btnCloudy = new Button("Buttons", new Vector2(500, 100), new Rectangle(250, 120 * 3, 250, 120), false, false);
btnRainy = new Button("Buttons", new Vector2(200, 300), new Rectangle(250, 120 * 4, 250, 120), false, false);
}
示例13: Create
public static RandomEvent Create(int day, Weather weather)
{
if (weather == Weather.Cloudy)
return CloudyEvent();
if (weather == Weather.HotAndDry)
return HotAndDryEvent();
return SunnyEvent(day);
}
示例14: CanGetForecast
public bool CanGetForecast()
{
Weather weather = new Weather();
string xmlData = weather.GetForecast(ZipCode);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xmlData);
XmlNode errorMessageNode = xmlDoc.SelectSingleNode("/errorMessage");
bool hasError = (errorMessageNode != null);
return !hasError;
}
示例15: Board
public Board(GameSettings settings)
{
mode = settings.Mode;
weather = Data.Weather.Normal;
terrain = settings.Terrain;
pokemons = new OnboardPokemon[settings.TeamCount, settings.XBound];
Pokemons = new List<OnboardPokemon>();
BoardConditions = new ConditionsDictionary();
FieldConditions = new ConditionsDictionary[settings.TeamCount];
for (int i = 0; i < settings.TeamCount; i++) FieldConditions[i] = new ConditionsDictionary();
}