本文整理汇总了C#中Station.getIndex方法的典型用法代码示例。如果您正苦于以下问题:C# Station.getIndex方法的具体用法?C# Station.getIndex怎么用?C# Station.getIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Station
的用法示例。
在下文中一共展示了Station.getIndex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getNextOnRoute
public Station getNextOnRoute(Station stationFinal)
{
if(this.getIndex() - stationFinal.getIndex() < 0){
return get (this.getIndex()+1);
}
else if(this.getIndex() - stationFinal.getIndex() > 0){
return get (this.getIndex()-1);
}
return null;
}
示例2: getApproxTravelTime
public int getApproxTravelTime(Station station)
{
float time=0;
bool needToWalk = getLineTypeTo(station) == Line.Type.None;
if (needToWalk)
{
float distance = Vector3.Distance(station.transform.position, this.transform.position);
time += distance * walkCostFactor;
}
else
{
int numStations = Mathf.Abs(station.getIndex() - this.station.getIndex());
time += station.getEnterCost(true);
time += numStations * line().getTravelCostFactor();
time += station.getExitCost();
}
return (int)time;
}
示例3: setStation
public void setStation(Station station)
{
float bestCaseTimeBeforeTravel = bestCaseTime;
clearGUITexts();
bool needToWalk = (line() == null || station.getLine() != line());
float timeToStation = 0.0f;
if (needToWalk)
{
float distance = Vector3.Distance(station.transform.position, this.transform.position);
timeToStation += distance * walkCostFactor;;
bestCaseTime += distance * walkCostFactorHealthyPerson;
}
else
{
int numStations = Mathf.Abs(station.getIndex() - this.station.getIndex());
timeToStation += station.getEnterCost(false);
timeToStation += numStations * line().getTravelCostFactor();
timeToStation += station.getExitCost();
//TODO: don't use "risks" of wheelchair driver
bestCaseTime += timeToStation;
}
travelTime += (int)timeToStation;
GameObject.Find("timeText").GetComponent<TimeOfDay>().addTime((int)timeToStation);
if(needToWalk)
stationNext = station;
else
stationNext = this.station.getNextOnRoute(station);
this.station = station;
newPos = stationNext.transform.position;
int extratime = evaluateRisk(needToWalk);
lastRiskTime = extratime;
travelTime+=extratime;
GameObject.Find("timeText").GetComponent<TimeOfDay>().addTime(extratime);
//Vector3 position = station.transform.position;
//position.z = this.transform.position.z;
//this.transform.position = position;
//is this station a target?
if(station.isTargetStation()){
SpriteRenderer sprite = station.GetComponent<SpriteRenderer>();
//target marked as visited
sprite.color = GameObject.Find("background").renderer.material.color;
station.enabled = false;
targetsVisited++;
if(targetsVisited == targetCount){
//GAME OVER! ALL TARGETS VISITED!
/*Vector3 pos = new Vector3(Screen.width,this.transform.position.y,this.transform.position.z);
GameObject txtGO = Instantiate(infoBox, pos, new Quaternion()) as GameObject;
TextMesh txt = txtGO.GetComponent<TextMesh>();
txt.fontSize=5;
txt.text = "If you had been a healthy person \nthe journey would have taken you "+(int)bestCaseTime+" minutes";*/
gameOver = true;
}
}
float bestCaseTimeDiff = bestCaseTime - bestCaseTimeBeforeTravel;
int moveTimeExtra = Mathf.RoundToInt(timeToStation - bestCaseTimeDiff);
int timeDiffToBestCase = moveTimeExtra + extratime;
if (timeDiffToBestCase > 0)
{
string extraTimeLabel = "";
if (moveTimeExtra > 0)
extraTimeLabel += "+" + moveTimeExtra;
if (extratime > 0)
extraTimeLabel += " +" + extratime;
GameObject.Find("timeDiffText").guiText.text = extraTimeLabel;
}
else
{
GameObject.Find("timeDiffText").guiText.text = "";
}
//GameObject.Find("timeDiffText").guiText.text += " (" + (travelTime - (int)bestCaseTime) + ")";
}