Exemple #1
0
    private Vector3 CreateRoadCornerCar(Vector3 startPos, EnmAxis axis)
    {
        Vector3 newPos = new Vector3(startPos.x, startPos.y, startPos.z);

        switch (axis)
        {
        case EnmAxis.x:
            newPos.x += 12.5f;
            break;

        case EnmAxis.rX:
            newPos.x -= 12.5f;
            break;

        case EnmAxis.z:
            newPos.z += 12.5f;
            break;

        case EnmAxis.rZ:
            newPos.z -= 12.5f;
            break;
        }

        GameObject roadCorner = Instantiate(arabaKose);

        roadCorner.transform.position = newPos;
        roadCorner.transform.parent   = goRoads.transform;

        if (lastParkArea != null)
        {
            lastParkArea.GetComponent <ParkArea>().blockL = new GameObject[3];
            lastParkArea.GetComponent <ParkArea>().blockR = new GameObject[3];

            lastParkArea.GetComponent <ParkArea>().blockL[0] = roadCorner.gameObject.transform.Find("blockLeft1").gameObject;
            lastParkArea.GetComponent <ParkArea>().blockL[1] = roadCorner.gameObject.transform.Find("blockLeft2").gameObject;
            lastParkArea.GetComponent <ParkArea>().blockL[2] = roadCorner.gameObject.transform.Find("blockLeft3").gameObject;

            lastParkArea.GetComponent <ParkArea>().blockR[0] = roadCorner.gameObject.transform.Find("blockRight1").gameObject;
            lastParkArea.GetComponent <ParkArea>().blockR[1] = roadCorner.gameObject.transform.Find("blockRight2").gameObject;
            lastParkArea.GetComponent <ParkArea>().blockR[2] = roadCorner.gameObject.transform.Find("blockRight3").gameObject;

            lastParkArea = null;
        }

        return(newPos);
    }
Exemple #2
0
    private Vector3 CreateRoadCornerTrain(Vector3 startPos, EnmAxis axis)
    {
        Vector3 newPos = new Vector3(startPos.x, startPos.y, startPos.z);

        switch (axis)
        {
        case EnmAxis.x:
            newPos.x += 10;
            break;

        case EnmAxis.rX:
            newPos.x -= 10;
            break;

        case EnmAxis.z:
            newPos.z += 10;
            break;

        case EnmAxis.rZ:
            newPos.z -= 10;
            break;
        }

        GameObject roadCorner = Instantiate(trenKose);

        roadCorner.transform.position = newPos;
        if (axis == EnmAxis.rX)
        {
            roadCorner.transform.rotation = Quaternion.Euler(0f, -90f, 0f);
        }
        else if (axis == EnmAxis.x)
        {
            roadCorner.transform.rotation = Quaternion.Euler(0f, 90f, 0f);
        }
        else if (axis == EnmAxis.rZ)
        {
            roadCorner.transform.rotation = Quaternion.Euler(0f, 180f, 0f);
        }
        roadCorner.transform.parent = goRoads.transform;

        return(newPos);
    }
Exemple #3
0
    private Vector3 CreateRail(int len, Vector3 startPos, EnmAxis axis)
    {
        Vector3 newPos = new Vector3(startPos.x, startPos.y, startPos.z);

        for (int i = 0; i < len; i++)
        {
            switch (axis)
            {
            case EnmAxis.x:
                newPos.x += 10;
                break;

            case EnmAxis.rX:
                newPos.x -= 10;
                break;

            case EnmAxis.z:
                newPos.z += 10;
                break;

            case EnmAxis.rZ:
                newPos.z -= 10;
                break;
            }

            GameObject road = Instantiate(ray);
            road.transform.position = newPos;
            if (axis == EnmAxis.z || axis == EnmAxis.rZ)
            {
                road.transform.rotation = Quaternion.Euler(0f, 90f, 0f);
            }
            road.transform.parent = goRoads.transform;
        }

        return(newPos);
    }
