Ejemplo n.º 1
0
    void Awake()
    {
        // Get all movement behaviours enemy has so that they can be stopped and resumed
        // IF A CHILD OBJECT OF ENEMY IS HANDLING THE SHOOTING, THERE SHOULD BE NO NEED TO STOP TO SHOOT
        // THE ANIMATION TO BE PLAYED TO INDICATE SHOOTING IS SEPARATE FROM MAIN ENEMY OBJECT AND SO ENEMY CAN SHOOT AND MOVE AT SAME TIME
        // STOP TO SHOOT SHOULD ONLY BE IF ENEMY ITSELF IS HANDLING THE SHOOTING WHICH WOULD NORMALLY REQUIRE ENEMY TO STOP MOVING AND PLAY THE SHOOTING ANIMATION
        movementBehaviours = GetComponents <StoppableMovementBehaviour>();

        view = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerInView>();
        anim = GetComponent <Animator>();

        foreach (Transform child in transform)
        {
            if (child.tag == "SpawnPos")
            {
                spawnPos = child;
            }
        }

        projectilePool = new List <GameObject>();
        for (int i = 0; i < poolNum; i++)
        {
            projectilePool.Add(Instantiate(shootBehaviour.projectilePrefab, Vector3.down * 50, Quaternion.identity));
            projectilePool[i].SetActive(false);
        }
    }
Ejemplo n.º 2
0
 void Awake()
 {
     anim        = GetComponent <Animator>();
     lastTrigger = Time.time + 2f;
     view        = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerInView>();
     shoot       = GetComponent <ShootFixed>();
 }
Ejemplo n.º 3
0
    void Awake()
    {
        player   = GameObject.FindGameObjectWithTag("Player");
        playerHP = player.GetComponent <PlayerHP>();
        view     = player.GetComponent <PlayerInView>();

        anim = GetComponent <Animator>();
    }
Ejemplo n.º 4
0
    bool playerInView;             // Must be in camera view and within distance to be in view (InView and InDistance)

    void Awake()
    {
        player   = GameObject.FindGameObjectWithTag("Player");
        playerHP = player.GetComponent <PlayerHP>();
        view     = player.GetComponent <PlayerInView>();

        nextPos       = posB;
        enemyDefaults = GetComponent <EnemyDefaults>();
        anim          = GetComponent <Animator>();
        rb            = GetComponent <Rigidbody2D>();
    }
Ejemplo n.º 5
0
    void Awake()
    {
        gravity       = -1f * gravityScale;
        collisionMask = LayerMask.GetMask("Ground");

        enemyDefaults = GetComponent <EnemyDefaults>();
        anim          = GetComponent <Animator>();

        player   = GameObject.FindGameObjectWithTag("Player");
        playerHP = player.GetComponent <PlayerHP>();
        view     = player.GetComponent <PlayerInView>();
    }
Ejemplo n.º 6
0
    void Awake()
    {
        collisionMask = LayerMask.GetMask("Ground");

        player       = GameObject.FindGameObjectWithTag("Player");
        playerHP     = player.GetComponent <PlayerHP>();
        playerInView = player.GetComponent <PlayerInView>();

        enemyDefaults = GetComponent <EnemyDefaults>();
        anim          = GetComponent <Animator>();

        nextPos = posB;
    }
Ejemplo n.º 7
0
    bool moveWhileFacing;   // Either move while facing player or stop movement and only face player

    void Awake()
    {
        player   = GameObject.FindGameObjectWithTag("Player");
        playerHP = player.GetComponent <PlayerHP>();
        view     = player.GetComponent <PlayerInView>();

        movement = GetComponent <StoppableMovementBehaviour>();
        anim     = GetComponent <Animator>();

        // Shoot behaviour must either be in main enemy object which this script is attached to or in child object
        shootBehaviourScript = GetComponentInChildren <ShootBehaviour>();
        // Do not shoot until aggro'd
        if (shootBehaviourScript != null)
        {
            shootBehaviourScript.enabled = false;
        }
    }
Ejemplo n.º 8
0
    void Awake()
    {
        facePlayer = true;
        player     = GameObject.FindGameObjectWithTag("Player");
        view       = player.GetComponent <PlayerInView>();
        anim       = GetComponent <Animator>();

        foreach (Transform child in transform)
        {
            if (child.tag == "SpawnPos")
            {
                spawnPos = child;
            }
        }

        projectilePool = new List <GameObject>();
        for (int i = 0; i < poolNum; i++)
        {
            projectilePool.Add(Instantiate(shootBehaviour.projectilePrefab, Vector3.down * 50, Quaternion.identity));
            projectilePool[i].SetActive(false);
        }
    }
Ejemplo n.º 9
0
 void Awake()
 {
     view = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerInView>();
 }