Esempio n. 1
0
    public IEnumerator PythonManagerGetScreenshotFilePathTest()
    {
        string path = PythonManager.GetInstance().GetScreenshotFilePath("screenshots/", "junction1", 5);

        Assert.AreEqual("screenshots/junction1_shot5.png", path);
        yield return(null);
    }
Esempio n. 2
0
 private void OnPostRender()
 {
     if (renderScreenshot)
     {
         Texture2D texture = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);
         texture.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0, false);
         texture.Apply();
         PythonManager.GetInstance().SetScreenshot(camera, texture);
         renderScreenshot = false;
     }
 }
Esempio n. 3
0
    public IEnumerator PythonManagerRewardCountTest()
    {
        int currentCount = PythonManager.GetInstance().GetRewardCount();

        currentCount++;
        PythonManager.GetInstance().IncrementRewardCount();
        Assert.AreEqual(PythonManager.GetInstance().GetRewardCount(), currentCount);
        currentCount = 0;
        PythonManager.GetInstance().ResetRewardCount();
        Assert.AreEqual(PythonManager.GetInstance().GetRewardCount(), currentCount);
        yield return(null);
    }
Esempio n. 4
0
    public void DisableLoops()
    {
        TrafficLightManager trafficLightManager = (TrafficLightManager)GameObject.FindObjectOfType(typeof(TrafficLightManager));

        trafficLightManager.StopAllCoroutines();
        PythonManager.GetInstance().StopAllCoroutines();
        PedestrianFactory pedestrianFactory = (PedestrianFactory)GameObject.FindObjectOfType(typeof(PedestrianFactory));

        if (pedestrianFactory != null)
        {
            pedestrianFactory.StopAllCoroutines();
        }
    }
Esempio n. 5
0
    void OnTriggerEnter(Collider other)
    {
        VehicleEngine vehicleEngine = other.GetComponentInParent <VehicleEngine>();

        if (vehicleEngine != null && !vehicleEngine.densityCountTriggered)
        {
            vehicleEngine.densityCountTriggered = true;
            PythonManager.GetInstance().IncrementDensityCount();
            // Calculate Delay
            if (vehicleEngine.startDelayTime != -1)
            {
                float delay = Time.time - vehicleEngine.startDelayTime;
                Utils.AppendAllTextToResults(Utils.VEHICLE_DELAY_TIMES_FILE_NAME, delay.ToString() + ",");
            }
        }
    }
Esempio n. 6
0
    /// <summary>
    /// Destroys the vehicle and passes information to the Python Manager.
    /// </summary>
    private void Destroy()
    {
        if (!densityCountTriggered)
        {
            densityCountTriggered = true;
            PythonManager.GetInstance().IncrementDensityCount();
        }
        Vector3 endPos   = transform.position;
        double  distance = Vector3.Distance(startPos, endPos);
        double  time     = (Time.time - startTime);
        double  speed    = (distance / time);

        PythonManager.GetInstance().speedList.Add(speed);
        Destroy(this.gameObject);
        PythonManager.GetInstance().IncrementRewardCount();
        Utils.AppendAllTextToResults(Utils.VEHICLE_TIMES_FILE_NAME, time.ToString() + ",");
    }
Esempio n. 7
0
        public static UnityContainer Configure()
        {
            var container = new UnityContainer();

            var rootPath       = ConfigurationManager.AppSettings.Get("RootPath");
            var usersRootPath  = ConfigurationManager.AppSettings.Get("UsersRootPath");
            var assetsRootPath = ConfigurationManager.AppSettings.Get("AssetsRootPath");
            var commandsPath   = ConfigurationManager.AppSettings.Get("CommandsPath");
            var libPath        = ConfigurationManager.AppSettings.Get("LibPath");
            var mlLibPath      = ConfigurationManager.AppSettings.Get("MlLibPath");
            var abilitiesPath  = Path.Combine(mlLibPath, "abilities");
            var affectsPath    = ConfigurationManager.AppSettings.Get("AffectsPath");

            container.RegisterInstance("RootPath", rootPath);
            container.RegisterInstance("AssetsRootPath", assetsRootPath);
            container.RegisterInstance("UsersRootPath", usersRootPath);
            container.RegisterInstance("LibPath", libPath);
            container.RegisterInstance("MlLibPath", mlLibPath);
            container.RegisterInstance("CommandsPath", commandsPath);
            container.RegisterInstance("AffectsPath", affectsPath);

            MLFunction.AddSearchPaths(libPath, mlLibPath);
            MLFunction.LoadAssemblies(
                Assembly.GetAssembly(typeof(Character)),
                Assembly.GetAssembly(typeof(IEnumerable <string>)),
                Assembly.GetAssembly(typeof(Enumerable)));

            var commandManager   = new CommandManager();
            var pythonManager    = new PythonManager();
            var abilityManager   = new AbilityManager();
            var characterManager = new CharacterManager(assetsRootPath, abilityManager);

            var itemManager = new ItemManager(assetsRootPath);
            var areaManager = new AreaManager(assetsRootPath, characterManager, itemManager);

            container.RegisterInstance <IManager <ICommand> >(commandManager);
            container.RegisterInstance <IManager <Character> >(characterManager);
            container.RegisterInstance <IManager <Item> >(itemManager);
            container.RegisterInstance <IManager <Area> >(areaManager);

            container.RegisterInstance(new Clock(DateTime.Now.Ticks));

            container.RegisterType <World>(new ContainerControlledLifetimeManager());
            return(container);
        }
Esempio n. 8
0
    private new void DisableLoops()
    {
        // Optimize time by removing unneeded particles
        foreach (ParticleSystem particleSystem in GameObject.FindObjectsOfType <ParticleSystem>())
        {
            particleSystem.Stop();
        }
        TrafficLightManager trafficLightManager = (TrafficLightManager)GameObject.FindObjectOfType(typeof(TrafficLightManager));

        trafficLightManager.enabled = false;
        trafficLightManager.StopAllCoroutines();
        VehicleFactory vehicleFactory = (VehicleFactory)GameObject.FindObjectOfType(typeof(VehicleFactory));

        vehicleFactory.StopAllCoroutines();
        PythonManager.GetInstance().StopAllCoroutines();
        PedestrianFactory pedestrianFactory = (PedestrianFactory)GameObject.FindObjectOfType(typeof(PedestrianFactory));

        if (pedestrianFactory != null)
        {
            pedestrianFactory.StopAllCoroutines();
        }
    }
Esempio n. 9
0
 public void TearDown()
 {
     PythonManager.GetInstance().rewardCount  = 0;
     PythonManager.GetInstance().densityCount = 0;
 }
Esempio n. 10
0
 void Awake()
 {
     instance = this;
 }