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


C# EnemyController.GetComponent方法代码示例

本文整理汇总了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;
    }
开发者ID:mattgor123,项目名称:CS355-Robo-Clean-5000,代码行数:20,代码来源:LMBasicShot.cs

示例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;*/
 }
开发者ID:travisstebbins,项目名称:EscapeTheCube,代码行数:19,代码来源:PlayerController.cs

示例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
        }
    }
开发者ID:royalknight2902,项目名称:AgeOfFreedom,代码行数:75,代码来源:SkillDamage.cs


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