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


C# Projectile.giveDamage方法代码示例

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


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

示例1: hurt

 public void hurt(Projectile p)
 {
     base.blinkRed();
     health -= p.giveDamage();
     if(health <= 0)
         die(this.gameObject);
 }
开发者ID:TheFracker,项目名称:Wrahh,代码行数:7,代码来源:Lobster.cs

示例2: hurt

    //////////////////////////////////////
    // WRAHH TAKES DAMAGE				//
    //////////////////////////////////////
    public void hurt(Projectile p)
    {
        base.blinkRed();

        // The damage that Wrahh is about to take is kept in the damageTaken variable.
        // The damage is first takes away his armor, and then start to take Wrahh's health

        int damageTaken = p.giveDamage ();
        int damageToHelm = 0;
        int damageToSheild = 0;

        // If any armor is left, it will be lost first.
        while(damageTaken > 0 && (shieldArmor - damageToSheild > 0 || helmArmor - damageToHelm > 0))
        {
            int armorHit = Random.Range(0,10); // Randomly assings what part of Wrahh's armor takes a hit
            if(armorHit >= 4 && shieldOn &&shieldArmor - damageToSheild > 0)
                damageToSheild++;
            else if(helmOn && armorHit < 4 && helmArmor - damageToHelm > 0)
                damageToHelm++;
            else if (shieldOn && shieldArmor - damageToSheild > 0)
                damageToSheild++;
            else if (helmOn && helmArmor - damageToHelm > 0)
                damageToHelm++;
            if(helmOn && helmArmor - damageToHelm <= 0)
            {
                helm.Protection = 0;
                helm.upgradeProtection();
            }
            if(shieldOn && shieldArmor - damageToSheild <= 0)
            {
                shield.Protection = 0;
                shield.upgradeProtection();
            }
            damageTaken--;
        }

        shieldArmor -= damageToSheild;
        helmArmor -= damageToHelm;

        // Any damage left after the armor has been hit, if any armor left, will take away his health.
        // And if the health takes away the last of Wrahh's health, he will die, and the game will end.
        health -= damageTaken;
        if (health <= 0){
            die(this.gameObject); // Calls die from GameCharacters class
        }
    }
开发者ID:TheFracker,项目名称:Wrahh,代码行数:49,代码来源:Wrahh.cs


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