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


C# Unit.getDamage方法代码示例

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


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

示例1: Update

 // Update is called once per frame
 public virtual void Update(Unit unit)
 {
     //If unit has arrived at destination then stop it
     float distance = Vector3.Distance(unit.getDestination(), unit.transform.position);
     if (distance < stoppingDistance) {
         unit.GetComponent<NavMeshAgent>().destination = unit.transform.position;
         unit.setDestination (unit.transform.position);
         unit.changeState (new Idle());
     }
     if (unit.GetComponent<NavMeshAgent>().nextPosition == unit.getDestination ()) {
         unit.GetComponent<NavMeshAgent>().updatePosition = false;
     }
     /* COMBAT (DRIVEBY STYLE) */
     foreach (Collider enemy in Physics.OverlapSphere (unit.transform.position, unit.getRange(),1<<10)){
         Unit enemyUnit = enemy.GetComponent<Unit>();
         if (enemyUnit != null && unit.team != enemyUnit.team){ // cant we all just get along?
             unit.lookAtPos(enemyUnit.transform.position);
             if(unit.canFire ()){
                 enemyUnit.GetComponent<Health>().applyDamage(unit.getDamage());
                 unit.resetCooldown ();
                 unit.drawAttack(unit,enemyUnit, unit.renderer.material.color);
             }
             break;
         }
     }
 }
开发者ID:schabou,项目名称:MobileRTS,代码行数:27,代码来源:Moving.cs

示例2: BasicAttack

 protected override void BasicAttack(Unit actionInvokerUnit, Unit actionTargetUnit)
 {
     Debug.Log("Target: " + actionTargetUnit.getUnitName() + actionTargetUnit.getIsOpponent()
               + "\n Initial Health: " + actionTargetUnit.getHealth());
     actionTargetUnit.setHealth(actionTargetUnit.getHealth() - actionInvokerUnit.getDamage() - 20);
     Debug.Log("Final Health: " + actionTargetUnit.getHealth());
 }
开发者ID:ChristopherElten,项目名称:1GAM-August,代码行数:7,代码来源:UFOShip.cs

示例3: Update

 // Update is called once per frame
 public virtual void Update(Unit unit)
 {
     // if target has died
     if (unit.getTarget() == null || unit.getTarget().GetComponent<Health>().currentHealth <= 0){
         unit.setTarget(null);
         unit.setDestination(Vector3.zero);
         unit.GetComponent<NavMeshAgent>().updatePosition = false;
         unit.changeState (new Idle());
         return;
     }
     // else, if enemy still alive
     Unit lastEnemy = null;
     bool inRange = false;
     foreach (Collider enemy in Physics.OverlapSphere (unit.transform.position, unit.getRange(),1<<10)){
         Unit enemyUnit = enemy.GetComponent<Unit>();
         if (enemyUnit != null && unit.team != enemyUnit.team){
             lastEnemy = enemyUnit;
             if (enemyUnit == unit.getTarget()){
                 inRange = true;
                 unit.setDestination (Vector3.zero);
                 unit.GetComponent<NavMeshAgent>().updatePosition = false;
                 // attack target unit
                 unit.lookAtPos(enemyUnit.transform.position);
                 if(unit.canFire ()){
                     enemyUnit.GetComponent<Health>().applyDamage(unit.getDamage());
                     unit.resetCooldown ();
                     unit.drawAttack(unit,enemyUnit, unit.renderer.material.color);
                 }
                 break;
             }
         }
     }
     if (!inRange){
         // for now, it finds a path every update. this will be fixed in future
         unit.GetComponent<NavMeshAgent>().destination = unit.getTarget ().transform.position;
         unit.setDestination(unit.getTarget ().transform.position);
         unit.GetComponent<NavMeshAgent>().updatePosition = true;
         if (lastEnemy != null){ // not in range of target, but in range of another enemy
             unit.lookAtPos(lastEnemy.transform.position);
             if(unit.canFire ()){
                 lastEnemy.GetComponent<Health>().applyDamage(unit.getDamage());
                 unit.resetCooldown ();
                 unit.drawAttack(unit,lastEnemy, unit.renderer.material.color);
             }
         }
     }
 }
开发者ID:schabou,项目名称:MobileRTS,代码行数:48,代码来源:Attacking.cs

示例4: BasicAttack

    protected override void BasicAttack(Unit actionInvokerUnit, Unit actionTargetUnit)
    {
        numberOfAttacks++;
        //Check for achievement
        if (numberOfAttacks == 2){
            GameEvent achievementEvent = new GameEvent(new Achievement("2 attacks performed!"));
            notifyObserver(achievementEvent);
        }

        Debug.Log("Target: " + actionTargetUnit.getUnitName() + actionTargetUnit.getIsOpponent()
                  + "\n Initial Health: " + actionTargetUnit.getHealth());
        actionTargetUnit.setHealth(actionTargetUnit.getHealth() - actionInvokerUnit.getDamage() - 80);
        Debug.Log("Final Health: " + actionTargetUnit.getHealth());
    }
开发者ID:ChristopherElten,项目名称:1GAM-August,代码行数:14,代码来源:RocketShip.cs

示例5: Update

 // Update is called once per frame
 public virtual void Update(Unit unit)
 {
     /* COMBAT (HOLD POSITION STYLE) */
     foreach (Collider enemy in Physics.OverlapSphere (unit.transform.position, unit.getRange(),1<<10)){
         Unit enemyUnit = enemy.GetComponent<Unit>();
         if (enemyUnit != null && unit.team != enemyUnit.team){ // cant we all just get along?
             unit.lookAtPos(enemyUnit.transform.position);
             if(unit.canFire ()){
                 enemyUnit.GetComponent<Health>().applyDamage(unit.getDamage());
                 unit.resetCooldown ();
                 unit.drawAttack(unit,enemyUnit, unit.renderer.material.color);
             }
             break;
         }
     }
 }
开发者ID:schabou,项目名称:MobileRTS,代码行数:17,代码来源:Idle.cs


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