void DetectGates()
 {
     // Reset current enemy
     currentGate = null;
     // Perform OverlapSphere and get the hits
     Collider[] hits = Physics.OverlapSphere(transform.position, attackRange);
     // Loop through everything we hit
     foreach (var hit in hits)
     {
         // If the thing we hit is an enemy
         GateHealth gate = hit.GetComponent <GateHealth>();
         if (gate)
         {
             // Set current enemy to that one
             currentGate = gate;
         }
     }
 }
예제 #2
0
    void OnCollisionEnter(Collision other)
    {
        if (other.gameObject == generator)
        {
            genTargetInRange = true;
        }
        else
        {
            genTargetInRange = false;
        }

        if (other.collider.CompareTag("Gate"))
        {
            gateHealth        = other.collider.GetComponent <GateHealth>();
            gateTargetInRange = true;
        }
        else
        {
            gateTargetInRange = false;
        }
    }
예제 #3
0
 // Use this for initialization
 void Start()
 {
     gameController = GameObject.FindWithTag("GameController").GetComponent <GameController>();
     gateHealth     = gateHealthParent.GetComponent <GateHealth>();
 }
예제 #4
0
 // Attacks at a given enemy only when 'attacking'
 public virtual void Attack(GateHealth g)
 {
     print("Base Enemy is attacking '" + g.name + "'");
 }
예제 #5
0
 // Aims at a given enemy every frame
 public virtual void Aim(GateHealth g)
 {
     print("Base Enemy is aiming at '" + g.name + "'");
 }
 // Attacks at a given enemy only when 'attacking'
 public override void Attack(GateHealth g)
 {
     print("MoveOnPath is attacking '" + g.name + "'");
     g.TakeDamage(damage);
     // Note (Manny): The way you're using Inheritance & Polymorphism here is wrong. Come and see me for more details.
 }
 // Aims at a given enemy every frame
 public override void Aim(GateHealth g)
 {
     print("MoveOnPath is aiming at '" + g.name + "'");
 }