当前位置: 首页>>代码示例>>C#>>正文


C# Station.getEnterCost方法代码示例

本文整理汇总了C#中Station.getEnterCost方法的典型用法代码示例。如果您正苦于以下问题:C# Station.getEnterCost方法的具体用法?C# Station.getEnterCost怎么用?C# Station.getEnterCost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Station的用法示例。


在下文中一共展示了Station.getEnterCost方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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;
    }
开发者ID:v01pe,项目名称:ExplorativeDesign,代码行数:21,代码来源:Player.cs

示例2: 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) + ")";
    }
开发者ID:v01pe,项目名称:ExplorativeDesign,代码行数:86,代码来源:Player.cs


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