Exemple #4
0
    private void CreateSea(int len, Vector3 startPos, EnmAxis axis, int leftRight)
    {
        Vector3 newPos = new Vector3(startPos.x, startPos.y, startPos.z);

        switch (axis)
        {
        case EnmAxis.x:
            if (leftRight == 0)
            {
                newPos.z += 60;
            }
            else if (leftRight == 1)
            {
                newPos.z -= 60;
            }
            break;

        case EnmAxis.rX:
            if (leftRight == 0)
            {
                newPos.z -= 60;
            }
            else if (leftRight == 1)
            {
                newPos.z += 60;
            }
            break;

        case EnmAxis.z:
            if (leftRight == 0)
            {
                newPos.x -= 60;
            }
            else if (leftRight == 1)
            {
                newPos.x += 60;
            }
            break;

        case EnmAxis.rZ:
            if (leftRight == 0)
            {
                newPos.x += 60;
            }
            else if (leftRight == 1)
            {
                newPos.x -= 60;
            }
            break;
        }
        for (int i = 0; i < len + 4; i++)
        {
            switch (axis)
            {
            case EnmAxis.x:
                newPos.x += 5;
                break;

            case EnmAxis.rX:
                newPos.x -= 5;
                break;

            case EnmAxis.z:
                newPos.z += 5;
                break;

            case EnmAxis.rZ:
                newPos.z -= 5;
                break;
            }

            GameObject road = Instantiate(deniz);
            road.transform.position = newPos;
            if (axis == EnmAxis.x || axis == EnmAxis.rX)
            {
                road.transform.rotation = Quaternion.Euler(0f, 90f, 0f);
            }
            road.transform.parent = goDesigns.transform;
        }
    }
