private void Line_RoadToCross(ref Line_FormRoad lfroad, ref Line_FormCross res)
	{
		res.dir = lfroad.dir;
		res.enterCoord = lfroad.genCoord;

		float crossLength = .0f;
		float fullLength = .0f;
		if (lfroad.dir == SourceDir.North || lfroad.dir == SourceDir.South)
		{
			crossLength = Configs.LENGTH_NS_CROSS;
			fullLength = Configs.LENGTH_NS_FULL;
		}
		else
		{
			crossLength = Configs.LENGTH_WE_CROSS;
			fullLength = Configs.LENGTH_WE_FULL;
		}
		float armLength = (fullLength - crossLength) / 2;

		res.enterTime = lfroad.genTime + armLength / lfroad.genSpeed;
		res.timeLength = lfroad.genLength / lfroad.genSpeed;
		res.timeOffset = crossLength / lfroad.genSpeed;

		return;
	}
Exemple #2
0
    private Line GetRandomLine(float nowTime, int genCount)
    {
        SourceDir genDir = (SourceDir)(Random.Range(.0f, .999f) * 4);

        float timeRange = Configs.GEN_TIME_RANGE + Configs.GEN_TIME_EXTEND * (genCount / Configs.GEN_RETRY_TIMES);
        float genTime   = nowTime + Random.value * timeRange;

        float genCoord = Random.value * Utils.GetDirCrossWidth(genDir);

        float genLength = Random.value * (Configs.GEN_MAX_LENGTH - Configs.GEN_MIN_LENGTH) + Configs.GEN_MIN_LENGTH;

        float genSpeed = Random.value * (Configs.GEN_MAX_SPEED - Configs.GEN_MIN_SPEED) + Configs.GEN_MIN_SPEED;

        Line_FormRoad lfr = new Line_FormRoad();

        lfr.dir       = genDir;
        lfr.genTime   = genTime;
        lfr.genCoord  = genCoord;
        lfr.genLength = genLength;
        lfr.genSpeed  = genSpeed;

        Line res = new Line(lfr);

        return(res);
    }
	public Line(Line_FormRoad lfr)
	{
		_lfr = lfr;
		_lfc = new Line_FormCross();
		Line_RoadToCross(ref _lfr, ref _lfc);
	}
	public Line(Line_FormCross lfc)
	{
		_lfc = lfc;
		_lfr = new Line_FormRoad();
		Line_CrossToRoad(ref _lfc, ref _lfr);
	}