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


C# Enemy.GetComponent方法代码示例

本文整理汇总了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);
    }
开发者ID:2P-Games,项目名称:Parasite-Paradise,代码行数:25,代码来源:Player.cs

示例2: AttackingEnemyState

 public AttackingEnemyState(Enemy enemy, Player player)
 {
     this.enemy = enemy;
     enemyRigidbody = enemy.GetComponent<Rigidbody>();
     this.player = player;
     randomMoveDelay = Random.Range(1f, 2f);
 }
开发者ID:sdomenici009,项目名称:Starfield,代码行数:7,代码来源:AttackingEnemyState.cs

示例3: EnemyPathStrategy

 public EnemyPathStrategy(Enemy enemy, List<Vector2> path)
 {
     this.enemy = enemy;
     this.path = path;
     node = 0;
     rb2d = enemy.GetComponent<Rigidbody2D>();
 }
开发者ID:alexandremuzio,项目名称:yatm,代码行数:7,代码来源:EnemyPathStrategy.cs

示例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;
 }
开发者ID:alexandremuzio,项目名称:yatm,代码行数:8,代码来源:EnemyAttackPeopleStrategy.cs

示例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;
 }
开发者ID:alexandremuzio,项目名称:yatm,代码行数:9,代码来源:EnemyFollowStrategy.cs

示例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;
    }
开发者ID:new-00-0ne,项目名称:System-Purge,代码行数:21,代码来源:wander.cs

示例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);
     }
 }
开发者ID:glegeza,项目名称:laser-defender,代码行数:13,代码来源:LootManager.cs

示例8: stopMonsterSound

 public void stopMonsterSound(Enemy monster)
 {
     monster.GetComponent<AudioSource> ().Stop();
 }
开发者ID:Elzahn,项目名称:IMY300,代码行数:4,代码来源:Sounds.cs

示例9: resumeMonsterSound

 public void resumeMonsterSound(Enemy monster)
 {
     if (monster.GetComponent<AudioSource> () != null) {
         monster.GetComponent<AudioSource> ().UnPause ();
     }
 }
开发者ID:Elzahn,项目名称:IMY300,代码行数:6,代码来源:Sounds.cs

示例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 ();
        }
    }
开发者ID:Elzahn,项目名称:IMY300,代码行数:20,代码来源:Sounds.cs

示例11: pauseMonsterSound

 public void pauseMonsterSound(Enemy monster)
 {
     if (monster != null) {
         monster.GetComponent<AudioSource> ().Pause ();
     }
 }
开发者ID:Elzahn,项目名称:IMY300,代码行数:6,代码来源:Sounds.cs

示例12: SpiralMotionEnemyState

	public SpiralMotionEnemyState(Enemy enemy, Player player)
	{
		this.enemy = enemy;
		enemyRigidbody = enemy.GetComponent<Rigidbody>();
		this.player = player;
	}
开发者ID:sdomenici009,项目名称:Starfield,代码行数:6,代码来源:SpiralMotionEnemyState.cs

示例13: LeavingEnemyState

 public LeavingEnemyState(Enemy enemy, Player player)
 {
     this.enemy = enemy;
     enemyRigidbody = enemy.GetComponent<Rigidbody>();
     this.player = player;
 }
开发者ID:sdomenici009,项目名称:Starfield,代码行数:6,代码来源:LeavingEnemyState.cs

示例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;
            }
        }
    }
开发者ID:bobjrsenior,项目名称:The_Final_Mage_2,代码行数:88,代码来源:DifficultyManager.cs


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