Пример #1
0
    private void InctanceRoadSituation()
    {
        ToolBox.Get <SignManager>().ClearSigns();
        ToolBox.Get <CarManager>().Clear();
        ToolBox.Get <TrafficLightManager>().Clear();


        ToolBox.Get <UIManager>().SetUIForRevision();



        RoadSituation RS = ToolBox.Get <ProcessingAnsvers>().lvlSituat[ToolBox.Get <SettingsPlayer>().numberOfRevisionQuestion];

        ToolBox.Get <TrafficLightManager>().GenerationTrafficLight(RS, ToolBox.Get <CrossManager>().Cross.transform);

        ToolBox.Get <SignManager>().GenerationTrafficSigns(RS, ToolBox.Get <CrossManager>().Cross.transform);

        ToolBox.Get <CarManager>().GenerateCars(RS, ToolBox.Get <CrossManager>().Cross.transform);
        ToolBox.Get <UIManager>().CreateBottons(ToolBox.Get <CarManager>().MasCars.Length);
        ToolBox.Get <ProcessingAnsvers>().DebugOut(ToolBox.Get <SettingsPlayer>().numberOfRevisionQuestion);
        if (!ToolBox.Get <SettingsPlayer>().ARCamera)
        {
            ToolBox.Get <CameraManager>().SetLocation(ToolBox.Get <CarManager>().MasCars[0], new Vector3(-20, 10, 0));
        }
        timer = ToolBox.Get <TimerManager>().SetTimer(20f, delegate { ToolBox.Get <UIManager>().ShowResults(); });
    }
Пример #2
0
 public GameObject[] GenerateCars(RoadSituation roadSituation, Transform cross)
 {
     MasCars         = new GameObject[roadSituation.CountOfCars];
     carPos          = roadSituation.posRotAnimCar;
     this.VIP        = roadSituation.VIP;
     this.directions = roadSituation.directions;
     return(InstantiateCars(cross));
 }
Пример #3
0
    public void GenerationTrafficSigns(RoadSituation road, Transform parent)
    {
        if (road.trafficSign != TrafficSign.Empty)
        {
            TS = new Dictionary <Position, TrafficSign>(3);

            InstantiateTrafficSign(road.posRotSign, road.CoutOfSigns, parent);
        }
    }
Пример #4
0
    IEnumerator SimpleGenerator()
    {
        PositionRotation[] posRotAnim = GetConstPRofCars();
        int numberOfSituation         = 0;

        ToolBox.Get <CarManager>().Clear();
        ToolBox.Get <ProcessingAnsvers>().mistakesese.Clear();
        ToolBox.Get <ProcessingAnsvers>().lvlSituat.Clear();
        while (numberOfSituation < 10 && ToolBox.Get <ProcessingAnsvers>().mistakesese.Count < 2)
        {
            Restart = false;
            RoadSituation RS = new RoadSituation(
                Random.Range(2, 4), Shuffle(GetConstPRofCars()), Convert.ToBoolean(Random.Range(0, 2)),
                new Direction[] { (Direction)Random.Range(0, 3), (Direction)Random.Range(0, 3), (Direction)Random.Range(0, 3), (Direction)Random.Range(0, 3) },
                (TrafficSign)Random.Range(0, 3), 4, ShaffleOdd(ConstSignTransform()),
                (TrafficLight)Random.Range(0, 4), 4, GetConstPRofTL());

            ToolBox.Get <TrafficLightManager>().GenerationTrafficLight(RS, ToolBox.Get <CrossManager>().Cross.transform);

            ToolBox.Get <SignManager>().GenerationTrafficSigns(RS, ToolBox.Get <CrossManager>().Cross.transform);

            ToolBox.Get <CarManager>().GenerateCars(RS, ToolBox.Get <CrossManager>().Cross.transform);
            ToolBox.Get <ProcessingAnsvers>().lvlSituat.Add(RS);
            if (!ToolBox.Get <SettingsPlayer>().ARCamera)
            {
                ToolBox.Get <CameraManager>().SetLocation(ToolBox.Get <CarManager>().MasCars[0], new Vector3(-20, 10, 0));
            }
            ToolBox.Get <UIManager>().CreateBottons(ToolBox.Get <CarManager>().MasCars.Length);
            timer = ToolBox.Get <TimerManager>().SetTimer(20f, delegate
            {
                if (ToolBox.Get <ProcessingAnsvers>().mistakesese.Count < 1)
                {
                    ToolBox.Get <ProcessingAnsvers>().mistakesese.Add(ToolBox.Get <ProcessingAnsvers>().lvlSituat.Count);
                    Restart = true;
                }
                else
                {
                    ToolBox.Get <ProcessingAnsvers>().mistakesese.Add(ToolBox.Get <ProcessingAnsvers>().lvlSituat.Count);

                    ToolBox.Get <SendingInfoManager>().SendTest();
                    ToolBox.Get <UIManager>().ShowResults();
                }
            });

            yield return(new WaitWhile(() => Restart == false));

            ToolBox.Get <UIManager>().ClearBottons();
            ToolBox.Get <SignManager>().ClearSigns();
            ToolBox.Get <CarManager>().Clear();
            ToolBox.Get <TrafficLightManager>().Clear();
            numberOfSituation++;
            Debug.Log(string.Format("{0}------------numberOfSituation", numberOfSituation));
        }

        ToolBox.Get <SendingInfoManager>().SendTest();
        ToolBox.Get <UIManager>().ShowResults();
    }
