示例#1
0
        private void stopAllEnemy()
        {
            if (gameObject.tag == "Player")
            {
                GameObject[] allEnemyCar = GameObject.FindGameObjectsWithTag("Enemy");

                if (allEnemyCar.Length > 0)
                {
                    foreach (GameObject gameObjectEnemy in allEnemyCar)
                    {
                        if (gameObjectEnemy != null)
                        {
                            CarAIControl carAIControl = gameObjectEnemy.GetComponent <CarAIControl>();
                            EnemyGun     enemyGun     = gameObjectEnemy.GetComponent <EnemyGun>();

                            if ((carAIControl != null) && (enemyGun != null))
                            {
                                carAIControl.stopCarAi();
                                enemyGun.stopShooting();
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
        }
示例#2
0
        private void Awake()
        {
            // get the car controller reference
            m_CarController = GetComponent <CarController>();

            // give the random perlin a random value
            m_RandomPerlin = Random.value * 100;

            m_Rigidbody = GetComponent <Rigidbody>();

            carHelper = GetComponent <CarHelper>();
            enemyGun  = GetComponent <EnemyGun>();
        }