示例#1
0
    private void Update()
    {
        if (PauseMenuManager.isGamePaused)
        {
            return;
        }

        if (isDead || CurrentRoad == null)
        {
            FadeOut();
            return;
        }

        float step = speed * Time.deltaTime;

        transform.position = Vector3.MoveTowards(transform.position, CurrentRoad.Node.position, step);
        Quaternion rotateTo = (PreviousRoad == null) ? CurrentRoad.Node.rotation : PreviousRoad.Node.rotation;

        transform.rotation = Quaternion.RotateTowards(transform.rotation, rotateTo, 512.0f * Time.deltaTime);
        if (Vector3.Distance(transform.position, CurrentRoad.Node.position) < 0.001f)
        {
            Road tempRoad = CurrentRoad;
            if (CurrentRoad.Type == RoadType.Straight)
            {
                StraightRoad straightRoad = (StraightRoad)CurrentRoad;
                CurrentRoad = (PreviousRoad == straightRoad.RoadA) ? straightRoad.RoadB : straightRoad.RoadA;
            }
            else if (CurrentRoad.Type == RoadType.Curved)
            {
                CurvedRoad curvedRoad = (CurvedRoad)CurrentRoad;
                if (PreviousRoad == curvedRoad.RoadB1 || PreviousRoad == curvedRoad.RoadB2)
                {
                    CurrentRoad = curvedRoad.RoadA;
                }
                else if (curvedRoad.IsToggable)
                {
                    CurrentRoad = (curvedRoad.ToggleRotate) ? curvedRoad.RoadB1 : curvedRoad.RoadB2;
                }
                else
                {
                    CurrentRoad = (PreviousRoad == curvedRoad.RoadA) ? ((curvedRoad.RoadB1 != null) ? curvedRoad.RoadB1 : curvedRoad.RoadB2) : curvedRoad.RoadA;
                }
            }
            else if (CurrentRoad.Type == RoadType.Merge)
            {
                MergeRoad mergeRoad = (MergeRoad)CurrentRoad;
                CurrentRoad = (PreviousRoad == mergeRoad.RoadA1 || PreviousRoad == mergeRoad.RoadA2) ? mergeRoad.RoadB : mergeRoad.RoadA1;
            }
            else if (CurrentRoad.Type == RoadType.Slip)
            {
                SlipRoad slipRoad = (SlipRoad)CurrentRoad;
                CurrentRoad = (slipRoad.ToggleRotate) ? slipRoad.RoadB1 : slipRoad.RoadB2;
            }
            PreviousRoad = tempRoad;
        }
        else
        {
            FadeIn();
        }
    }
示例#2
0
    public static Road CreateCurvedRightDown(int x, int y)
    {
        CurvedRoad r = (CurvedRoad)CreateCurved(x, y, 0);

        r.right = true;
        r.down  = true;
        return(r);
    }
示例#3
0
    public static Road CreateCurvedRightUp(int x, int y)
    {
        CurvedRoad r = (CurvedRoad)CreateCurved(x, y, 90);

        r.right = true;
        r.up    = true;
        return(r);
    }
示例#4
0
    public static Road CreateCurvedLeftDown(int x, int y)
    {
        CurvedRoad r = (CurvedRoad)CreateCurved(x, y, 270);

        r.left = true;
        r.down = true;
        return(r);
    }
示例#5
0
    public static Road CreateCurvedLeftUp(int x, int y)
    {
        CurvedRoad r = (CurvedRoad)CreateCurved(x, y, 180);

        r.left = true;
        r.up   = true;
        return(r);
    }
示例#6
0
    /**
     * Default is down-right
     * */
    public static Road CreateCurved(int x, int y, float zRotation)
    {
        InitializePrefabs();
        GameObject road = (GameObject)SpoofInstantiate(curvedPrefab);

        road.transform.position = new Vector3(x, y, 0);
        road.transform.Rotate(0, 0, zRotation);
        CurvedRoad r = road.GetComponent <CurvedRoad>();

        r.xPos           = x;
        r.yPos           = y;
        r.neighbourRoads = new List <Road>();
        return(r);
    }
    void Start()
    {
        SR = this.GetComponent <StraightRoad>();
        CR = this.GetComponent <CurvedRoad>();
        currentPlacement = SR;
        map = new int[gridSizeX, gridSizeY];

        for (int i = 0; i < map.GetLength(0); i++)
        {
            for (int j = 0; j < map.GetLength(1); j++)
            {
                map[i, j] = (int)cellVal.EMPTY;
            }
        }
        selectCell();
    }
示例#8
0
 //not quite fully functional
 private static void PlaceCarOnCurvedRoad(Car c, CurvedRoad r)
 {
     FaceCarInDirection(c, new Vector2(0.5f, 0.5f));
     RotateCarByAngle(c, r.transform.rotation.eulerAngles.z);
 }