예제 #1
0
    void ShootWeapon()
    {
        // VFX
        if (m_MuzzleFlash)
        {
            m_MuzzleFlash.Play();
        }

        // SFX
        if (m_ShootSFX)
        {
            m_AudioSource.Play();
        }

        // Hit detection
        RaycastHit hit;

        if (Physics.Raycast(m_AgentCamera.transform.position, m_AgentCamera.transform.forward, out hit, 150f))
        {
            DCDummy hitAgent = hit.transform.GetComponent <DCDummy>();

            if (hitAgent != null)
            {
                score += 1;
                m_AgentArea.ResolveHit(this, hitAgent, score);
            }
        }
    }
예제 #2
0
    bool HasTargetsInSight()
    {
        bool someTargetInSight = false;

        foreach (DCDummy doomCubeAgent in m_AgentTargets)
        {
            if (doomCubeAgent != this)
            {
                Vector3 tPos = m_AgentCamera.WorldToViewportPoint(doomCubeAgent.transform.position);

                if (tPos.x > 0f && tPos.x < 1f && tPos.y > 0f && tPos.y < 1f && tPos.z > 0f)
                {
                    RaycastHit hit;
                    Vector3    tDir = doomCubeAgent.transform.position - m_AgentCamera.transform.position;

                    if (Physics.Raycast(m_AgentCamera.transform.position, tDir, out hit, 150f))
                    {
                        DCDummy hitAgent = hit.transform.GetComponent <DCDummy>();

                        if (hitAgent != null && hitAgent == doomCubeAgent)
                        {
                            someTargetInSight = true;
                            break;
                        }
                    }
                }
            }
        }

        return(someTargetInSight);
    }
예제 #3
0
    public void ResolveHit(DCAgentSolo winnerAgent, DCDummy loserAgent, int score)
    {
        winnerAgent.AddReward(score);
        PlaceDummy(loserAgent, 8 + score);

        if (score > 2)
        {
            winnerAgent.EndEpisode();
        }
    }
예제 #4
0
    public void PlaceDummy(DCDummy doomCube, int zone)
    {
        if (zone > 8)
        {
            // Spawn position
            doomCube.transform.position = transform.position + new Vector3(20f + ((float)(zone - 8)) * 4f, 1.5f, 55f);

            // Spawn direction
            doomCube.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
        }
        else
        {
            // Spawn position
            doomCube.transform.position = ChooseRandomPosition(zone);

            // Spawn direction
            doomCube.transform.rotation = ChooseRandomRotation();
        }
    }
예제 #5
0
    // Update is called once per frame
    void Update()
    {
        // Hit detection
        RaycastHit hit;

        if (Physics.Raycast(m_Camera.transform.position, m_Camera.transform.forward, out hit, 150f))
        {
            DCDummy hitAgent = hit.transform.GetComponent <DCDummy>();

            if (hitAgent != null)
            {
                m_Crosshair.color = Color.red;
            }
            else
            {
                m_Crosshair.color = Color.white;
            }
        }
    }