void OnTriggerEnter2D(Collider2D other)
    {
        Rigidbody2D otherRigidbody = other.GetComponentInParent <Rigidbody2D> ();

        if (other.tag == "SpawnCollider" && spawn == null && rigidbodyIsMovingInCorrectDirection(otherRigidbody, other))
        {
            spawn = Instantiate(enemyPrefab, transform.position, Quaternion.identity) as GameObject;
            IDirected directedComponent = spawn.GetComponent <IDirected>();
            if (directedComponent != null)
            {
                directedComponent.horizontalDirection = spawnDirection;
            }
            if (isBuzzword)
            {
                GenericBuzzwordMessenger buzzwordMessenger = spawn.GetComponent <GenericBuzzwordMessenger>();
                if (buzzwordMessenger == null)
                {
                    Debug.LogError("Spawn point marked for buzzword, but GenericBuzzwordMessenger was not found on the enemyPrefab");
                }
                else
                {
                    buzzwordMessenger.buzzword = buzzwordStrings[Random.Range(0, buzzwordStrings.Length - 1)];
                }
            }
        }
    }
示例#2
0
 public FireController(IDirected player, IUserFireInputProxy fireInput, BulletData data, IBulletFactory bulletFactory)
 {
     CanExecute               = true;
     _player                  = player;
     _fireInput               = fireInput;
     _playerTransform         = player.GetPosition();
     _data                    = data;
     _fireInput.FireOnEnable += FireInput;
     _currentCooldown         = 0;
     _bulletFactory           = bulletFactory;
     _playerBullets           = new PlayerBullets();
     _fire                    = false;
 }