Exemplo n.º 1
0
 void Start()
 {
     m_Players = new Perception_Player[PlayerInfo.PlayerList.Count];
     for (int i = 0; i < m_Players.Length; i++)
     {
         m_Players[i] = new Perception_Player(PlayerInfo.PlayerList[i]);
     }
 }
Exemplo n.º 2
0
    public float getThreat(Perception_Player player)
    {
        if (player.AttackedUs)
        {
            return((player.AttackedUsTimer / i_ResidualThreatTimerAttacks) + (getDistanceThreat(player) * i_FOVD_RT) + (getResidualDistanceThreat(player) * (1.0f - i_FOVD_RT)));
        }

        return((getDistanceThreat(player) * (1.0f - i_FOVD_RT)) + (getResidualDistanceThreat(player) * i_FOVD_RT));
        //return (getDistanceThreat (player) * i_FOVD_RT);
        //return (getResidualDistanceThreat(player) * (1.0f - i_FOVD_RT));
    }
Exemplo n.º 3
0
    public float getThreat(Perception_Player player)
    {
        if (player.AttackedUs)
        {
            return (player.AttackedUsTimer / i_ResidualThreatTimerAttacks) + (getDistanceThreat(player) * i_FOVD_RT) + (getResidualDistanceThreat(player) * (1.0f - i_FOVD_RT));
        }

        return (getDistanceThreat(player) * (1.0f - i_FOVD_RT)) + (getResidualDistanceThreat(player) * i_FOVD_RT);
        //return (getDistanceThreat (player) * i_FOVD_RT);
        //return (getResidualDistanceThreat(player) * (1.0f - i_FOVD_RT));
    }
Exemplo n.º 4
0
    float getDistanceThreat(Perception_Player player)
    {
        //distance to player
        float distance = (transform.position - player.Player.position).magnitude;

        //is player out of view distance?
        if (distance > i_ViewDist)
        {
            return(0.0f);
        }

        // is the player behind something?
        RaycastHit raycastData;

        if (!Physics.Raycast(transform.position, player.Player.position - transform.position, out raycastData, distance + 1.0f, ~LayerMask.GetMask(Constants.ENEMY_STRING)))// TODO: replace with constant
        {
            //Debug.DrawLine(transform.position, player.Player.position - transform.position, Color.red);
            return(0.0f);
        }
        else
        {
            //did we hit the player?
            if (raycastData.collider.tag != Constants.PLAYER_STRING)
            {
                //Debug.DrawLine(transform.position, player.Player.position - transform.position, Color.black);
                //return 0.0f;
            }
        }

        //in the field of view?
        float dot   = Vector3.Dot(transform.forward.normalized, (player.Player.position - transform.position).normalized);
        float angle = Mathf.Acos(dot / (transform.forward.normalized.magnitude * (player.Player.position - transform.position).normalized.magnitude)) * ANGLE_MULTIPLIER;



        if (i_FieldOfView < angle)
        {
            //return 0.0f;
        }
        //Debug.Log (player.PlayerInfo.gameObject.name + " in range/sight");
        //we can see the player
        player.playerSeen(i_ResidualThreatTimerSight);

        return(Mathf.Clamp(((i_ViewDist * i_PerfectVisionPercent) / distance), 0.0f, 1.0f));
    }
Exemplo n.º 5
0
 float getResidualDistanceThreat(Perception_Player player)
 {
     return(player.SawPlayerTimer / i_ResidualThreatTimerSight);
 }
Exemplo n.º 6
0
    float getDistanceThreat(Perception_Player player)
    {
        //distance to player
        float distance = (transform.position - player.Player.position).magnitude;

        //is player out of view distance?
        if (distance > i_ViewDist)
        {
            return 0.0f;
        }

        // is the player behind something?
        RaycastHit raycastData;
        if (!Physics.Raycast(transform.position, player.Player.position - transform.position, out raycastData, distance +1.0f, ~LayerMask.GetMask(Constants.ENEMY_STRING)))// TODO: replace with constant
        {
            //Debug.DrawLine(transform.position, player.Player.position - transform.position, Color.red);
            return 0.0f;
        }
        else
        {
            //did we hit the player?
            if (raycastData.collider.tag != Constants.PLAYER_STRING)
            {
                //Debug.DrawLine(transform.position, player.Player.position - transform.position, Color.black);
                //return 0.0f;
            }
        }

        //in the field of view?
        float dot = Vector3.Dot(transform.forward.normalized, (player.Player.position - transform.position).normalized);
        float angle = Mathf.Acos(dot / (transform.forward.normalized.magnitude * (player.Player.position - transform.position).normalized.magnitude)) * ANGLE_MULTIPLIER;

        if (i_FieldOfView < angle)
        {
            //return 0.0f;
        }
        //Debug.Log (player.PlayerInfo.gameObject.name + " in range/sight");
        //we can see the player
        player.playerSeen(i_ResidualThreatTimerSight);

        return Mathf.Clamp(((i_ViewDist * i_PerfectVisionPercent) / distance), 0.0f, 1.0f);
    }
Exemplo n.º 7
0
 void Start()
 {
     m_Players = new Perception_Player[PlayerInfo.PlayerList.Count];
     for (int i = 0; i < m_Players.Length; i++)
     {
         m_Players[i] = new Perception_Player(PlayerInfo.PlayerList[i]);
     }
 }
Exemplo n.º 8
0
 float getResidualDistanceThreat(Perception_Player player)
 {
     return player.SawPlayerTimer / i_ResidualThreatTimerSight;
 }