void OnTriggerEnter(Collider c)
    {
        if (c.collider.GetComponent <Explodable>() != null)
        {
            c.collider.SendMessage("Boom");
        }
        if (c.gameObject.CompareTag("Enemy"))
        {
            EnemyBase scr = c.gameObject.GetComponent <EnemyBase>();
            scr.takeDamage(dmg);
            scr.damageTaken += dmg;
            if (hawkScript.enemiesToAttack.Contains(c.gameObject) == false)
            {
                hawkScript.enemiesToAttack.Add(c.gameObject);
            }

            Woodsman tempScr = woodsPlayer.GetComponent <Woodsman>();
            tempScr.hitCount += 1;


            Destroy(gameObject);
        }
        else if (c.gameObject.CompareTag("wall"))
        {
            Destroy(gameObject);
        }
    }
    // Use this for initialization
    void Start()
    {
        // list of enemies to keep track of for the hawk to attack
        // the hawk will only attack the one that the woodsman has done the most damage to
        enemiesToAttack = new List <GameObject>();

        // Looping through the current players to find the woodsman character to use its forward for movement
        PlayerManager pManager = GameObject.FindGameObjectWithTag("PlayerManager").GetComponent <PlayerManager>();

        for (int i = 0; i < pManager.players.Count; i++)
        {
            script = pManager.players[i].GetComponent <Woodsman>();
            if (script)
            {
                woodsman = pManager.players[i];
                break;
            }
        }
        // setting initial mode to rotating around woodsman
        mode = 1;

        // initializing the initalPoint which is the point the hawk wants to fly to
        // when sent out by player to zero
        initialPoint = Vector3.zero;

        // finding the perch position that is a child of the woodsman to use
        // for when the hawk is perched on the woodsman shoulder
        perchPos = woodsman.transform.Find("perchPos");

        // initially setting the time the hawk perchs in mode 4, and
        // how long it idles in mode 1
        timerPerch = Random.Range(15.0f, 22.0f);
        timerIdle  = Random.Range(15.0f, 22.0f);

        // Setting how long the hawk will attack an enemy when set out by player
        // and it comes into contact with an enemy
        timerEnemy = 2.0f;
    }
Exemple #3
0
 private void Start()
 {
     woodsman   = GameObject.Find("Woodsman(Clone)").GetComponent <Woodsman>();
     hawkScript = GameObject.FindGameObjectWithTag("Hawk").GetComponent <HawkAI2>();
 }