예제 #1
0
 //範囲ダメージ
 public void AreaAttack()
 {
     EffectManager.instance.playInPlace(transform.position, particleToPlay);
     Collider[] allEnemyes = Physics.OverlapSphere(transform.position, range);
     foreach (var c in allEnemyes)
     {
         Character character = c.GetComponent <Character>();
         //キャラクターじゃなければ、ターワダメージ
         if (character == null)
         {
             damage = towerCroneDamage;
         }
         else
         {
             damage = standardDamage;
         }
         Iteam team = c.GetComponent <Iteam>();
         if (team != null && team.getTeam() != tm)
         {
             Health h = c.GetComponent <Health>();
             if (h != null)
             {
                 h.takeDamage(damage);
             }
         }
     }
     Destroy(gameObject);
 }
예제 #2
0
 //areaAttack
 public void meleeAreaAttack()
 {
     EffectManager.instance.playInPlace(transform.position, meleeAreaEffect);
     Collider[] allEnemyes = Physics.OverlapSphere(transform.position, monstercard.range);
     foreach (var c in allEnemyes)
     {
         Character character = c.GetComponent <Character>();
         if (character != null)
         {
             if (character.getTroupType() == troupType.fly && monstercard.targets != targetType.All)
             {
                 continue;
             }
         }
         Iteam team = c.GetComponent <Iteam>();
         if (team != null && team.getTeam() != tm)
         {
             Health h = c.GetComponent <Health>();
             if (h != null)
             {
                 h.takeDamage(monstercard.damage);
             }
         }
     }
 }
예제 #3
0
    //raycastでsphereを作る
    private void OverlapFinding()
    {
        if (inBattle)
        {
            return;
        }
        Collider[]       allcolider = Physics.OverlapSphere(transform.position, 5);
        List <Transform> targetList = new List <Transform>();

        foreach (var item in allcolider)
        {
            if (item.GetComponent <Character>())
            {
                //建物だけの場合は続く
                if (monstercard.targets == targetType.onlyBuild)
                {
                    continue;
                }
                //飛ぶモンスターに攻撃出来ない場合は続く
                troupType type = item.GetComponent <Character>().getTroupType();
                if (type == troupType.fly && monstercard.targets == targetType.onlyGround)
                {
                    continue;
                }
            }
            //敵チームのモンスターだったらリストに加える
            Iteam team = item.GetComponent <Iteam>();
            if (team != null && team.getTeam() != this.tm)
            {
                targetList.Add(item.transform);
            }
        }

        //リストがあったら一番近いエネルギーを選ぶ
        if (targetList.Count < 1)
        {
            return;
        }
        targetList = targetList.OrderBy(c => Vector3.Distance(transform.position, c.transform.position)).ToList();
        target     = targetList[0];
        inBattle   = true;
        changeState(charState.chase);
    }
예제 #4
0
 //爆弾の爆発
 void explode()
 {
     Collider[] colliders = Physics.OverlapSphere(transform.position, 2.5f);
     foreach (var c in colliders)
     {
         Health h = c.GetComponent <Health>();
         if (h == null)
         {
             continue;
         }
         Iteam t = c.GetComponent <Iteam>();
         if (t.getTeam() == team)
         {
             continue;
         }
         h.takeDamage(damage);
     }
     EffectManager.instance.playInPlace(transform.position, "TowerExplosion");
     Destroy(gameObject);
 }