本文整理汇总了C#中Unit.drawAttack方法的典型用法代码示例。如果您正苦于以下问题:C# Unit.drawAttack方法的具体用法?C# Unit.drawAttack怎么用?C# Unit.drawAttack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Unit
的用法示例。
在下文中一共展示了Unit.drawAttack方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
}
示例2: 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);
}
}
}
}
示例3: 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;
}
}
}