Exemple #1
0
    /**
     * Get target position of the current aimed agent
     */
    private Vector3 getTargetPositionFromAgent()
    {
        MovingAgent humanoidAgent = m_currentTarget as MovingAgent;

        if (humanoidAgent == null)
        {
            return(m_currentTarget.getTopPosition());
        }
        else
        {
            if (humanoidAgent.isCrouched())
            {
                if (humanoidAgent.isAimed())
                {
                    return(m_currentTarget.getTopPosition());
                }
                else
                {
                    return(m_currentTarget.getCurrentPosition() + new Vector3(0, 0.6f, 0));
                }
            }
            else
            {
                return(m_currentTarget.getCurrentPosition() + new Vector3(0, 1.05f, 0));
            }
        }
    }
    public bool canFireToTarget(float maximumFiringDistance)
    {
        bool canFire = maximumFiringDistance > distanceTo(target.getCurrentPosition());

        if (!canFire)
        {
            //Debug.Log("Distance Fail");
            return(false);
        }
        else
        {
            RaycastHit hit;
            string[]   layerMaskNames = { "FullCOverObsticles" };

            if (Physics.Raycast(transform.position + new Vector3(0, 2f, 0), target.getTopPosition() - this.transform.position - new Vector3(0, 2f, 0), out hit, maximumFiringDistance, LayerMask.GetMask(layerMaskNames)))
            {
                return(false);
            }
            else
            {
                //Debug.Log("Nothing to hit");
                return(true);
            }
        }
    }