コード例 #1
0
    void OnCollisionEnter(Collision other)
    {
        if (_crashed || _aiCarControl == null || _carController == null)
        {
            return;
        }

        // Break and disable AI control
        _crashed = true;
        _aiCarControl.enabled = false;
        _carController.Move(0, 0, 0, 0);
        var survivalTime     = _odometer.SurvivalTime;
        var traveledDistance = _odometer.Distance;
        var furthestDistance = _odometer.FarthestDistance;

        // Analyze the results
        StartCoroutine(AI_Logic.RunEvaluationCoroutine(survivalTime, traveledDistance, furthestDistance, () => {
            SceneManager.LoadScene(0);

            // Reset odometer
            if (_odometer != null)
            {
                _odometer.Reset();
            }

            // Enable AI control
            _aiCarControl.enabled = true;
            _crashed = false;
        }));
    }
コード例 #2
0
    private void FixedUpdate()
    {
        var sensors = GetSensorValues();

        StartCoroutine(AI_Logic.RunAICoroutine(Time.time, Time.deltaTime, sensors, (output) => {
            _carController.Move(output.Steering, output.Acceleration, output.Footbrake, output.Handbrake);
        }));
    }
コード例 #3
0
    protected bool rotated = false;     //check if rotation was set somewhere else

    void Start()
    {
        /**Gets called by unity when the script is initialized
         * */
        anim         = GetComponent <Animator>();
        character    = gameObject.GetComponent <EnemyCharacter> ();
        logic        = gameObject.GetComponent <AI_Logic> ();
        agent        = gameObject.GetComponent <NavMeshAgent> ();
        time         = 0.0f;
        shootTimeOut = 0.0f;

        agent.stoppingDistance = character.stoppingRange;
        rand = new System.Random();
    }
コード例 #4
0
 public static void ResetLogic()
 {
     _aiLogic = new AI_Logic();
 }
コード例 #5
0
 static void OnBeforeSceneLoadRuntimeMethod()
 {
     AI_Logic.Restart();
 }