示例#1
0
文件: EnemyAI.cs 项目: Abahu/MUAi_p7
    public virtual void AIReset()
    {
        if (!stats)
        {
            stats = GetComponent <StatScript>();
        }
        stats?.AIReset();
        if (!rb)
        {
            rb = GetComponent <Rigidbody>();
        }
        if (rb)
        {
            rb.velocity        = Vector3.zero;
            rb.angularVelocity = Vector3.zero;
        }
        Vector3 pos = new Vector3(
            Random.Range(xRange.x, xRange.y),
            0,
            Random.Range(yRange.x, yRange.y));

        transform.localPosition = pos;
        transform.localRotation = Quaternion.Euler(0f, Random.Range(-180f, 180f), 0);

        state = StateEnum.Idle;
        ResetTarget();
    }
示例#2
0
    public override void AgentReset()
    {
        foreach (GameObject spell in castSpells)
        {
            if (spell != null)
            {
                Destroy(spell);
            }
        }
        castSpells.Clear();
        // If the Agent fell, zero its momentum
        rb.angularVelocity      = Vector3.zero;
        rb.velocity             = Vector3.zero;
        transform.localPosition = startPos;
        transform.localRotation = Quaternion.Euler(0, Random.Range(-180f, 180f), 0);


        stats.AIReset();
        isDead = false;

        // Reset enemies
        for (int i = 0; i < enemies.Length; ++i)
        {
            enemyAIs[i].AIReset();
        }

        Shuffle();
    }
示例#3
0
    public override void AgentReset()
    {
        ++numEpisodes;

        if (avgScoreField != null)
        {
            avgScoreField.text = (cumulativeScore / numEpisodes).ToString();
        }
        foreach (GameObject spell in castSpells)
        {
            if (spell != null)
            {
                Destroy(spell);
            }
        }
        castSpells.Clear();
        // If the Agent fell, zero its momentum
        rb.angularVelocity      = Vector3.zero;
        rb.velocity             = Vector3.zero;
        transform.localPosition = startPos;
        transform.localRotation = Quaternion.Euler(0, Random.Range(-180f, 180f), 0);
        isDead = false;
        stats.AIReset();
        Shuffle();
    }