本文整理汇总了C#中Enemy.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# Enemy.GetComponent方法的具体用法?C# Enemy.GetComponent怎么用?C# Enemy.GetComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Enemy
的用法示例。
在下文中一共展示了Enemy.GetComponent方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Infect
public void Infect(Enemy targetEnemy)
{
this.isPossessingEnemy = true;
// reset timers
this.infectTimer = 0.0f;
// re-enable controls, just in case.
this.controlsEnabled = true;
GameObject enemyObject = targetEnemy.gameObject;
this.TruePlayer = gameObject;
// disable enemy components
targetEnemy.GetComponent<Enemy>().enabled = false;
targetEnemy.GetComponent<EnemyAnimation>().enabled = false;
// copy this player script to enemy
enemyObject.AddComponent<PlayerControl>();
UnityEditorInternal.ComponentUtility.CopyComponent(this);
UnityEditorInternal.ComponentUtility.PasteComponentValues(enemyObject.GetComponent<PlayerControl>());
// disable self
this.gameObject.SetActive(false);
}
示例2: AttackingEnemyState
public AttackingEnemyState(Enemy enemy, Player player)
{
this.enemy = enemy;
enemyRigidbody = enemy.GetComponent<Rigidbody>();
this.player = player;
randomMoveDelay = Random.Range(1f, 2f);
}
示例3: EnemyPathStrategy
public EnemyPathStrategy(Enemy enemy, List<Vector2> path)
{
this.enemy = enemy;
this.path = path;
node = 0;
rb2d = enemy.GetComponent<Rigidbody2D>();
}
示例4: EnemyAttackPeopleStrategy
public EnemyAttackPeopleStrategy(Enemy enemy, Func<List<NPC>> getListOfNPC, Func<List<Player>> getListOfPlayers)
{
this.enemy = enemy;
this.getListOfNPC = getListOfNPC;
this.getListOfPlayers = getListOfPlayers;
rb2d = enemy.GetComponent<Rigidbody2D>();
target = null;
}
示例5: EnemyFollowStrategy
public EnemyFollowStrategy(Enemy enemy, Func<List<NPC>> getListOfNPC, Func<List<Player>> getListOfPlayers)
{
this.enemy = enemy;
this.getListOfNPC = getListOfNPC;
this.getListOfPlayers = getListOfPlayers;
rb2d = enemy.GetComponent<Rigidbody2D>();
lastSightTimer = UnityEngine.Random.Range(0, sightCooldown);
lastWaitTimer = MAX_WAIT_TIME;
}
示例6: Enter
public void Enter(Enemy enemy)
{
time = 0;
enemy.wander = true;
enemy.idle = false;
Debug.Log("Wander");
this.enemy = enemy;
this.enemyMask = enemy.enemyMask;
r = Mathf.CeilToInt((UnityEngine.Random.Range(0.0F, 1.0F)));
if (r == 1.0F)
this.enemy.rightdirection = false;
else
this.enemy.rightdirection = true;
dis = 5;
myTrans = enemy.transform;
myBody = enemy.GetComponent<Rigidbody2D>();
SpriteRenderer mySprite = enemy.GetComponent<SpriteRenderer>();
myWidth = mySprite.bounds.extents.x;
myHeight = mySprite.bounds.extents.y;
speed = enemy.movementSpeed;
}
示例7: EnemyDestroyed
public void EnemyDestroyed(Enemy enemy)
{
LootTable loot = enemy.GetComponent<LootTable>();
if (!loot)
{
return;
}
GameObject lootType = loot.GetLoot();
if (lootType)
{
Instantiate(lootType, enemy.transform.position, Quaternion.identity);
}
}
示例8: stopMonsterSound
public void stopMonsterSound(Enemy monster)
{
monster.GetComponent<AudioSource> ().Stop();
}
示例9: resumeMonsterSound
public void resumeMonsterSound(Enemy monster)
{
if (monster.GetComponent<AudioSource> () != null) {
monster.GetComponent<AudioSource> ().UnPause ();
}
}
示例10: playMonsterSound
public void playMonsterSound(int clipAt, Enemy monster)
{
monsterAudio = monster.GetComponent<AudioSource> ();
monsterAudio.spatialBlend = 1f;
monsterAudio.rolloffMode = AudioRolloffMode.Linear;
monsterAudio.minDistance = 12;
monsterAudio.maxDistance = 40;
if (clipAt == MONSTER_WALKING) {
if (monsterAudio.isPlaying == false && done) {
monsterAudio.loop = true;
monsterAudio.clip = monsterClips [clipAt];
monsterAudio.Play ();
}
} else{
monsterAudio.loop = false;
monsterAudio.clip = monsterClips [clipAt];
monsterAudio.Play ();
}
}
示例11: pauseMonsterSound
public void pauseMonsterSound(Enemy monster)
{
if (monster != null) {
monster.GetComponent<AudioSource> ().Pause ();
}
}
示例12: SpiralMotionEnemyState
public SpiralMotionEnemyState(Enemy enemy, Player player)
{
this.enemy = enemy;
enemyRigidbody = enemy.GetComponent<Rigidbody>();
this.player = player;
}
示例13: LeavingEnemyState
public LeavingEnemyState(Enemy enemy, Player player)
{
this.enemy = enemy;
enemyRigidbody = enemy.GetComponent<Rigidbody>();
this.player = player;
}
示例14: setEnemyStats
public void setEnemyStats(Enemy enemy)
{
EnemyHealth enemyHP = enemy.GetComponent<EnemyHealth>();
EnemyAI enemyAI = enemy.GetComponent<EnemyAI>();
//Randomly generates enemy type.
int type = Random.Range(0, 2);
if (type == 0)
{
//Destroy the collider for melee enemies
Destroy(enemy.GetComponent<CircleCollider2D>());
enemy.rangedType = false;
enemy.meleeType = true;
enemy.GetComponent<SpriteRenderer>().sprite = meleeType;
}
else if (type == 1)
{
//Destroy the collider for ranged enemies.
Destroy(enemy.GetComponent<BoxCollider2D>());
enemy.meleeType = false;
enemy.rangedType = true;
enemy.GetComponent<SpriteRenderer>().sprite = rangeType;
}
//If the current enemy is a melee type
if (enemy.meleeType == true)
{
//Floor 1 - 2
if (floor <= 2)
{
enemyHP.maxHealth = enemyHPDifficulty(enemy) - 2;
enemyHP.health = enemyHP.maxHealth;
enemyAI.enemySpeed = enemySpeedDifficulty(enemy);
enemyAI.meleeDamage = enemyDamageDifficulty(enemy);
}
//floor 3 - 4
else if (floor > 2 && floor <= 4)
{
enemyHP.maxHealth = enemyHPDifficulty(enemy) - 1;
enemyHP.health = enemyHP.maxHealth;
enemyAI.enemySpeed = enemySpeedDifficulty(enemy) + .1f;
enemyAI.meleeDamage = enemyDamageDifficulty(enemy);
}
else
{
enemyHP.maxHealth = enemyHPDifficulty(enemy);
enemyHP.health = enemyHP.maxHealth;
enemyAI.enemySpeed = enemySpeedDifficulty(enemy) + .15f;
enemyAI.meleeDamage = enemyDamageDifficulty(enemy);
}
}
else
{
//Floor 1 - 2
if (floor <= 2)
{
enemyHP.maxHealth = enemyHPDifficulty(enemy) - 2;
enemyHP.health = enemyHP.maxHealth;
enemyAI.enemySpeed = enemySpeedDifficulty(enemy);
enemyAI.rangeDamage = enemyDamageDifficulty(enemy);
enemyAI.rangeSpeed = enemyRangeSpeed;
enemyAI.shootWaitTime = enemyShootWaitTime;
enemyAI.rangeProjectile = enemyRangeProjectile;
}
//Floor 3 - 4
else if (floor > 2 && floor <= 4)
{
enemyHP.maxHealth = enemyHPDifficulty(enemy) - 1;
enemyHP.health = enemyHP.maxHealth;
enemyAI.enemySpeed = enemySpeedDifficulty(enemy) + .1f;
enemyAI.rangeDamage = enemyDamageDifficulty(enemy);
enemyAI.rangeSpeed = enemyRangeSpeed;
enemyAI.shootWaitTime = enemyShootWaitTime;
enemyAI.rangeProjectile = enemyRangeProjectile;
}
//Floor 5 - 6
else
{
enemyHP.maxHealth = enemyHPDifficulty(enemy);
enemyHP.health = enemyHP.maxHealth;
enemyAI.enemySpeed = enemySpeedDifficulty(enemy) + .15f;
enemyAI.rangeDamage = enemyDamageDifficulty(enemy);
enemyAI.rangeSpeed = enemyRangeSpeed;
enemyAI.shootWaitTime = enemyShootWaitTime;
enemyAI.rangeProjectile = enemyRangeProjectile;
}
}
}