Esempio n. 1
0
 void Weapon(MonsterHealth monsterHealth)
 {
     if (monsterHealth != null)
     {
         monsterHealth.TakeDamage(lightDamage);
     }
 }
    void OnTriggerEnter(Collider other)
    {
        GameObject otherobj = other.gameObject;

        if (otherobj.tag == EnemyTag || otherobj.tag == BossTag)
        {
            Debug.Log("Deal Damage");

            otherobj.GetComponent <MonsterHealth>().TakeDamage(20);

            Vector3 damageSystemPosition = Vector3.zero;
            damageSystemPosition.y += .5f;

            GameObject damageSystem = (GameObject)Instantiate(damageObject);
            damageSystem.transform.parent = otherobj.transform;

            damageSystem.transform.localPosition = damageSystemPosition;
            damageSystem.transform.localScale    = new Vector3(1, 1, 1);

            MonsterHealth health = otherobj.GetComponent <MonsterHealth>();
            if (health != null)
            {
                health.TakeDamage(damage * damageMultiplier);
            }
        }
    }
Esempio n. 3
0
    public override void Attack()
    {
        print("Shoot shotgun");

        //shotgun has larger hit range
        Ray rayCenter = _camera.ScreenPointToRay(Input.mousePosition);
        Ray rayLeft   = _camera.ScreenPointToRay(new Vector3(_camera.pixelWidth * 9 / 20, _camera.pixelWidth / 2, 0));
        Ray rayRight  = _camera.ScreenPointToRay(new Vector3(_camera.pixelWidth * 11 / 20, _camera.pixelWidth / 2, 0));
        Ray rayUp     = _camera.ScreenPointToRay(new Vector3(_camera.pixelWidth / 2, _camera.pixelWidth * 9 / 20, 0));
        Ray rayDown   = _camera.ScreenPointToRay(new Vector3(_camera.pixelWidth / 2, _camera.pixelWidth * 11 / 20, 0));

        RaycastHit hit;

        if (Physics.Raycast(rayCenter, out hit) ||
            Physics.Raycast(rayLeft, out hit) ||
            Physics.Raycast(rayRight, out hit) ||
            Physics.Raycast(rayUp, out hit) ||
            Physics.Raycast(rayDown, out hit))
        {
            GameObject obj = hit.transform.gameObject;
            if (Array.IndexOf(enemies, obj) != -1)
            {
                print("hit");
                monsterHealth = obj.GetComponent <MonsterHealth> ();
                monsterHealth.TakeDamage(shotgunDamage);
            }
        }
    }
Esempio n. 4
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        MonsterHealth MH = collision.GetComponent <MonsterHealth>();

        if (MH != null)
        {
            MH.TakeDamage(damage);
            Destroy(gameObject);
        }
    }
Esempio n. 5
0
	void OnTriggerEnter(Collider other) {
		if (mHealth.health > 0) {
			if (other.tag == "monster") {
				monsterHealth = other.gameObject.GetComponent<MonsterHealth> (); 
				monsterHealth.TakeDamage (30);
			}

			if (other.tag == "boss") {
				bossHealth = other.gameObject.GetComponent<BossHealth> (); 
				bossHealth.TakeDamage (30);
			}
		}

		//Destroy(other.gameObject);
	}
Esempio n. 6
0
    public override void Attack()
    {
        if (timer > timeBetweenAttacks)
        {
            timer = 0;
            Ray ray = _camera.ScreenPointToRay(Input.mousePosition);

            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                GameObject obj = hit.transform.gameObject;
                if (Array.IndexOf(enemies, obj) != -1)
                {
                    print("hit");
                    monsterHealth = obj.GetComponent <MonsterHealth> ();
                    monsterHealth.TakeDamage(pistolDamage);
                }
            }
        }
    }
Esempio n. 7
0
    void OnTriggerEnter(Collider other)
    {
        GameObject otherObject = other.gameObject;

        if (isEnemy(otherObject))
        {
            Vector3 damageSystemPosition = Vector3.zero;
            damageSystemPosition.y += .5f;

            GameObject damageSystem = (GameObject)Instantiate(damageObject);
            damageSystem.transform.parent = otherObject.transform;

            damageSystem.transform.localPosition = damageSystemPosition;
            damageSystem.transform.localScale    = new Vector3(1, 1, 1);

            MonsterHealth health = otherObject.GetComponent <MonsterHealth>();
            if (health != null)
            {
                health.TakeDamage(damage * damageMultiplier);
            }
        }
    }
    void DealDamage()
    {
        foreach (GameObject enemy in enemyTargetList)
        {
            //deal damge
            Debug.Log("Deal Damage");
            enemy.GetComponent <MonsterHealth>().TakeDamage(18);
            Vector3 damageSystemPosition = Vector3.zero;
            damageSystemPosition.y += .5f;

            GameObject damageSystem = (GameObject)Instantiate(damageObject);
            damageSystem.transform.parent = enemy.transform;

            damageSystem.transform.localPosition = damageSystemPosition;
            damageSystem.transform.localScale    = new Vector3(1, 1, 1);

            MonsterHealth health = enemy.GetComponent <MonsterHealth>();
            if (health != null)
            {
                health.TakeDamage(damage * damageMultiplier);
            }
        }
    }