Beispiel #1
0
    /// <summary>
    /// Bot choose a random point in the map and moves towards this target until it reaches.
    /// When it reaches it finds another target.
    /// </summary>
    private void moveRandomTarget()
    {
        if (Time.fixedTime >= nextActionTime)
        {
            // Pick a random target
            targetPosition = pandemicArea.ChooseRandomPosition();

            // Rotate toward the target
            transform.rotation = Quaternion.LookRotation(targetPosition - transform.position, Vector3.up);

            // Calculate the time to get there
            float timeToGetThere = Vector3.Distance(transform.position, targetPosition) / moveSpeed;
            nextActionTime = Time.fixedTime + timeToGetThere;
        }
        else
        {
            // Make sure that the fish does not swim past the target
            Vector3 moveVector = moveSpeed * transform.forward * Time.fixedDeltaTime;
            if (moveVector.magnitude <= Vector3.Distance(transform.position, targetPosition))
            {
                transform.position += moveVector;
            }
            else
            {
                transform.position = targetPosition;
                nextActionTime     = Time.fixedTime;
            }
        }
    }
Beispiel #2
0
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.CompareTag("target"))
        {
            float tempReward = 1 - (starvingLevel / 100);
            //AddReward(1- tempReward);
            AddReward(1f);
            //Add in TotalScore
            statRecorder.totalScore += 1;

            collision.gameObject.transform.position = pandemicArea.ChooseRandomPosition();
            starvingLevel = 100f;
        }
        if (m_InfectionStatus == agentStatus.HEALTHY)
        {
            if (collision.gameObject.CompareTag("agent"))
            {
                //Each agent will count this therefore its half.

                statRecorder.collisionCounts += 0.5f;
            }
            else if (collision.gameObject.CompareTag("dummyBot"))
            {
                statRecorder.collisionCounts += 1f;
            }
        }
    }
Beispiel #3
0
    private void Awake()
    {
        //Get the PandemicArea
        pandemicArea    = GetComponentInParent <PandemicArea>();
        pandemicAreaObj = pandemicArea.gameObject;

        targetPosition = pandemicArea.ChooseRandomPosition();
        GetComponent <SphereCollider>().radius = exposureRadius;
        recoverTime = pandemicArea.recoverTime;
    }
Beispiel #4
0
    private void Awake()
    {
        //Get the PandemicArea
        pandemicArea    = GetComponentInParent <PandemicArea>();
        pandemicAreaObj = pandemicArea.gameObject;

        targetPosition = pandemicArea.ChooseRandomPosition();
        GetComponent <SphereCollider>().radius = exposureRadius;
        recoverTime = pandemicArea.recoverTime;

        rb = GetComponent <Rigidbody>();
        initialVelocity = new Vector3(UnityEngine.Random.Range(-20, 20), 0, UnityEngine.Random.Range(-20, 20));

        coroutine = WaitAtStart(2f);
        //StartCoroutine(coroutine);
    }