Beispiel #1
0
 void Start()
 {
     eai    = this.GetComponent <EnemyAI> ();
     player = GameObject.FindGameObjectWithTag("Player");
     sc     = GameObject.FindGameObjectWithTag("GameController").GetComponent <SpriteContainer>();
     sr     = this.GetComponent <SpriteRenderer> ();
     ea     = this.GetComponent <EnemyAnimate>();
 }
    // Use this for initialization
    void Start()
    {
        Scene currentScene = SceneManager.GetActiveScene();

        sceneName = currentScene.name;
        eai       = this.GetComponent <EnemyAI> ();
        player    = GameObject.FindGameObjectWithTag("Player");
        sr        = this.GetComponent <SpriteRenderer> ();
        sc        = GameObject.FindGameObjectWithTag("GameController").GetComponent <SpriteContainer> ();
        ea        = this.GetComponent <EnemyAnimate> ();
        Boss      = GameObject.Find("Mirtha");
    }
Beispiel #3
0
    public void attack()
    {
        pa.attack();
        if (gun == true)
        {
            pa.attack();
            Bullet  bl = bullet.GetComponent <Bullet> ();
            Vector3 dir;
            dir.x = Vector2.right.x;
            dir.y = Vector2.right.y;
            dir.z = 0;
            bl.setVals(dir, "Player");
            if (oneHanded == true)
            {
                Instantiate(bullet, oneHandSpawn.transform.position, this.transform.rotation);
                //Instantiate(muzzleFlash, oneHandSpawn.transform.position, this.transform.rotation);
            }
            else
            {
                Instantiate(bullet, twoHandSpawn.transform.position, this.transform.rotation);
                // Instantiate(muzzleFlash, oneHandSpawn.transform.position, this.transform.rotation);
            }
            timer = timerReset;
        }
        else
        {
            //melee attack
            int layerMask = 1 << 9;
            layerMask = ~layerMask;
            pa.attack();

            RaycastHit2D ray = Physics2D.Raycast(new Vector2(this.transform.position.x, this.transform.position.y), new Vector2(transform.right.x, transform.right.y), 0.5f, layerMask);
            Debug.DrawRay(new Vector2(this.transform.position.x, this.transform.position.y), new Vector2(transform.right.x, transform.right.y), Color.green);

            if (curWeapon == null && ray.collider.gameObject.tag == "Enemy")
            {
                EnemyAnimate ea = ray.collider.gameObject.GetComponent <EnemyAnimate>();
                ea.knockDownEnemy();
            }
            else if (ray.collider != null)
            {
                if (ray.collider.gameObject.tag == "Enemy")
                {
                    EnemyAnimate ea = ray.collider.GetComponent <EnemyAnimate>();
                    ea.killMelee();
                }
            }
        }
    }
Beispiel #4
0
 void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.tag == "Enemy")
     {
         attacked = col.gameObject.GetComponent <EnemyAnimate>();
         attacked.killBullet();
         Instantiate(bloodImpact, this.transform.position, this.transform.rotation);
         Destroy(this.gameObject);
     }
     else
     {
         Instantiate(wallImpact, this.transform.position, this.transform.rotation);
         Destroy(this.gameObject);
     }
 }
Beispiel #5
0
 void OnTriggerEnter2D(Collider2D col)
 {
     if (col.gameObject.tag == "Enemy")
     {
         attacked = col.gameObject.GetComponent <EnemyAnimate>();
         attacked.knockDownEnemy();
         rid.isKinematic = true;
         Destroy(this);
     }
     else if (col.gameObject.tag == "Player")
     {
     }
     else
     {
         rid.isKinematic = true;
         Destroy(this);
     }
 }