Пример #5
0
 public RoadSituation AddLvlSituat(RoadSituation situa)
 {
     lvlSituat.Add(situa);
     return(situa);
 }
Пример #6
0
    public void GenerationTrafficLight(RoadSituation road, Transform parent)
    {
        if (road.trafficLight != TrafficLight.Empty)
        {
            GenerateTrafficGO(road.posRotLight, parent);

            GameObject[] lights1 = new GameObject[4];
            GameObject[] lights2 = new GameObject[4];
            prefabOfLight.GetComponent <Light>().range = 5;
            for (int i = 0; i < TL.Length; i++)
            {
                lights1[i] = Instantiate(prefabOfLight, TL[i].transform, false);

                lights2[i] = Instantiate(prefabOfLight, TL[i].transform, false);
            }

            switch (road.trafficLight)//Тута сам свет наверн
            {
            case TrafficLight.Off:
                for (int i = 0; i < TL.Length; i++)
                {
                    lights1[i].transform.localPosition = new Vector3(0, 20, -4);
                    lights2[i].transform.localPosition = new Vector3(0, 20, 4);
                    lights1[i].GetComponent <Animator>().runtimeAnimatorController = controllerOfLight;
                    lights2[i].GetComponent <Animator>().runtimeAnimatorController = controllerOfLight;
                }
                break;

            case TrafficLight.Red:
                PosTL = new Dictionary <Position, TrafficLight>();
                for (int i = 0; i < TL.Length; i++)
                {
                    if (i % 2 == 0)
                    {
                        lights1[i].GetComponent <Light>().color = Color.red;
                        lights2[i].GetComponent <Light>().color = Color.red;
                        lights1[i].transform.localPosition      = new Vector3(0, 22, -4);
                        lights2[i].transform.localPosition      = new Vector3(0, 22, 4);
                        PosTL.Add((Position)i, TrafficLight.Red);
                    }
                    else
                    {
                        lights1[i].GetComponent <Light>().color = Color.green;
                        lights2[i].GetComponent <Light>().color = Color.green;
                        lights1[i].transform.localPosition      = new Vector3(0, 18, -4);
                        lights2[i].transform.localPosition      = new Vector3(0, 18, 4);
                        PosTL.Add((Position)i, TrafficLight.Green);
                    }
                }
                break;

            case TrafficLight.Green:
                PosTL = new Dictionary <Position, TrafficLight>();
                for (int i = 0; i < TL.Length; i++)
                {
                    if (i % 2 == 0)
                    {
                        lights1[i].GetComponent <Light>().color = Color.green;
                        lights2[i].GetComponent <Light>().color = Color.green;
                        lights1[i].transform.localPosition      = new Vector3(0, 18, -4);
                        lights2[i].transform.localPosition      = new Vector3(0, 18, 4);
                        PosTL.Add((Position)i, TrafficLight.Green);
                    }
                    else
                    {
                        lights1[i].GetComponent <Light>().color = Color.red;
                        lights2[i].GetComponent <Light>().color = Color.red;
                        lights1[i].transform.localPosition      = new Vector3(0, 22, -4);
                        lights2[i].transform.localPosition      = new Vector3(0, 22, 4);
                        PosTL.Add((Position)i, TrafficLight.Red);
                    }
                }
                break;
            }
        }
    }