Exemple #1
0
    void Start()
    {
        Player_script     = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>();
        Player_xyz        = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>();
        Projectile_script = projectile.GetComponent <Enemy_Projectile>();
        Enemy_sprite      = GetComponent <SpriteRenderer>();
        Enemy_xyz         = GetComponent <Transform>();
        anim = GetComponent <Animator>();

        //Activate IEnumerator fireShot()
        StartCoroutine(fireShot());
    }
Exemple #2
0
    void OnTriggerEnter2D(Collider2D otherCollider)
    {
        // Is this a shot?
        Enemy_Projectile shot = otherCollider.gameObject.GetComponent <Enemy_Projectile>();

        if (shot != null)
        {
            Damage(shot.damage); //inflict damage

            // Destroy the shot
            Destroy(shot.gameObject); // Remember to always target the game object, otherwise you will just remove the script
        }
    }
Exemple #3
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        // Is this a shot?
        Enemy_Projectile shot = collision.gameObject.GetComponent <Enemy_Projectile>();

        if (shot != null)
        {
            TakeDamage(shot.damage);  //inflict damage
            // Destroy the shot
            Destroy(shot.gameObject); // Remember to always target the game object, otherwise you will just remove the script
        }

        if ((collision.CompareTag("Enemy")) && !GetComponent <playerControl>().sPress)
        {
            if (!GetComponent <playerControl>().hasDashBomb || !GetComponent <airDash>().airDashingCurrently)
            {
                TakeDamage(1);
            }
        }
    }
Exemple #4
0
        void CreateProjectile()
        {
            Vector3 newPosition;

            if (_guardian.facingRight == true)
            {
                newPosition = _guardian.transform.position + new Vector3(1f, 0, 0);
                _guardian.rigidbody2D.AddForce(new Vector2(25000f, 0f));
            }
            else
            {
                newPosition = _guardian.transform.position - new Vector3(1f, 0, 0);
                _guardian.rigidbody2D.AddForce(new Vector2(-25000f, 0f));
            }
            GameObject       proj       = (GameObject)Instantiate(_guardian.meleeAttackPrefab, newPosition, Quaternion.identity);
            Enemy_Projectile projScript = proj.GetComponent <Enemy_Projectile> ();

            projScript.DMG         = _guardian.meleeDamage;
            projScript.facingRight = _guardian.facingRight;
        }