示例#1
0
 public void Attack()
 {
     if (ally.returnElapsedTime() > ally.wpnSpeed && ally.inCombat)
     {
         if (ally.returnTarget().GetComponent <Enemy_Melee> () != null)
         {
             if (ally.returnTarget().GetComponent <Enemy_Melee> ().enemy.isAlive())
             {
                 ally.returnTarget().GetComponent <Enemy_Melee> ().enemy.takeDamage(ally.wpnDmg);
             }
             else
             {
                 ally.nullTarget();
                 ally.GetTarget();
             }
         }
         else if (ally.returnTarget().GetComponent <Enemy_Ranged> () != null)
         {
             if (ally.returnTarget().GetComponent <Enemy_Melee> ().enemy.isAlive())
             {
                 ally.returnTarget().GetComponent <Enemy_Melee> ().enemy.takeDamage(ally.wpnDmg);
             }
             else
             {
                 ally.nullTarget();
                 ally.GetTarget();
             }
         }
         ally.setElapsedTime(0);
     }
     ally.incElapsedTime();
 }
示例#2
0
 void Attack()
 {
     if (ally.returnElapsedTime() > ally.wpnSpeed + Random.value * 0.5f)        //timer done, can fire
     {
         GameObject newArrow = Instantiate(arrowPrefab, arrowSpawn.transform.position, arrowSpawn.transform.rotation) as GameObject;
         newArrow.transform.eulerAngles = new Vector3(0, 0, transform.eulerAngles.z + 90.9f);
         newArrow.tag = "Player_Projectile";
         newArrow.AddComponent <Player_Projectile> ();
         newArrow.GetComponent <Player_Projectile> ().speed        = 10f;
         newArrow.GetComponent <Player_Projectile> ().punchthrough = ally.retPunchthroughLevel();
         newArrow.GetComponent <Player_Projectile> ().wpnDmg       = ally.wpnDmg + ally.wpnDmg * ally.retDamageLevel() * 0.5f;
         ally.setElapsedTime(0);     //elapsedTime = 0;
     }
     ally.incElapsedTime();          //elapsedTime+=Time.deltaTime
 }