当前位置: 首页>>代码示例>>C#>>正文


C# EnemyHealth.TakeDamage方法代码示例

本文整理汇总了C#中EnemyHealth.TakeDamage方法的典型用法代码示例。如果您正苦于以下问题:C# EnemyHealth.TakeDamage方法的具体用法?C# EnemyHealth.TakeDamage怎么用?C# EnemyHealth.TakeDamage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EnemyHealth的用法示例。


在下文中一共展示了EnemyHealth.TakeDamage方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnCollisionEnter

 void OnCollisionEnter(Collision col)
 {
     if(col.gameObject.tag == "Zombie")
     {
         enemy = col.gameObject;
         enemyHealth = col.gameObject.GetComponent<EnemyHealth>();
         enemyHealth.TakeDamage(Damage);
         GameObject bloodSplat = (GameObject)Instantiate(BloodSplat, col.transform.position + Vector3.up * 1.5f, col.transform.rotation);
         Destroy(bloodSplat, 1f);
     }
     DestroyBullet();
 }
开发者ID:darinav,项目名称:ShooterSample,代码行数:12,代码来源:BulletControl.cs

示例2: OnTriggerEnter2D

 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag == "Enemy")
     {
         Debug.Log("Bullet entered a collider");
         enemyHealth = other.GetComponent<EnemyHealth>();
         enemyHealth.TakeDamage(amount);
         Destroy(gameObject);
     }
     if (other.gameObject.tag == "Ground")
         Destroy(gameObject);
 }
开发者ID:jesusdrodriguez,项目名称:Monster_Survival,代码行数:12,代码来源:Bullet.cs

示例3: OnTriggerEnter

 void OnTriggerEnter(Collider other)
 {
     //enemy = GameObject.FindGameObjectWithTag("Enemy");
     if (other.gameObject.tag == "Enemy")
     {
         enemy = other.gameObject;
         enemyHealth = enemy.GetComponent<EnemyHealth>();
         if (enemyHealth != null)
         {
             enemyHealth.TakeDamage(damage);
         }
     }
 }
开发者ID:Unityprojektgruppe2,项目名称:Unity-Project---Group-2-NEW,代码行数:13,代码来源:WeaponAttack.cs

示例4: OnTriggerEnter2D

	void OnTriggerEnter2D(Collider2D other){
		if((other.gameObject.tag == "Enemy" && count == 0))
		{
			enemyHealth = other.gameObject.GetComponent<EnemyHealth>();
			//APPLYING DAMAGE TO ENEMY
			enemyHealth.TakeDamage(batonDamage);
			count++;
			
			GetComponent<AudioSource>().Play();
			
		}
		
	}
开发者ID:AJ56321,项目名称:Mall-Brawl-v2,代码行数:13,代码来源:BatonAttack.cs

示例5: Awake

    //public bool rocket = false;
    void Awake()
    {
        RaycastHit hit;
        if(Physics.Raycast(transform.position, transform.forward,out hit, maxDist))
        {
            if(hit.transform.tag == "Enemies" )
            {
                Debug.Log("BULLET HAS HIT");
                enemyHealth = hit.transform.GetComponent<EnemyHealth>();
                enemyHealth.TakeDamage(damage, hit.point);
                Destroy(gameObject);

            }
        }

        Destroy(gameObject);
    }
开发者ID:StevenCoverdale,项目名称:Zombies-Guns-Explosions,代码行数:18,代码来源:Bullet.cs

示例6: Attack

 void Attack()
 {
     //Debug.Log ("turn: " + turnController.playerTurn);
     if (turnController.giveBonus == false) {
         turnController.BeginTurn();
     }
     turnController.giveBonus = true;
     endTurnButton.onClick.AddListener (() => turnController.pressButton = true);
     if (turnController.playerTurn == 1 && turnController.pressButton == true) {
         GameObject enemy = GameObject.FindGameObjectWithTag ("Enemy");
         enemyHealth = enemy.GetComponent<EnemyHealth> ();
         if (enemyHealth.currentHealth > 0) {
             enemyHealth.TakeDamage (attackPoint);
         }
         turnController.giveBonus = false;
         turnController.EndTurn();
     }
 }
开发者ID:Nephilim314,项目名称:GameRepo,代码行数:18,代码来源:PlayerAttack.cs

示例7: OnTriggerEnter

    void OnTriggerEnter(Collider collision)
    {
        enemyHealth = collision.gameObject.GetComponent<EnemyHealth> ();

        switch (attackType) {
        case AttackType.AOEAttack:
            Debug.Log ("AOE Attack!");
            if (collision.gameObject.tag == "Enemy") {
                Rigidbody enemy = collision.gameObject.GetComponentInChildren<Rigidbody> ();
                Vector3 force = enemy.position - weaponCollider.transform.position;
                force.Normalize ();
                force *= AOEPower;
                enemy.AddForce (force, ForceMode.Impulse);
                enemyHealth.TakeDamage(5);

                //SFX
                soundManager.spinHitSound();
            }
            break;
        case AttackType.meleeAttack:
            Debug.Log ("PUNCH!");
            if (collision.gameObject.tag == "Enemy") {
                Rigidbody enemy = collision.gameObject.GetComponentInChildren<Rigidbody> ();
                Vector3 force = attackVector;
                force.Normalize ();
                force *= meleePower;
                enemy.AddForce (force, ForceMode.Impulse);
                enemyHealth.TakeDamage(10);

                //SFX
                soundManager.punchHitSound();
            }
            break;
        }
    }
开发者ID:samueltrussell,项目名称:Fowl-Situation,代码行数:35,代码来源:WeaponHandler.cs

示例8: TakeAttack

    public void TakeAttack()
    {
        state = animator.GetCurrentAnimatorStateInfo(0);
        bool inRightState = false;
        foreach (string attackName in attackNames)
        {
        //			Debug.Log(attackName);
            if (state.IsName(attackName))
            {
                inRightState = true;
                break;
            }
        }

        if (!inRightState)
        {
            return;
        }

        foreach (GameObject enemy in contactGameObjects)
        {
            enemyHealth = enemy.GetComponent <EnemyHealth>();

            if (enemyHealth != null && enemyHealth.currentHealth > 0)
            {
                if (state.IsName("attack05"))
                {
                    Time.timeScale = 0.1f;
                    animator.SetFloat("AnimationSpeed", 0f);
                    StartCoroutine("resetAnimationSpeed");
                }
                else
                {
                    animator.SetFloat("AnimationSpeed", 1f);
                }

                playerMovement.ChangeDirection(enemy.transform.position - player.transform.position);

                enemyHealth.TakeDamage(10, Vector3.zero, m_attackType, player.transform.position);
            }
        }
    }
开发者ID:wangwuyi,项目名称:ChuLiuXiangVsBadman,代码行数:42,代码来源:AttackElement.cs


注:本文中的EnemyHealth.TakeDamage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。