Пример #1
0
    public void UpdateCarPos(UIMapCtrl mMapCtrl)
    {
        if (mRoute.trainId == Pathea.IdGenerator.Invalid || this.gameObject == null || mSprCar == null)
        {
            if (mSprCar != null)
            {
                mSprCar.enabled = false;
            }
            return;
        }

        mSprCar.enabled = true;

        Vector3 carAng    = new Vector3();
        Vector3 carUp     = new Vector3();
        Vector3 carPos    = mRoute.GetTrainPosition(out carAng, out carUp);
        Vector3 mRoutePos = new Vector3(carPos.x, carPos.z, 0);
        Vector3 pos       = mRoutePos - mMapCtrl.mMapCamera.gameObject.transform.localPosition;
        int     count     = mMapCtrl.mCameraSizeCount;

        Vector2 v2CarPos = new Vector2(pos.x / count, pos.y / count);

        mSprCar.transform.localPosition = new Vector3(v2CarPos.x, v2CarPos.y, 0);
        if (mRoute.moveDir == -1)
        {
            mSprCar.transform.localEulerAngles = new Vector3(180, 0, Mathf.Atan2(carAng.x, carAng.z) * Mathf.Rad2Deg + 180);
        }
        else
        {
            mSprCar.transform.localEulerAngles = new Vector3(180, 0, Mathf.Atan2(carAng.x, carAng.z) * Mathf.Rad2Deg);
        }
    }
Пример #2
0
    public void ResetLinePos(UIMapCtrl mMapCtrl)
    {
        mStagePosList.Clear();
        for (int i = 0; i < mRoute.pointCount; i++)
        {
            Vector3 mRoutePos = new Vector3(mRoute.GetPointByIndex(i).position.x, mRoute.GetPointByIndex(i).position.z, 0);
            Vector3 pos       = mRoutePos - mMapCtrl.mMapCamera.gameObject.transform.localPosition;
            int     count     = mMapCtrl.mCameraSizeCount;
            mStagePosList.Add(new Vector2(pos.x / count, pos.y / count));
        }

        UpdateLinePos();
    }