Exemple #1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Attacker_TypeA attacker = collision.gameObject.GetComponent <Attacker_TypeA>();
        Health         health   = collision.GetComponent <Health>();

        if (attacker && health)
        {
            health.DamageReceived(damage);
            Destroy(gameObject);
        }
    }
Exemple #2
0
    bool isTimeToSpawn(GameObject attackerGameObject)
    {
        Attacker_TypeA attackerA = attackerGameObject.GetComponentInChildren <Attacker_TypeA>();

        float spawnDelay     = attackerA.spawnEverySecond;
        float spawnPersecond = 1 / spawnDelay;

        if (Time.deltaTime > spawnDelay)
        {
            Debug.LogWarning("Spawn rate capped by frame rate and that's bad");
        }

        float threshold = spawnPersecond * Time.deltaTime / 5; //we have 5 lanes

        return(Random.value < threshold);
        //Always make it clear to read
    }
Exemple #3
0
 // Use this for initialization
 void Start()
 {
     targetAnimation = GetComponent <Animator>();
     attackerA       = GetComponent <Attacker_TypeA>();
 }