Exemple #5
0
    void Start()
    {
        if (playerAracTip == EnmPlayerAracTip.Klasik)
        {
            player = Instantiate(playerKlasik);
        }
        else if (playerAracTip == EnmPlayerAracTip.Siyah)
        {
            player = Instantiate(playerSiyah);
        }
        else if (playerAracTip == EnmPlayerAracTip.Beyaz)
        {
            player = Instantiate(playerBeyaz);
        }

        if (korumaAracTip == EnmKorumaAracTip.Ambulans)
        {
            korumaArac = Instantiate(ambulans);
        }
        else if (korumaAracTip == EnmKorumaAracTip.Itfaiye)
        {
            korumaArac = Instantiate(itfaiye);
        }
        else if (korumaAracTip == EnmKorumaAracTip.Swat)
        {
            korumaArac = Instantiate(swat);
        }

        player.transform.position     = new Vector3(player.transform.position.x, player.transform.position.y, 20f);
        korumaArac.transform.position = new Vector3(korumaArac.transform.position.x, korumaArac.transform.position.y, 15f);

        goRoads      = new GameObject();
        goRoads.name = "Roads";
        goRoads.transform.position = new Vector3(0f, 0f, 0f);

        goDesigns      = new GameObject();
        goDesigns.name = "Designs";
        goDesigns.transform.position = new Vector3(0f, 0f, 0f);

        goParkAreas      = new GameObject();
        goParkAreas.name = "ParkAreas";
        goParkAreas.transform.position = new Vector3(0f, 0f, 0f);

        goOtoPoses      = new GameObject();
        goOtoPoses.name = "OtoPositions";
        goOtoPoses.transform.position = new Vector3(0f, 0f, 0f);

        #region Yol1
        if (yol1SolDizayn == EnmYolDizayn.Ev || yol1SolDizayn == EnmYolDizayn.Cimen || yol1SolDizayn == EnmYolDizayn.Apartman)
        {
            if (yol1SolDizayn == EnmYolDizayn.Ev)
            {
                CreateHouse(yol1Uzunluk, lastPosRoad, lastAxis, 0);
            }
            else if (yol1SolDizayn == EnmYolDizayn.Apartman)
            {
                CreateApart(yol1Uzunluk, lastPosRoad, lastAxis, 0);
            }
            CreateGrass(yol1Uzunluk, lastPosRoad, lastAxis, 0);
        }
        else if (yol1SolDizayn == EnmYolDizayn.Deniz)
        {
            CreateSea(yol1Uzunluk, lastPosRoad, lastAxis, 0);
        }
        if (yol1SagDizayn == EnmYolDizayn.Ev || yol1SagDizayn == EnmYolDizayn.Cimen || yol1SagDizayn == EnmYolDizayn.Apartman)
        {
            if (yol1SagDizayn == EnmYolDizayn.Ev)
            {
                CreateHouse(yol1Uzunluk, lastPosRoad, lastAxis, 1);
            }
            else if (yol1SagDizayn == EnmYolDizayn.Apartman)
            {
                CreateApart(yol1Uzunluk, lastPosRoad, lastAxis, 1);
            }
            CreateGrass(yol1Uzunluk, lastPosRoad, lastAxis, 1);
        }
        else if (yol1SagDizayn == EnmYolDizayn.Deniz)
        {
            CreateSea(yol1Uzunluk, lastPosRoad, lastAxis, 1);
        }
        lastPosRoad = CreateRoad(yol1Uzunluk, lastPosRoad, lastAxis, true);
        if (yol1YolAyrım == EnmYolAyrım.Duz)
        {
            if (yol1OtoAracTip == EnmOtonomAracTip.Araba)
            {
                lastPosRoad = CreateRoadCornerCar(lastPosRoad, EnmAxis.z);
                CreateRoad(25, new Vector3(lastPosRoad.x + 7.5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.x, otoCarRoad: true);
                CreateRoad(25, new Vector3(lastPosRoad.x - 7.5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.rX, otoCarRoad: true);
            }
            else if (yol1OtoAracTip == EnmOtonomAracTip.Tren)
            {
                lastPosRoad = CreateRoadCornerTrain(lastPosRoad, EnmAxis.z);
                CreateRail(10, new Vector3(lastPosRoad.x + 5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.x);
                CreateRail(10, new Vector3(lastPosRoad.x - 5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.rX);
            }

            lastPosRoad.z += 7.5f;
        }
        else if (yol1YolAyrım == EnmYolAyrım.SagDonme)
        {
            if (yol1OtoAracTip == EnmOtonomAracTip.Araba)
            {
                lastPosRoad = CreateRoadCornerCar(lastPosRoad, EnmAxis.z);
                CreateRoad(25, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z + 7.5f), EnmAxis.z, otoCarRoad: true);
                CreateRoad(25, new Vector3(lastPosRoad.x - 7.5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.rX, otoCarRoad: true);
            }

            lastPosRoad.x += 7.5f;
            lastAxis       = EnmAxis.x;
        }
        else if (yol1YolAyrım == EnmYolAyrım.SolDonme)
        {
            if (yol1OtoAracTip == EnmOtonomAracTip.Araba)
            {
                lastPosRoad = CreateRoadCornerCar(lastPosRoad, EnmAxis.z);
                CreateRoad(25, new Vector3(lastPosRoad.x + 7.5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.x, otoCarRoad: true);
                CreateRoad(25, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z + 7.5f), EnmAxis.z, otoCarRoad: true);
            }

            lastPosRoad.x -= 7.5f;
            lastAxis       = EnmAxis.rX;
        }
        #endregion

        #region Yol2
        if (yol2SolDizayn == EnmYolDizayn.Ev || yol2SolDizayn == EnmYolDizayn.Cimen || yol2SolDizayn == EnmYolDizayn.Apartman)
        {
            if (yol2SolDizayn == EnmYolDizayn.Ev)
            {
                CreateHouse(yol2Uzunluk, lastPosRoad, lastAxis, 0);
            }
            else if (yol2SolDizayn == EnmYolDizayn.Apartman)
            {
                CreateApart(yol2Uzunluk, lastPosRoad, lastAxis, 0);
            }
            CreateGrass(yol2Uzunluk, lastPosRoad, lastAxis, 0);
        }
        else if (yol2SolDizayn == EnmYolDizayn.Deniz)
        {
            CreateSea(yol2Uzunluk, lastPosRoad, lastAxis, 0);
        }
        if (yol2SagDizayn == EnmYolDizayn.Ev || yol2SagDizayn == EnmYolDizayn.Cimen || yol2SagDizayn == EnmYolDizayn.Apartman)
        {
            if (yol2SagDizayn == EnmYolDizayn.Ev)
            {
                CreateHouse(yol2Uzunluk, lastPosRoad, lastAxis, 1);
            }
            else if (yol2SagDizayn == EnmYolDizayn.Apartman)
            {
                CreateApart(yol2Uzunluk, lastPosRoad, lastAxis, 1);
            }
            CreateGrass(yol2Uzunluk, lastPosRoad, lastAxis, 1);
        }
        else if (yol2SolDizayn == EnmYolDizayn.Deniz)
        {
            CreateSea(yol2Uzunluk, lastPosRoad, lastAxis, 1);
        }
        lastPosRoad = CreateRoad(yol2Uzunluk, lastPosRoad, lastAxis, true);
        if (yol2YolAyrım == EnmYolAyrım.Duz)
        {
            if (yol2OtoAracTip == EnmOtonomAracTip.Araba)
            {
                lastPosRoad = CreateRoadCornerCar(lastPosRoad, lastAxis);
                if (lastAxis == EnmAxis.z)
                {
                    CreateRoad(25, new Vector3(lastPosRoad.x + 7.5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.x, otoCarRoad: true);
                    CreateRoad(25, new Vector3(lastPosRoad.x - 7.5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.rX, otoCarRoad: true);
                }
                else if (lastAxis == EnmAxis.rZ)
                {
                    CreateRoad(25, new Vector3(lastPosRoad.x + 7.5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.x, otoCarRoad: true);
                    CreateRoad(25, new Vector3(lastPosRoad.x - 7.5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.rX, otoCarRoad: true);
                }
                else if (lastAxis == EnmAxis.x)
                {
                    CreateRoad(25, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z + 7.5f), EnmAxis.z, otoCarRoad: true);
                    CreateRoad(25, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z - 7.5f), EnmAxis.rZ, otoCarRoad: true);
                }
                else if (lastAxis == EnmAxis.rX)
                {
                    CreateRoad(25, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z + 7.5f), EnmAxis.z, otoCarRoad: true);
                    CreateRoad(25, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z - 7.5f), EnmAxis.rZ, otoCarRoad: true);
                }
            }
            else if (yol2OtoAracTip == EnmOtonomAracTip.Tren)
            {
                lastPosRoad = CreateRoadCornerTrain(lastPosRoad, lastAxis);
                if (lastAxis == EnmAxis.z)
                {
                    CreateRail(10, new Vector3(lastPosRoad.x + 5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.x);
                    CreateRail(10, new Vector3(lastPosRoad.x - 5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.rX);
                }
                else if (lastAxis == EnmAxis.rZ)
                {
                    CreateRail(10, new Vector3(lastPosRoad.x + 5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.x);
                    CreateRail(10, new Vector3(lastPosRoad.x - 5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.rX);
                }
                else if (lastAxis == EnmAxis.x)
                {
                    CreateRail(10, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z + 5f), EnmAxis.z);
                    CreateRail(10, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z - 5f), EnmAxis.rZ);
                }
                else if (lastAxis == EnmAxis.rX)
                {
                    CreateRail(10, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z + 5f), EnmAxis.z);
                    CreateRail(10, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z - 5f), EnmAxis.rZ);
                }
            }

            switch (lastAxis)
            {
            case EnmAxis.x:
                lastPosRoad.x += 7.5f;
                break;

            case EnmAxis.rX:
                lastPosRoad.x -= 7.5f;
                break;

            case EnmAxis.z:
                lastPosRoad.z += 7.5f;
                break;

            case EnmAxis.rZ:
                lastPosRoad.z -= 7.5f;
                break;
            }
        }
        else if (yol2YolAyrım == EnmYolAyrım.SagDonme)
        {
            if (yol2OtoAracTip == EnmOtonomAracTip.Araba)
            {
                lastPosRoad = CreateRoadCornerCar(lastPosRoad, lastAxis);
                if (lastAxis == EnmAxis.z)
                {
                    CreateRoad(25, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z + 7.5f), EnmAxis.z, otoCarRoad: true);
                    CreateRoad(25, new Vector3(lastPosRoad.x - 7.5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.rX, otoCarRoad: true);
                }
                else if (lastAxis == EnmAxis.rZ)
                {
                    CreateRoad(25, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z - 7.5f), EnmAxis.rZ, otoCarRoad: true);
                    CreateRoad(25, new Vector3(lastPosRoad.x + 7.5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.x, otoCarRoad: true);
                }
                else if (lastAxis == EnmAxis.x)
                {
                    CreateRoad(25, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z + 7.5f), EnmAxis.z, otoCarRoad: true);
                    CreateRoad(25, new Vector3(lastPosRoad.x + 7.5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.x, otoCarRoad: true);
                }
                else if (lastAxis == EnmAxis.rX)
                {
                    CreateRoad(25, new Vector3(lastPosRoad.x - 7.5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.rX, otoCarRoad: true);
                    CreateRoad(25, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z - 7.5f), EnmAxis.rZ, otoCarRoad: true);
                }
            }

            switch (lastAxis)
            {
            case EnmAxis.x:
                lastPosRoad.z -= 7.5f;
                lastAxis       = EnmAxis.rZ;
                break;

            case EnmAxis.rX:
                lastPosRoad.z += 7.5f;
                lastAxis       = EnmAxis.z;
                break;

            case EnmAxis.z:
                lastPosRoad.x += 7.5f;
                lastAxis       = EnmAxis.x;
                break;

            case EnmAxis.rZ:
                lastPosRoad.x -= 7.5f;
                lastAxis       = EnmAxis.rX;
                break;
            }
        }
        else if (yol2YolAyrım == EnmYolAyrım.SolDonme)
        {
            if (yol2OtoAracTip == EnmOtonomAracTip.Araba)
            {
                lastPosRoad = CreateRoadCornerCar(lastPosRoad, lastAxis);
                if (lastAxis == EnmAxis.z)
                {
                    CreateRoad(25, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z + 7.5f), EnmAxis.z, otoCarRoad: true);
                    CreateRoad(25, new Vector3(lastPosRoad.x + 7.5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.x, otoCarRoad: true);
                }
                else if (lastAxis == EnmAxis.rZ)
                {
                    CreateRoad(25, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z - 7.5f), EnmAxis.rZ, otoCarRoad: true);
                    CreateRoad(25, new Vector3(lastPosRoad.x - 7.5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.rX, otoCarRoad: true);
                }
                else if (lastAxis == EnmAxis.x)
                {
                    CreateRoad(25, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z - 7.5f), EnmAxis.rZ, otoCarRoad: true);
                    CreateRoad(25, new Vector3(lastPosRoad.x + 7.5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.x, otoCarRoad: true);
                }
                else if (lastAxis == EnmAxis.rX)
                {
                    CreateRoad(25, new Vector3(lastPosRoad.x - 7.5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.rX, otoCarRoad: true);
                    CreateRoad(25, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z + 7.5f), EnmAxis.z, otoCarRoad: true);
                }
            }

            switch (lastAxis)
            {
            case EnmAxis.x:
                lastPosRoad.z += 7.5f;
                lastAxis       = EnmAxis.z;
                break;

            case EnmAxis.rX:
                lastPosRoad.z -= 7.5f;
                lastAxis       = EnmAxis.rZ;
                break;

            case EnmAxis.z:
                lastPosRoad.x -= 7.5f;
                lastAxis       = EnmAxis.rX;
                break;

            case EnmAxis.rZ:
                lastPosRoad.x += 7.5f;
                lastAxis       = EnmAxis.x;
                break;
            }
        }
        #endregion

        #region Yol3
        if (yol3SolDizayn == EnmYolDizayn.Ev || yol3SolDizayn == EnmYolDizayn.Cimen || yol3SolDizayn == EnmYolDizayn.Apartman)
        {
            if (yol3SolDizayn == EnmYolDizayn.Ev)
            {
                CreateHouse(yol3Uzunluk, lastPosRoad, lastAxis, 0);
            }
            else if (yol3SolDizayn == EnmYolDizayn.Apartman)
            {
                CreateApart(yol3Uzunluk, lastPosRoad, lastAxis, 0);
            }
            CreateGrass(yol3Uzunluk, lastPosRoad, lastAxis, 0);
        }
        else if (yol3SolDizayn == EnmYolDizayn.Deniz)
        {
            CreateSea(yol3Uzunluk, lastPosRoad, lastAxis, 0);
        }
        if (yol3SagDizayn == EnmYolDizayn.Ev || yol3SagDizayn == EnmYolDizayn.Cimen || yol3SagDizayn == EnmYolDizayn.Apartman)
        {
            if (yol3SagDizayn == EnmYolDizayn.Ev)
            {
                CreateHouse(yol3Uzunluk, lastPosRoad, lastAxis, 1);
            }
            else if (yol3SagDizayn == EnmYolDizayn.Apartman)
            {
                CreateApart(yol3Uzunluk, lastPosRoad, lastAxis, 1);
            }
            CreateGrass(yol3Uzunluk, lastPosRoad, lastAxis, 1);
        }
        else if (yol3SolDizayn == EnmYolDizayn.Deniz)
        {
            CreateSea(yol3Uzunluk, lastPosRoad, lastAxis, 1);
        }
        lastPosRoad = CreateRoad(yol3Uzunluk, lastPosRoad, lastAxis, true);
        if (yol3YolAyrım == EnmYolAyrım.Duz)
        {
            if (yol3OtoAracTip == EnmOtonomAracTip.Araba)
            {
                lastPosRoad = CreateRoadCornerCar(lastPosRoad, lastAxis);
                if (lastAxis == EnmAxis.z)
                {
                    CreateRoad(25, new Vector3(lastPosRoad.x + 7.5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.x, otoCarRoad: true);
                    CreateRoad(25, new Vector3(lastPosRoad.x - 7.5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.rX, otoCarRoad: true);
                }
                else if (lastAxis == EnmAxis.rZ)
                {
                    CreateRoad(25, new Vector3(lastPosRoad.x + 7.5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.x, otoCarRoad: true);
                    CreateRoad(25, new Vector3(lastPosRoad.x - 7.5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.rX, otoCarRoad: true);
                }
                else if (lastAxis == EnmAxis.x)
                {
                    CreateRoad(25, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z + 7.5f), EnmAxis.z, otoCarRoad: true);
                    CreateRoad(25, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z - 7.5f), EnmAxis.rZ, otoCarRoad: true);
                }
                else if (lastAxis == EnmAxis.rX)
                {
                    CreateRoad(25, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z + 7.5f), EnmAxis.z, otoCarRoad: true);
                    CreateRoad(25, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z - 7.5f), EnmAxis.rZ, otoCarRoad: true);
                }
            }
            else if (yol3OtoAracTip == EnmOtonomAracTip.Tren)
            {
                lastPosRoad = CreateRoadCornerTrain(lastPosRoad, lastAxis);
                if (lastAxis == EnmAxis.z)
                {
                    CreateRail(10, new Vector3(lastPosRoad.x + 5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.x);
                    CreateRail(10, new Vector3(lastPosRoad.x - 5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.rX);
                }
                else if (lastAxis == EnmAxis.rZ)
                {
                    CreateRail(10, new Vector3(lastPosRoad.x + 5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.x);
                    CreateRail(10, new Vector3(lastPosRoad.x - 5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.rX);
                }
                else if (lastAxis == EnmAxis.x)
                {
                    CreateRail(10, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z + 5f), EnmAxis.z);
                    CreateRail(10, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z - 5f), EnmAxis.rZ);
                }
                else if (lastAxis == EnmAxis.rX)
                {
                    CreateRail(10, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z + 5f), EnmAxis.z);
                    CreateRail(10, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z - 5f), EnmAxis.rZ);
                }
            }

            switch (lastAxis)
            {
            case EnmAxis.x:
                lastPosRoad.x += 7.5f;
                break;

            case EnmAxis.rX:
                lastPosRoad.x -= 7.5f;
                break;

            case EnmAxis.z:
                lastPosRoad.z += 7.5f;
                break;

            case EnmAxis.rZ:
                lastPosRoad.z -= 7.5f;
                break;
            }
        }
        else if (yol3YolAyrım == EnmYolAyrım.SagDonme)
        {
            if (yol3OtoAracTip == EnmOtonomAracTip.Araba)
            {
                lastPosRoad = CreateRoadCornerCar(lastPosRoad, lastAxis);
                if (lastAxis == EnmAxis.z)
                {
                    CreateRoad(25, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z + 7.5f), EnmAxis.z, otoCarRoad: true);
                    CreateRoad(25, new Vector3(lastPosRoad.x - 7.5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.rX, otoCarRoad: true);
                }
                else if (lastAxis == EnmAxis.rZ)
                {
                    CreateRoad(25, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z - 7.5f), EnmAxis.rZ, otoCarRoad: true);
                    CreateRoad(25, new Vector3(lastPosRoad.x + 7.5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.x, otoCarRoad: true);
                }
                else if (lastAxis == EnmAxis.x)
                {
                    CreateRoad(25, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z + 7.5f), EnmAxis.z, otoCarRoad: true);
                    CreateRoad(25, new Vector3(lastPosRoad.x + 7.5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.x, otoCarRoad: true);
                }
                else if (lastAxis == EnmAxis.rX)
                {
                    CreateRoad(25, new Vector3(lastPosRoad.x - 7.5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.rX, otoCarRoad: true);
                    CreateRoad(25, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z - 7.5f), EnmAxis.rZ, otoCarRoad: true);
                }
            }

            switch (lastAxis)
            {
            case EnmAxis.x:
                lastPosRoad.z -= 7.5f;
                lastAxis       = EnmAxis.rZ;
                break;

            case EnmAxis.rX:
                lastPosRoad.z += 7.5f;
                lastAxis       = EnmAxis.z;
                break;

            case EnmAxis.z:
                lastPosRoad.x += 7.5f;
                lastAxis       = EnmAxis.x;
                break;

            case EnmAxis.rZ:
                lastPosRoad.x -= 7.5f;
                lastAxis       = EnmAxis.rX;
                break;
            }
        }
        else if (yol3YolAyrım == EnmYolAyrım.SolDonme)
        {
            if (yol3OtoAracTip == EnmOtonomAracTip.Araba)
            {
                lastPosRoad = CreateRoadCornerCar(lastPosRoad, lastAxis);
                if (lastAxis == EnmAxis.z)
                {
                    CreateRoad(25, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z + 7.5f), EnmAxis.z, otoCarRoad: true);
                    CreateRoad(25, new Vector3(lastPosRoad.x + 7.5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.x, otoCarRoad: true);
                }
                else if (lastAxis == EnmAxis.rZ)
                {
                    CreateRoad(25, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z - 7.5f), EnmAxis.rZ, otoCarRoad: true);
                    CreateRoad(25, new Vector3(lastPosRoad.x - 7.5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.rX, otoCarRoad: true);
                }
                else if (lastAxis == EnmAxis.x)
                {
                    CreateRoad(25, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z - 7.5f), EnmAxis.rZ, otoCarRoad: true);
                    CreateRoad(25, new Vector3(lastPosRoad.x + 7.5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.x, otoCarRoad: true);
                }
                else if (lastAxis == EnmAxis.rX)
                {
                    CreateRoad(25, new Vector3(lastPosRoad.x - 7.5f, lastPosRoad.y, lastPosRoad.z), EnmAxis.rX, otoCarRoad: true);
                    CreateRoad(25, new Vector3(lastPosRoad.x, lastPosRoad.y, lastPosRoad.z + 7.5f), EnmAxis.z, otoCarRoad: true);
                }
            }

            switch (lastAxis)
            {
            case EnmAxis.x:
                lastPosRoad.z += 7.5f;
                lastAxis       = EnmAxis.z;
                break;

            case EnmAxis.rX:
                lastPosRoad.z -= 7.5f;
                lastAxis       = EnmAxis.rZ;
                break;

            case EnmAxis.z:
                lastPosRoad.x -= 7.5f;
                lastAxis       = EnmAxis.rX;
                break;

            case EnmAxis.rZ:
                lastPosRoad.x += 7.5f;
                lastAxis       = EnmAxis.x;
                break;
            }
        }
        #endregion

        lastPosRoad = CreateRoad(yol4Uzunluk, lastPosRoad, lastAxis);
    }
Exemple #6
0
    private Vector3 CreateRoad(int len, Vector3 startPos, EnmAxis axis, bool paintParkArea = false, bool otoCarRoad = false)
    {
        Vector3 newPos = new Vector3(startPos.x, startPos.y, startPos.z);

        for (int i = 0; i < len; i++)
        {
            switch (axis)
            {
            case EnmAxis.x:
                newPos.x += 5;
                break;

            case EnmAxis.rX:
                newPos.x -= 5;
                break;

            case EnmAxis.z:
                newPos.z += 5;
                break;

            case EnmAxis.rZ:
                newPos.z -= 5;
                break;
            }

            GameObject road = Instantiate(yol);
            road.transform.position = newPos;
            if (axis == EnmAxis.x || axis == EnmAxis.rX)
            {
                road.transform.rotation = Quaternion.Euler(0f, 90f, 0f);
            }
            road.transform.parent = goRoads.transform;

            if (otoCarRoad && i == len - 1)
            {
                Vector3 otoCarPosV = new Vector3(newPos.x, newPos.y, newPos.z);

                switch (axis)
                {
                case EnmAxis.x:
                    otoCarPosV.z += 3.5f;
                    break;

                case EnmAxis.rX:
                    otoCarPosV.z -= 3.5f;
                    break;

                case EnmAxis.z:
                    otoCarPosV.x -= 3.5f;
                    break;

                case EnmAxis.rZ:
                    otoCarPosV.x += 3.5f;
                    break;
                }


                GameObject otoCarPos = new GameObject();
                otoCarPos.name = "OtoCarPos";

                otoCarPos.transform.position = otoCarPosV;
                otoCarPos.transform.parent   = goOtoPoses.transform;
            }

            if (paintParkArea && i == len - 2)
            {
                Vector3 parkAreaPos = new Vector3(newPos.x, newPos.y, newPos.z);
                switch (axis)
                {
                case EnmAxis.x:
                    parkAreaPos.z += 3.5f;
                    break;

                case EnmAxis.rX:
                    parkAreaPos.z -= 3.5f;
                    break;

                case EnmAxis.z:
                    parkAreaPos.x -= 3.5f;
                    break;

                case EnmAxis.rZ:
                    parkAreaPos.x += 3.5f;
                    break;
                }
                GameObject parkArea = Instantiate(parkAlani);
                parkArea.transform.position = parkAreaPos;
                if (axis == EnmAxis.x || axis == EnmAxis.rX)
                {
                    parkArea.transform.rotation = Quaternion.Euler(90f, 90f, 90f);
                }
                parkArea.transform.parent = goParkAreas.transform;
                lastParkArea = parkArea;
            }
        }

        return(newPos);
    }
Exemple #7
0
    private void CreateApart(int len, Vector3 startPos, EnmAxis axis, int leftRight)
    {
        int     maxLen       = len * 5;
        float   lastHouseLen = 0f;
        float   houseLen     = 0f;
        Vector3 newPos       = new Vector3(startPos.x, startPos.y, startPos.z);

        if (lastAxis == EnmAxis.z)
        {
            newPos.z += 15f;
        }
        else if (lastAxis == EnmAxis.rX)
        {
            newPos.x -= 15f;
        }
        else if (lastAxis == EnmAxis.rZ)
        {
            newPos.z -= 15f;
        }
        else if (lastAxis == EnmAxis.x)
        {
            newPos.x += 15f;
        }

        for (int i = 0; i < len; i++)
        {
            int houseIndex = UnityEngine.Random.Range(0, ApartListe.Length);

            switch (axis)
            {
            case EnmAxis.x:
                newPos.x += lastHouseLen;
                break;

            case EnmAxis.rX:
                newPos.x -= lastHouseLen;
                break;

            case EnmAxis.z:
                newPos.z += lastHouseLen;
                break;

            case EnmAxis.rZ:
                newPos.z -= lastHouseLen;
                break;
            }

            if (houseLen > len * 5 - ApartListe[houseIndex].boyut)
            {
                break;
            }

            GameObject road = Instantiate(ApartListe[houseIndex].ev);
            lastHouseLen = ApartListe[houseIndex].boyut;
            houseLen    += lastHouseLen;
            Vector3 pos = newPos;

            switch (axis)
            {
            case EnmAxis.x:
                if (leftRight == 0)
                {
                    pos.z += ApartListe[houseIndex].genislik;
                }
                else if (leftRight == 1)
                {
                    pos.z -= ApartListe[houseIndex].genislik;
                }
                break;

            case EnmAxis.rX:
                if (leftRight == 0)
                {
                    pos.z -= ApartListe[houseIndex].genislik;
                }
                else if (leftRight == 1)
                {
                    pos.z += ApartListe[houseIndex].genislik;
                }
                break;

            case EnmAxis.z:
                if (leftRight == 0)
                {
                    pos.x -= ApartListe[houseIndex].genislik;
                }
                else if (leftRight == 1)
                {
                    pos.x += ApartListe[houseIndex].genislik;
                }
                break;

            case EnmAxis.rZ:
                if (leftRight == 0)
                {
                    pos.x += ApartListe[houseIndex].genislik;
                }
                else if (leftRight == 1)
                {
                    pos.x -= ApartListe[houseIndex].genislik;
                }
                break;
            }
            road.transform.position = pos;

            if (axis == EnmAxis.z && leftRight == 1)
            {
                road.transform.rotation = Quaternion.Euler(0f, 180f, 0f);
            }
            else if (axis == EnmAxis.rZ && leftRight == 0)
            {
                road.transform.rotation = Quaternion.Euler(0f, 180f, 0f);
            }
            else if (axis == EnmAxis.x && leftRight == 0)
            {
                road.transform.rotation = Quaternion.Euler(0f, 90f, 0f);
            }
            else if (axis == EnmAxis.x && leftRight == 1)
            {
                road.transform.rotation = Quaternion.Euler(0f, -90f, 0f);
            }
            else if (axis == EnmAxis.rX && leftRight == 0)
            {
                road.transform.rotation = Quaternion.Euler(0f, -90f, 0f);
            }
            else if (axis == EnmAxis.rX && leftRight == 1)
            {
                road.transform.rotation = Quaternion.Euler(0f, 90f, 0f);
            }

            road.transform.parent = goDesigns.transform;
        }
    }