public void Start()
	{
		_controlManager = ControlManager.Instance;
		_movement = GetComponent<PedestrianMovement>();
		_sprite = GetComponentInChildren<AsvarduilSpriteSystem>();

		_currentIdleHook = FindCurrentIdleHook();
	}
Пример #2
0
    public void Start()
    {
        _controlManager = ControlManager.Instance;
        _movement       = GetComponent <PedestrianMovement>();
        _sprite         = GetComponentInChildren <AsvarduilSpriteSystem>();

        _currentIdleHook = FindCurrentIdleHook();
    }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Pedestrian"/> class.
 /// </summary>
 /// <param name="point">The location of the <see cref="Pedestrian"/>.</param>
 /// <param name="movement">The <see cref="PedestrianMovement"/> of the <see cref="Pedestrian"/>.</param>
 public Pedestrian(Point point, PedestrianMovement movement)
 {
     this.MovingBehaviour = MoveBehaviour.DECELERATE;
     this.Position = point;
     this.MovementDirection = movement;
     this.Speed = 0;
     this.HitBox = new Rectangle(this.Position.X, this.Position.Y, 3, 3);
     UI.TrafficTimer.Timer.Elapsed += (s, e) => Move(this.MovingBehaviour);
 }
    void WriteToCsv()
    {
        string       filePath   = Application.dataPath + "/csv/trial_data-" + groupFormationToTest + ".csv";
        bool         fileExists = File.Exists(filePath);
        StreamWriter writer     = new StreamWriter(filePath, append: true);

        if (!fileExists)
        {
            //writer = new StreamWriter(filePath);
            // Header
            writer.WriteLine("id,formation,time,col0,col1,col2,col3,col4,col5");
        }

        // Get Pedestrian collision data
        int[] collisions = new int[] { 0, 0, 0, 0, 0, 0 };
        foreach (GameObject ge in GameObject.FindGameObjectsWithTag("Obstacle"))
        {
            PedestrianMovement pm = ge.GetComponent <PedestrianMovement>();
            collisions[pm.pedestrianID] = pm.numCollisions;
            Debug.Log(pm.pedestrianID + "   " + pm.numCollisions);
            Debug.Log(collisions[pm.pedestrianID]);
        }

        Debug.Log("----");
        Debug.Log(collisions[0]);
        Debug.Log(collisions[1]);
        Debug.Log(collisions[2]);

        // Output data
        writer.WriteLine(trialID +
                         "," + groupFormationToTest +
                         "," + timeSinceStart +
                         "," + collisions[0] +
                         "," + collisions[1] +
                         "," + collisions[2] +
                         "," + collisions[3] +
                         "," + collisions[4] +
                         "," + collisions[5]
                         );

        writer.Flush();
        writer.Close();
    }
    // Update is called once per frame
    void Update()
    {
        timeSinceStart += Time.deltaTime;
        int pedestriansLeft = 6;

        foreach (GameObject ge in GameObject.FindGameObjectsWithTag("Obstacle"))
        {
            PedestrianMovement pm = ge.GetComponent <PedestrianMovement>();
            if (pm.finishedTrial)
            {
                pedestriansLeft -= 1;
            }
        }
        if (GameObject.FindGameObjectsWithTag("Spawner").Length <= 0 && pedestriansLeft <= 0)
        {
            EndTrialRun();
        }
        //if(GameObject.FindGameObjectsWithTag("Obstacle").Length <= 0 && GameObject.FindGameObjectsWithTag("Spawner").Length <= 0) {
        //    EndTrialRun();
        //}
    }
Пример #6
0
 public void Start()
 {
     _sprite   = GetComponentInChildren <AsvarduilSpriteSystem>();
     _movement = GetComponent <PedestrianMovement>();
 }
Пример #7
0
	public void Start()
	{
		_sprite = GetComponentInChildren<AsvarduilSpriteSystem>();
		_movement = GetComponent<PedestrianMovement>();
	}