• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Weather类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Weather的典型用法代码示例。如果您正苦于以下问题:C# Weather类的具体用法?C# Weather怎么用?C# Weather使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Weather类属于命名空间,在下文中一共展示了Weather类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
            }
        }
开发者ID:adloky,项目名称:weathmon,代码行数:47,代码来源:WundergroundWeatherParser.cs


示例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;
        }
开发者ID:enyim,项目名称:Hackathon,代码行数:49,代码来源:DefaultScorer.cs


示例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);
    }
开发者ID:Miformat,项目名称:GlobalGameJam,代码行数:34,代码来源:MeteoManager.cs


示例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;
            }
        }
开发者ID:catdawg,项目名称:FES2010,代码行数:27,代码来源:Ball.cs


示例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;
            }
        }
开发者ID:andrewdavis1995,项目名称:MALTMusic,代码行数:28,代码来源:WeatherModel.cs


示例6: WeatherReply

 public WeatherReply(WeatherQuery query, Weather weather, DateTime replyTime, Exception exception = null)
 {
     Query = query;
     Weather = weather;
     ReplyTime = replyTime;
     Exception = exception;
 }
开发者ID:adloky,项目名称:weathmon,代码行数:7,代码来源:WeatherReply.cs


示例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;
			}
		}
开发者ID:Godkong,项目名称:Origins,代码行数:27,代码来源:Weather.cs


示例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);
            }
        }
开发者ID:adloky,项目名称:weathmon,代码行数:35,代码来源:OpenWeatherMapWeatherParser.cs


示例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>();
        }
开发者ID:sunoru,项目名称:PBO,代码行数:16,代码来源:Turn.cs


示例10: WeatherData

 public WeatherData(WeatherData data)
 {
     mType = data.mType;
     mTemp = data.mTemp;
     mLength = data.mLength;
     mWeight = data.mWeight;
 }
开发者ID:Robobeurre,项目名称:NRaas,代码行数:7,代码来源:WeatherData.cs


示例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();
 }
开发者ID:markustenghamn,项目名称:EggRoll,代码行数:9,代码来源:SettingsMenu.cs


示例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);
 }
开发者ID:markustenghamn,项目名称:EggRoll,代码行数:9,代码来源:WeatherMenu.cs


示例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);
        }
开发者ID:CHilke1,项目名称:lemonade-stand,代码行数:10,代码来源:RandomEventsFactory.cs


示例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;
 }
开发者ID:xerxesb,项目名称:Cuke4Nuke,代码行数:10,代码来源:ConnectToNoaaWebService.cs


示例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();
 }
开发者ID:sunoru,项目名称:PBO,代码行数:11,代码来源:Board.cs


示例16: endOfTurn

 public static void endOfTurn()
 {
     if (weather != Weather.normal)
     {
         weatherDur--;
         if (weatherDur <= 0)
         {
             weather = Weather.normal;
         }
     }
 }
开发者ID:DanFlannel,项目名称:Pokemon_Battle_Simulator,代码行数:11,代码来源:FBG_BattleEnviornment.cs


示例17: Form1

 public Form1()
 {
     CL = new List<City>();
     var converter = new XmlSerializer(typeof(List<City>));
     var file = File.OpenText(".\\Cityes");
     CL = (List<City>)converter.Deserialize(file);
     file.Close();
     W = new Weather();
     button1 = new Button();
     InitializeComponent();
     Voice = new System.Speech.Synthesis.SpeechSynthesizer();
     this.Voice.SpeakCompleted += new System.EventHandler<System.Speech.Synthesis.SpeakCompletedEventArgs>(Comp);
 }
开发者ID:1extra,项目名称:prog2015,代码行数:13,代码来源:Form1.cs


示例18: SetWeather

    public void SetWeather(Weather w)
    {
        currentWeather = w;
        secondsPassed = 0;

        if (weather)
            Destroy (weather);

        if (w == Weather.Sunny)
            Sunny ();
        else if (w == Weather.Rainy)
            Rainy ();
        else if (w == Weather.Cloudy)
            Cloudy ();
    }
开发者ID:JaydenIvanovic,项目名称:HellaPlants,代码行数:15,代码来源:RandomWeather.cs


示例19: ParseResult

        private string ParseResult(Weather weather)
        {
            if(weather.current_observation != null)
            {
                CurrentObservation o = weather.current_observation;
                DisplayLocation d = o.display_location;

                string result = string.Format("Weather for {0}{1}: {2}, {3}", d.full, (d.zip != null ? " (" + d.zip + ")" : ""), o.weather, o.temperature_string);
                result += string.Format("; feels like {0}. {1} winds. {2} humidity", o.feelslike_string, o.wind_string, o.relative_humidity);
                if(o.precip_today_metric != null)
                {
                    result += string.Format("; {0} precipitation today", o.precip_today_string);
                }
                return string.Format("{0}. {1}\n{2}", result, o.observation_time, o.forecast_url);
            }
            return null;
        }
开发者ID:truongphamx,项目名称:SteamChatBot,代码行数:17,代码来源:WeatherTrigger.cs


示例20: BoardOutward

        internal BoardOutward(GameSettings settings)
        {
            this.settings = settings;
              teams = new ObservableCollection<PokemonOutward>[settings.TeamCount];
              Teams = new ReadOnlyObservableCollection<PokemonOutward>[settings.TeamCount];
              pokemons = new List<PokemonOutward>();
              weather = Data.Weather.Normal;
              Terrain = settings.Terrain;

              var empty = new PokemonOutward[settings.XBound];
              for (int i = 0; i < settings.TeamCount; i++)
              {
            teams[i] = new ObservableCollection<PokemonOutward>(empty);
            Teams[i] = new ReadOnlyObservableCollection<PokemonOutward>(teams[i]);
              }

              listeners = new List<IBoardEvent>();
        }
开发者ID:sunoru,项目名称:PBO,代码行数:18,代码来源:BoardOutward.cs



注:本文中的Weather类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Web类代码示例发布时间:2022-05-24
下一篇:
C# WearableType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap