private static void CustomDrawGizmos(Transform aTarget, GizmoType aGizmoType)
    {
        #if UNITY_EDITOR
        if (Application.isPlaying)
        {
            AIMotor motor = (AIMotor)aTarget.GetComponent <AIMotor>();
            if (!motor)
            {
                return;
            }

            // debug auto crouch
            Vector3 posHead = motor.transform.position + Vector3.up * ((motor._capsuleCollider.height * 0.5f) - motor._capsuleCollider.radius);
            Ray     ray1    = new Ray(posHead, Vector3.up);
            Gizmos.DrawWireSphere(ray1.GetPoint((motor.headDetect - (motor._capsuleCollider.radius * 0.1f))), motor._capsuleCollider.radius * 0.9f);
            Handles.Label(ray1.GetPoint((motor.headDetect + (motor._capsuleCollider.radius))), "Head Detection");

            // debug check trigger action
            Vector3 yOffSet = new Vector3(0f, -0.5f, 0f);
            Ray     ray2    = new Ray(motor.transform.position - yOffSet, motor.transform.forward);
            Debug.DrawRay(ray2.origin, ray2.direction * motor.distanceOfRayActionTrigger, Color.white);
            Handles.Label(ray2.GetPoint(motor.distanceOfRayActionTrigger), "Check for Trigger Actions");
        }
        #endif
    }
    public void OnSceneGUI()
    {
        AIMotor motor = (AIMotor)target;

        if (!motor)
        {
            return;
        }
        if (!motor.displayGizmos)
        {
            return;
        }
        Handles.color = new Color(1, 1, 0, 0.2f);
        Handles.DrawSolidArc(motor.transform.position, Vector3.up, motor.transform.forward, motor.fieldOfView, motor.maxDetectDistance);
        Handles.DrawSolidArc(motor.transform.position, Vector3.up, motor.transform.forward, -motor.fieldOfView, motor.maxDetectDistance);
        Handles.color = new Color(1, 1, 1, 0.5f);
        Handles.DrawWireDisc(motor.transform.position, Vector3.up, motor.maxDetectDistance);
        Handles.color = new Color(0, 1, 0, 0.1f);
        Handles.DrawSolidDisc(motor.transform.position, Vector3.up, motor.strafeDistance);

        Handles.color = new Color(1, 0, 0, 0.2f);
        Handles.DrawSolidDisc(motor.transform.position, Vector3.up, motor.minDetectDistance);
        Handles.color = new Color(0, 0, 1, 0.2f);
        Handles.DrawSolidDisc(motor.transform.position, Vector3.up, motor.distanceToAttack);
    }
    void OnEnable()
    {
        AIMotor motor = (AIMotor)target;

        if (motor.gameObject.layer == LayerMask.NameToLayer("Default"))
        {
            PopUpLayerInfoEditor window = ScriptableObject.CreateInstance <PopUpLayerInfoEditor>();
            window.position = new Rect(Screen.width, Screen.height / 2, 360, 100);
            window.ShowPopup();
        }
    }
    public override void OnInspectorGUI()
    {
        if (!skin)
        {
            skin = Resources.Load("skin") as GUISkin;
        }
        GUI.skin = skin;
        AIMotor motor = (AIMotor)target;

        GUILayout.BeginVertical("AI Controller", "window");

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        if (!motor)
        {
            return;
        }

        if (motor.gameObject.layer == LayerMask.NameToLayer("Default"))
        {
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.HelpBox("Please assign the Layer of the Character to 'Enemy'", MessageType.Warning);
        }

        if (motor.groundLayer == 0)
        {
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.HelpBox("Please assign the Ground Layer to 'Default' ", MessageType.Warning);
        }

        EditorGUILayout.BeginVertical();
        base.OnInspectorGUI();

        GUILayout.EndVertical();
        EditorGUILayout.EndVertical();

        EditorGUILayout.Space();
        EditorGUILayout.Space();
    }
示例#5
0
 public void Setup(HumanSheet humanSheetIn, bool isZombie, GameObject squadDeployment = null)
 {
     this.humanSheet = humanSheetIn;
     this.isZombie   = isZombie;
     animator        = transform.parent.GetComponent <Animator> ();
     stateMachine    = transform.parent.GetComponent <AnimationStateMachine> ();
     stateMachine.Setup(this);
     animationEvents = transform.parent.GetComponent <AnimationEvents> ();
     animationEvents.Setup(this);
     agent      = transform.parent.GetComponent <NavMeshAgent> ();
     navigation = GetComponent <AINavigation> ();
     navigation.Setup(showAgent);
     senses = GetComponent <AISenses> ();
     senses.Setup();
     vision = transform.parent.GetComponentInChildren <AIVision> ();
     vision.Setup(this, showVisionTargets, showNearVision, showMidVision, showFarVision);
     combat = GetComponent <AICombat> ();
     combat.Setup(this);
     if (isZombie)
     {
         //Debug.Log ("zombie perception : " + humanSheet.stats.perception);
         motor         = new ZombieMotor(this, transform.parent.GetComponent <Animator> ());
         behaviourTree = new BTZombie();
     }
     else
     {
         //Debug.Log ("swat perception : " + humanSheet.stats.perception);
         motor         = new HumanMotor(this, transform.parent.GetComponent <Animator> ());
         behaviourTree = new BTSwat();
     }
     behaviourTree.squadDeployment = squadDeployment;
     behaviourTree.Setup(humanSheet, this);
     //motor.UpdateAvatarMask ();
     agent.updatePosition = false;
     //agent.updateRotation = false;
     behaviourTree.StartTree();
 }
示例#6
0
 private void Start()
 {
     col   = GetComponent <SphereCollider>();
     anim  = GetComponent <Animator>();
     motor = GetComponent <AIMotor>();
 }
示例#7
0
 // Use this for initialization
 void Start()
 {
     motor = GetComponent <AIMotor>();
     anim  = GetComponent <Animator>();
 }