示例#1
0
 public void Start()
 {
     if (DeferToParent && transform.parent != null)
     {
         _parentTagSource = transform.parent.GetComponentInParent <IKnowsEnemyTags>();
     }
 }
    // Use this for initialization
    void Start()
    {
        if (TurretPrefab != null)
        {
            if (EnemyTagSource == null && transform.parent != null)
            {
                EnemyTagSource = transform.GetComponentInParent <IKnowsEnemyTags>();
            }

            if (EnemyTagSource != null)
            {
                EnemyTags = EnemyTagSource.KnownEnemyTags;
            }

            if (ParentForTurret == null && transform.parent != null)
            {
                ParentForTurret = transform.parent;
            }

            var turret = Instantiate(TurretPrefab, transform.position, transform.rotation, ParentForTurret);

            if (ParentForTurret != null)
            {
                var parentRigidbody = ParentForTurret.GetComponent <Rigidbody>();
                if (parentRigidbody != null)
                {
                    turret.SetVelocity(parentRigidbody.velocity);
                }

                turret.parent = ParentForTurret;
                turret.GetComponent <FixedJoint>().connectedBody = parentRigidbody;

                var renderer = ParentForTurret.GetComponentInChildren <Renderer>();

                if (renderer != null)
                {
                    //Debug.Log("has renderer");
                    turret.transform.SetColor(renderer.material.color);
                }
            }

            var tagKnower = turret.GetComponent <IKnowsEnemyTags>();
            if (tagKnower != null)
            {
                tagKnower.KnownEnemyTags = EnemyTags;
            }

            if (TagChildren)
            {
                turret.tag = ParentForTurret != null ? ParentForTurret.tag : tag;
            }

            Destroy(gameObject);
        }
        else
        {
            Debug.LogWarning(name + " Has no turret to spawn.");
        }
    }
示例#3
0
 // Use this for initialization
 void Start()
 {
     _colerer = GetComponent <ColourSetter>();
     _reload  = Random.value * RandomStartTime + MinStartTime;
     Emitter  = Emitter != null ? Emitter : transform;
     _targetChoosingMechanism = GetComponent <IKnowsCurrentTarget>();
     _enemyTagKnower          = GetComponent <IKnowsEnemyTags>();
     _spawner = GetComponent <Rigidbody>();
 }
示例#4
0
    // Use this for initialization
    void Start()
    {
        _colerer = GetComponent <ColourSetter>();
        _targetChoosingMechanism = GetComponent <IKnowsCurrentTarget>();
        _enemyTagKnower          = GetComponent <IKnowsEnemyTags>();
        var emitterCount = EmitterParent.childCount;

        _emitters = new List <Transform>();
        for (int i = 0; i < emitterCount; i++)
        {
            _emitters.Add(EmitterParent.GetChild(i));
        }

        _reload = LoadTime;

        _fireControl = GetComponent <IFireControl>();
    }
示例#5
0
 // Use this for initialization
 void Start()
 {
     if (TargetPicker == null)
     {
         Debug.LogError(name + " Has no target picker");
         _active = false;
         return;
     }
     if (Detector == null)
     {
         EnemyTagKnower = EnemyTagKnower ?? GetComponentInParent <IKnowsEnemyTags>();
         if (EnemyTagKnower == null)
         {
             Debug.LogWarning(name + " Could not find enemy tag source for target picker while configuring the detector.");
         }
         else
         {
             Detector = new RepositoryTargetDetector(EnemyTagKnower);
         }
     }
     FilteredTargets = new List <Target>();//ensure that this isn't null.
 }
 public RepositoryTargetDetector(IKnowsEnemyTags enemyTagKnower)
 {
     _enemyTagKnower = enemyTagKnower;
 }