Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
        capsule.enabled = false;
        pos             = transform.position.x;
        dirRight        = true;
        enemy           = GetComponent <OrcAI>();
        enemyT          = GetComponent <Transform>();
        //enemyR = GetComponent<Rigidbody> ();
        isStun       = false;
        direction    = Vector2.right;
        seesPlayer   = false;
        isMoving     = false;
        isIdle       = false;
        isAttack     = false;
        SFX          = GetComponent <AudioSource>();
        timeForCool1 = GetComponent <CoolDown>();
        timeForCool2 = GetComponent <CoolDown>();
        proCoolDown  = GetComponent <CoolDown>();
        anim         = GetComponent <Animator>();

        if (PlayerPrefs.GetString("hasWand") == "true")
        {
            wandBonus = 1;
        }
        else
        {
            wandBonus = 0;
        }
        if (PlayerPrefs.GetString("hasSword") == "true")
        {
            swordBonus = 1;
        }
        else
        {
            swordBonus = 0;
        }
    }
Esempio n. 2
0
 void Attack(GameObject enemy)
 {
     if (isAttacking)
     {
         if (enemy.CompareTag("OrcTown"))
         {
             Building town = enemy.gameObject.GetComponent <Building>();
             Debug.Log("attackorctown");
             if (!town.isDead)
             {
                 float enemyHP = town.HP;
                 town.TakeDamage(0.1f);
                 if (enemyHP == 0)
                 {
                     currentenemy = null;
                     isAttacking  = false;
                     animator.SetBool("Fighting", false);
                 }
             }
             //else
             //{
             //    Debug.Log("deadfootman");
             //    currentenemy = null;
             //    isAttacking = false;
             //    animator.SetBool("Fighting", false);
             //}
         }
         if (enemy.CompareTag("OCTownHall"))
         {
             TownHall townhall = enemy.gameObject.GetComponent <TownHall>();
             if (!townhall.isDead)
             {
                 float enemyHP = townhall.HP;
                 townhall.TakeDamage(0.1f);
                 if (enemyHP <= 0)
                 {
                     //townhall.isDead = true;
                     //Debug.Log("deadfootman");
                     currentenemy = null;
                     isAttacking  = false;
                     animator.SetBool("Fighting", false);
                 }
                 //Debug.Log("Orc Townhall [" + enemyHP + "/20]HP has been attacked");
             }
         }
         if (enemy.CompareTag("Orc"))
         {
             OrcAI orc = enemy.gameObject.GetComponent <OrcAI>();
             if (!orc.isDead)
             {
                 float enemyHP = orc.HP;
                 orc.TakeDamage(0.1f);
                 if (enemyHP <= 0)
                 {
                     currentenemy = null;
                     isAttacking  = false;
                     animator.SetBool("Fighting", false);
                 }
             }
         }
     }
 }
Esempio n. 3
0
 void Start()
 {
     enemy    = GetComponent <OrcAI>();
     stunTime = 1.5f;
 }