Inheritance: MonoBehaviour
コード例 #1
0
ファイル: Entity.cs プロジェクト: ly774508966/AI-Companion
    // Use this for initialization
    public virtual void Start()
    {
        AddType(EntityType.Entity);

        dead = false;

        pathRequested = false;
        isOnPath      = false;

        health      = startingHealth;
        medKits     = 0;
        seenMedKits = new Dictionary <string, Vector3>();

        blackboard = new Blackboard();
        blackboard.treeData.Add("entity", this);

        col = transform.GetComponentInChildren <SphereCollider>();

        grid = GameObject.Find("GameController").GetComponent <Grid>();
        eyes = GetComponentInChildren <AISight>();

        enemiesInLevel = new List <GameObject>();

        foreach (Entity entity in GameController.gameController.entitiesInLevel) //Check entities in the level against this AI's enemy type
        {
            if (((1 << entity.gameObject.layer) & enemiesMask) != 0)
            {
                enemiesInLevel.Add(entity.gameObject);
            }
        }
    }
コード例 #2
0
ファイル: DefendState.cs プロジェクト: fefete/AStarAI
    // Use this for initialization
    void Start()
    {
        aiUnit_  = this.GetComponent <AIUnit>();
        aiSight_ = aiSight_.GetComponent <AISight>();

        subState = SubState.Empty;
    }
コード例 #3
0
ファイル: moveTo.cs プロジェクト: propredator23/CPI211_Team9
 //init vars
 void Start()
 {
     agent           = GetComponent <NavMeshAgent>();
     selfSight       = GetComponent <AISight>();
     player          = GameObject.FindGameObjectsWithTag("Player");//player reference
     playerPos       = player[0].transform;
     lastPlayerSight = playerPos;
 }
コード例 #4
0
ファイル: AIPersonality.cs プロジェクト: mrradd/Tanxz
    /****************************************************************************
    * Unity Methods
    ****************************************************************************/
    /****************************************************************************
     * Awake */
    /**
     ****************************************************************************/
    protected virtual void Awake()
    {
        /** Make sure the tank can see. */
        if (aiSight == null)
        {
            aiSight = gameObject.GetComponent <AISight>();
        }

        /** Set Layer Mask. */
        mLayerMask = 1 << LayerMask.NameToLayer("Interractive");
    }
コード例 #5
0
ファイル: CaptureState.cs プロジェクト: fefete/AStarAI
    // Use this for initialization
    void Start()
    {
        aiUnit_  = this.GetComponent <AIUnit>();
        aiSight_ = aiSight_.GetComponent <AISight>();

        retreating_ = false;

        //Get Path to Flag
        aiUnit_.getNewPath(aiUnit_.startNode, aiUnit_.targetNode);

        subState = SubState.Capturing;
    }
コード例 #6
0
ファイル: EnemyAI.cs プロジェクト: operskaas/VirtualBall
    void Awake()
    {
        nav     = GetComponent <UnityEngine.AI.NavMeshAgent> ();
        aiSight = GetComponent <AISight> ();
        globalLastPlayerSighting = GameObject.FindGameObjectWithTag("GameController").GetComponent <GlobalLastPlayerSighting> ();
        if (team == "Team0")
        {
            enemyTeam = "Team1";
        }
        else
        {
            enemyTeam = "Team0";
        }

        //enemyTeamMembers = GameObject.FindGameObjectsWithTag("GameController").
    }
コード例 #7
0
    private void Awake()
    {
        // get the components on the object we need ( should not be null due to require component so no need to check )
        agent     = GetComponentInChildren <NavMeshAgent>();
        character = GetComponent <ThirdPersonCharacter>();
        player    = FindObjectOfType <ThirdPersonUserControl>();
        _aiSight  = GetComponentInChildren <AISight>();

        _noiseScript = GameObject.FindGameObjectWithTag("NoiseBar").GetComponent <Noise>();
        var mechanicsObj = GameObject.FindWithTag("MechanicsObject");

        micInput = mechanicsObj.GetComponent <MicrophoneInput>();
        _hideFromWitchCooldownTarget = mechanicsObj.GetComponent <WitchKeepStill>().keepStillDuration;
        _witchScript = mechanicsObj.GetComponent <WitchKeepStill>();

        _aiSight.aiController = this;
    }
コード例 #8
0
    // Use this for initialization
    public override void Awake()
    {
        base.Awake();
        target             = GameObject.FindGameObjectWithTag("Player");
        _platformMask      = SetMask();
        targetRb2d         = target.GetComponent <Rigidbody2D>();
        _startingPos       = transform.position;
        _amps_sound        = GetComponent <AudioSource>();
        _lastAttackTime    = 0;
        _attackAniDuration = 0;
        _lastHitTime       = 0;
        _lastPatrolTime    = 0;
        waiting            = false;
        var movement = new Vector2(-1 * acceleration * rb2d.mass, 0);

        rb2d.AddForce(movement, ForceMode2D.Force);
        patrolPointMin = new Vector2(this.transform.position.x - patrolDistance, this.transform.position.y);
        patrolPointMax = new Vector2(this.transform.position.x + patrolDistance, this.transform.position.y);
        _buddyMask     = LayerMask.GetMask("Enemy");
        _sight         = new AISight(gameObject.GetComponentInChildren <CapsuleCollider2D>(), sightRange);
    }
コード例 #9
0
    void OnSceneGUI()
    {
        AISight ai_sight = (AISight)target;

        Handles.color = Color.white;
        Handles.DrawWireArc(ai_sight.transform.position, Vector3.up, Vector3.forward, 360, ai_sight.view_radius);
        Vector3 view_angle_a = ai_sight.DirectionFromAngle(-ai_sight.view_angle / 2, false);
        Vector3 view_angle_b = ai_sight.DirectionFromAngle(ai_sight.view_angle / 2, false);

        Handles.DrawLine(ai_sight.transform.position, ai_sight.transform.position + view_angle_a * ai_sight.view_radius);
        Handles.DrawLine(ai_sight.transform.position, ai_sight.transform.position + view_angle_b * ai_sight.view_radius);

        Handles.color = Color.red;
        foreach (GameObject visible_target in ai_sight.visible_targets)
        {
            Handles.DrawLine(ai_sight.transform.position, visible_target.transform.position);
        }

        Handles.color = Color.green;
        foreach (Transform visible_cover_pos in ai_sight.visible_cover_positions)
        {
            Handles.DrawLine(ai_sight.transform.position, visible_cover_pos.position);
        }
    }
コード例 #10
0
 public override void Init(Blackboard blackboard)
 {
     this.blackboard = blackboard;
     eyes            = blackboard.GetValueFromKey <AISight>("eyes");
     entity          = eyes.transform.parent.GetComponent <Entity>();
 }
コード例 #11
0
 public override void Init(Blackboard blackboard)
 {
     this.blackboard = blackboard;
     companion       = blackboard.GetValueFromKey <Companion>("companion");
     eyes            = companion.GetComponentInChildren <AISight>();
 }
コード例 #12
0
 public override void Init(Blackboard blackboard)
 {
     this.blackboard = blackboard;
     entity          = blackboard.GetValueFromKey <Entity>("entity");
     eyes            = entity.GetComponentInChildren <AISight>();
 }