-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExperimentView.cs
More file actions
93 lines (81 loc) · 2.83 KB
/
ExperimentView.cs
File metadata and controls
93 lines (81 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
using System;
internal class ExperimentView : IEquatable<ExperimentView>, IComparable<ExperimentView>
{
private readonly float _earnedScience;
private readonly string _fullExperimentId;
private readonly float _fullScience;
private readonly float _nextExperimentScience;
private readonly bool _onShip;
// public ExperimentView(string fullExperimentId, bool onShip, float earnedScience, float fullScience)
// {
// _fullExperimentId = fullExperimentId;
// _onShip = onShip;
// _earnedScience = earnedScience;
// _fullScience = fullScience;
// }
public ExperimentView(ScienceSubject scienceSubject, bool onShip = false)
{
_fullExperimentId = scienceSubject.id;
_onShip = onShip;
_earnedScience = scienceSubject.science;
_fullScience = scienceSubject.scienceCap;
ScienceExperiment scienceExperiment = ResearchAndDevelopment.GetExperiment(scienceSubject.id.Split('@')[0]);
_nextExperimentScience = ResearchAndDevelopment.GetScienceValue(scienceExperiment.baseValue*scienceExperiment.dataScale, scienceSubject);
}
public ExperimentView(ScienceData scienceData, bool onShip = true)
{
ScienceSubject scienceSubject = ResearchAndDevelopment.GetSubjectByID(scienceData.subjectID);
_fullExperimentId = scienceData.subjectID;
_onShip = onShip;
_earnedScience = ResearchAndDevelopment.GetScienceValue(scienceData.dataAmount, scienceSubject);
_fullScience = 0;
_nextExperimentScience = 0;
}
public string FullExperimentId
{
get { return _fullExperimentId; }
}
public bool OnShip
{
get { return _onShip; }
}
public float EarnedScience
{
get { return _earnedScience; }
}
public float FullScience
{
get { return _fullScience; }
}
public float NextExperimentScience
{
get { return _nextExperimentScience; }
}
public int CompareTo(ExperimentView other)
{
string[] splitx = _fullExperimentId.Split('@');
string[] splity = other._fullExperimentId.Split('@');
if (splitx[0] == splity[0])
{
if (_onShip && !other._onShip)
return 1;
if (other._onShip && !_onShip)
return -1;
return 0;
}
return splitx[0].CompareTo(splity[0]);
}
public bool Equals(ExperimentView other)
{
if (other == null) return false;
if (_onShip != other._onShip) return false;
if (other._fullExperimentId == _fullExperimentId)
{
if (!_onShip == !other._onShip)
{
return true;
}
}
return false;
}
}