Projekt

Obecné

Profil

Stáhnout (1.53 KB) Statistiky
| Větev: | Tag: | Revize:
1
using System.Collections;
2
using System.Collections.Generic;
3
using UnityEngine;
4
using System.Xml.Serialization;
5
using System;
6
using ServerApp.Parser.OutputInfo;
7

    
8
[XmlRoot("Request")]
9
public class Request
10
{
11
    [XmlElement]
12
    public bool useWeather;
13

    
14

    
15
    [XmlElement]
16
    public double temperature;
17
    
18
    [XmlElement]
19
    public double wind;
20
    
21
    [XmlElement]
22
    public double rain;
23

    
24
    [XmlElement]
25
    public WeatherConditions weather;
26

    
27

    
28
    [XmlElement]
29
    public bool useEndDate;
30

    
31

    
32
    [XmlElement]
33
    public Date start;
34

    
35
    [XmlElement]
36
    public Date end;
37

    
38

    
39
    public static Request Randomize()
40
    {
41
        Request r = new Request();
42

    
43
        r.useWeather = (UnityEngine.Random.Range(0f, 1f) < 0.5f) ? true : false;
44

    
45
        if (r.useWeather)
46
        {
47
            r.temperature = UnityEngine.Random.Range(0f, 40f);
48
            r.wind = UnityEngine.Random.Range(0f, 100f);
49
            r.rain = UnityEngine.Random.Range(0f, 100f);
50
            r.weather = (WeatherConditions)UnityEngine.Random.Range(0, 3);
51
        }
52

    
53
        r.start = Date.Randomize();
54

    
55
        r.useEndDate = (UnityEngine.Random.Range(0f, 1f) < 0.5f) ? true : false;
56

    
57
        if (r.useEndDate)
58
        {
59
            r.end = Date.Randomize();
60
            if (r.start.CompareTo(r.end) < 0)
61
            {
62
                Date tmp = r.start;
63
                r.start = r.end;
64
                r.end = tmp;
65
            }
66
            else if (r.start.CompareTo(r.end) == 0) 
67
            { 
68
                r.useEndDate = false;
69
            }
70
        }
71

    
72
        return r;
73
    }
74

    
75
}
(11-11/16)