// IEnumerator RegenHealth()
    // {

    //  ready = false;

    // yield return new WaitForSeconds(regenTime);
    //  TakeDamage(-healthRegen);

    // ready = true;


    // }


    private void OnCollisionEnter2D(Collision2D col)
    {
        //Debug.Log("tower col");
        //Debug.Log(GetComponent<Rigidbody2D>().velocity.magnitude);

        if (col.collider.tag == "head" && GetComponent <Rigidbody2D>().velocity.magnitude > 0.01)
        {
            GetComponent <Rigidbody2D>().AddForce(new Vector2(0, fallOffForce));
            OrcScript os = col.collider.gameObject.GetComponentInParent <OrcScript>();
            // Debug.Log("fal dmg");
            os.TakeDamage(fallingDmg);
        }
    }
Example #2
0
    private void Start()
    {
        ///Finds all the game objects with the tags to get the components required to complete the script.
        ///
        playerHPScript = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerHealth>();
        player         = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>();

        orcPatrolParent = GetComponentInParent <OrcPatrol>();
        orc             = GetComponentInParent <OrcScript>();

        ///Stores the Information of the these gameobjects colliders
        orcColliderInfo    = GameObject.FindGameObjectWithTag("Orc").gameObject.GetComponent <Collider>();
        playerColliderInfo = GameObject.FindGameObjectWithTag("Player").gameObject.GetComponent <Collider>();
        //potionColliderInfo = GameObject.FindGameObjectWithTag("Potion").gameObject.GetComponent<Collider>();

        ///Always ignore collision between the Orc and Player.
        Physics.IgnoreCollision(orcColliderInfo, playerColliderInfo, true);
        anim = GetComponentInParent <Animator>();
    }
Example #3
0
 void Start()
 {
     orcParent = transform.parent.GetComponent <OrcScript>();
 }