本文整理汇总了C#中EnemyController.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# EnemyController.GetComponent方法的具体用法?C# EnemyController.GetComponent怎么用?C# EnemyController.GetComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EnemyController
的用法示例。
在下文中一共展示了EnemyController.GetComponent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AttackLogic
public Vector3 AttackLogic(EnemyController enemy, GameObject player)
{
// Start firing if timer has elapsed & player is in aggro range
if (LMHelper.CheckAttackTimer(enemy) && LMHelper.CanShoot(enemy, player))
{
enemy.GetComponent<WeaponBackpackController>().StartFiring();
}
else
{
enemy.GetComponent<WeaponBackpackController>().StopFiring();
}
//Face the player
Vector3 facing = LMHelper.BaseMoveLogic(enemy, player);
//Offset slightly since gun is off-center
Vector3 perp = Vector3.Cross(facing, new Vector3(0f, 1f, 0f)); //left perpendicular
facing = (facing + perp * 0.05f);
facing.Normalize();
return facing;
}
示例2: DamageCoRoutine
IEnumerator DamageCoRoutine(Vector2 direction, EnemyController enemy)
{
yield return null;
if (gravDirection == 0 || gravDirection == 2)
rb.velocity = new Vector2 (-direction.x * (enemy.GetComponent<Rigidbody2D> ().velocity.x < 0 ? enemy.speed : -enemy.speed) * 10, isGrounded ? 0 : gravDirection == 0 ? direction.y * enemyHitVerticalVelocity : -direction.y * enemyHitVerticalVelocity);
else
rb.velocity = new Vector2 (isGrounded ? 0 : gravDirection == 1 ? -direction.x * enemyHitVerticalVelocity : direction.x * enemyHitVerticalVelocity, -direction.y * (enemy.GetComponent<Rigidbody2D>().velocity.y < 0 ? enemy.speed : -enemy.speed) * 10);
yield return new WaitForSeconds (kickbackTime);
rb.velocity = new Vector2 (0, rb.velocity.y);
kickback = false;
yield return new WaitForSeconds (damageDelay - kickbackTime);
isHit = false;
Debug.Log ("isHit reset");
/*yield return null;
yield return new WaitForSeconds (hitKickbackTime);
kickback = false;
yield return new WaitForSeconds (damageDelay - attackKickback);
isHit = false;*/
}
示例3: runEffect
void runEffect(EnemyController enemy)
{
switch (state.effectType)
{
#region BURN
case EBulletEffect.BURN:
bool hasEffect = false;
foreach (Transform child in enemy.transform)
{
if (child.name == PlayNameHashIDs.BulletEffectBurning)
{
hasEffect = true;
Animator animator = child.GetComponentInChildren<Animator>();
animator.SetBool("Loop", true);
animator.SetBool("Finish", false);
child.GetComponent<BulletEffectController>().reset = true;
break;
}
}
if (!hasEffect)
{
string[] values = (string[])state.effectValue;
BulletEffectManager.Instance.initEffect(EBulletEffect.BURN, enemy.gameObject,
float.Parse(values[0]), int.Parse(values[1]), float.Parse(values[2]));
}
break;
#endregion
#region SLOW
case EBulletEffect.SLOW:
hasEffect = false;
if (enemy.GetComponent<EnemyController>().listEffected.Contains(EBulletEffect.SLOW))
{
enemy.GetComponent<BulletEffectController>().reset = true;
hasEffect = true;
}
if (!hasEffect)
{
string[] values = (string[])state.effectValue;
BulletEffectManager.Instance.initEffect(EBulletEffect.SLOW, enemy.gameObject,
float.Parse(values[0]), float.Parse(values[1]));
}
break;
#endregion
#region POISON
case EBulletEffect.POISON:
break;
#endregion
#region STUN
case EBulletEffect.STUN:
hasEffect = false;
foreach (Transform child in enemy.transform)
{
if (child.name == PlayNameHashIDs.BulletEffectBurning)
{
hasEffect = true;
child.GetComponent<BulletEffectController>().reset = true;
break;
}
}
if (!hasEffect)
{
string[] values = (string[])state.effectValue;
BulletEffectManager.Instance.initEffect(EBulletEffect.STUN, enemy.gameObject,
controller.getCurrentState().effectObjectID, values[0]);
}
break;
#endregion
}
}