//範囲ダメージ 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); }
//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); } } } }
/// <Pick up Iteam Summary> /// This function adds a iteam component to parent object /// the parent component has a score value as well as a weightvalue /// we just tether the weight value though onto our player for purposes /// </summary> /// <param name="weightval"></param> /// <param name="scoreval"></param> public void PickUpIteam(int weightval, int scoreval) { if (!_isCarryingObject) { Iteam iteam = gameObject.AddComponent <Iteam>(); iteam.SetScoreValue(scoreval); iteam.SetWeightValue(weightval); _iteamweight = weightval; _isCarryingObject = true; Debug.Log("Picked up iteam"); } }
void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player") { Player player = other.gameObject.GetComponent <Player>(); if (player._isCarryingObject) { Iteam iteam = other.gameObject.GetComponent <Iteam>(); _ScoreManager.AddScore(player._teamcolour, iteam._scorevalue); player.RemoveIteam(); } } }
//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); }
//爆弾の爆発 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); }