protected virtual void HitCheck() { Collider[] colliders = new Collider[10]; Physics.OverlapSphereNonAlloc(_transform.position, _meleeHitRange, colliders); for (int i = 0; i < colliders.Length; i++) { if (colliders[i] != null) { if (colliders[i].CompareTag(TagManager.GetTag(TagType.Target))) { var mainBuilding = Services.Instance.LevelService.MainBuilds; mainBuilding.GetDamage(_damage); if (_levelService.ActiveEnemies.Contains(this)) _levelService.ActiveEnemies.Remove(this); Object.Destroy(_enemyObject); if (_levelService.ActiveEnemies.Count == 0 && Services.Instance.LevelService.IsLevelSpawnEnded) { _levelService.EndLevel(); } } else if (colliders[i].CompareTag(TagManager.GetTag(TagType.Player))) { if (_currentHitCooldown == 0) { Services.Instance.LevelService.CharacterBehaviour.SetArmor(_damage); _currentHitCooldown = _hitCooldown; } Services.Instance.LevelService.CharacterBehaviour.RamEnemy(this); _stoping.AddTimeRemaining(); } else if (colliders[i].CompareTag(TagManager.GetTag(TagType.Block))) { if (_currentHitCooldown == 0) { Services.Instance.LevelService.CharacterBehaviour.SetDamage(_damage); _currentHitCooldown = _hitCooldown; } _stoping.AddTimeRemaining(); } } } }
public void Collision() { var tagCollider = Physics.OverlapSphere(transform.position, _radius); for (int i = 0; i < tagCollider.Length; i++) { if (tagCollider[i].CompareTag(TagManager.GetTag(TagType.Bonus))) { hasSkill = true; for (int b = 0; b < Services.Instance.LevelService.ActiveBonus.Count; b++) { if (Services.Instance.LevelService.ActiveBonus[b].GetTransform() == tagCollider[i].transform) { Services.Instance.LevelService.ActiveBonus[b].Use(); } } } } }
public void Initialization() { //Инициализация списка спауна //Получаем Scriptable Object список спауна var enemySpawnList = Data.Instance.LevelData.GetEnemySpawnList(Services.Instance.LevelService.CurrentLevel); //Извлекаем из него массив элементов - записей о спауне отдельных врагов var singleEnemySpawnDatas = enemySpawnList.Enemies; //Сортируем его по таймингу спауна по ворастанию singleEnemySpawnDatas = singleEnemySpawnDatas.OrderBy(x => x.SpawnTiming).ToArray(); //Закидываем это всё в очередь в таком порядке, чтобы запси с ранними таймингами были в голове очереди _enemiesToSpawnQueue = new Queue <SingleEnemySpawnData>(); foreach (var enemySpawnData in singleEnemySpawnDatas) { _enemiesToSpawnQueue.Enqueue(enemySpawnData); } //Инициализация точек спауна //Создаются массивы точек спауна и их ID соответственно GameObject[] spawnPoints = GameObject.FindGameObjectsWithTag(TagManager.GetTag(TagType.Spawn)); int[] spawnPointIds = new int[spawnPoints.Length]; for (int i = 0; i < spawnPoints.Length; i++) { string idString = string.Empty;//строка, содержащая все цифры из имени объекта foreach (char c in spawnPoints[i].name) { if (IsDigit(c)) { idString += c; } } int id = int.Parse(idString); spawnPointIds[i] = id; } //Каждая точка спауна занимает место в массиве _spawnPoints с индексом равным своему ID _spawnPoints = new Vector3[spawnPointIds.Max() + 1]; for (int i = 0; i < spawnPoints.Length; i++) { _spawnPoints[spawnPointIds[i]] = spawnPoints[i].transform.position; } }
protected override void HitCheck() { Collider[] colliders = new Collider[10]; Physics.OverlapSphereNonAlloc(_transform.position, _meleeHitRange, colliders); for (int i = 0; i < colliders.Length; i++) { if (colliders[i] != null) { if (colliders[i].CompareTag(TagManager.GetTag(TagType.Target))) { var mainBuilding = colliders[i].GetComponent <MainBuild>(); mainBuilding.GetDamage(_damage); } if (_hp < _spikeThreshold) { if (colliders[i].CompareTag(TagManager.GetTag(TagType.Player))) { Services.Instance.LevelService.CharacterBehaviour.SetArmor(_damage); } else if (colliders[i].CompareTag(TagManager.GetTag(TagType.Block))) { Services.Instance.LevelService.CharacterBehaviour.SetDamage(_damage); } } else { if (colliders[i].CompareTag(TagManager.GetTag(TagType.Player))) { Services.Instance.LevelService.CharacterBehaviour.SetDamage(_damage); } else if (colliders[i].CompareTag(TagManager.GetTag(TagType.Block))) { Services.Instance.LevelService.CharacterBehaviour.SetDamage(_damage + _bonusDamage); } } } } }
public void Move() { _timeService = Services.Instance.TimeService; _bullet.position += _speed * _bullet.forward * _timeService.DeltaTime(); Collider[] _collidedObjects = new Collider[30]; var tagCollider = Physics.OverlapSphereNonAlloc(_bullet.transform.position, 3, _collidedObjects); for (int i = 0; i < tagCollider; i++) { if (_collidedObjects[i].CompareTag(TagManager.GetTag(TagType.Enemy))) { for (int b = 0; b < Services.Instance.LevelService.ActiveEnemies.Count; b++) { if (Services.Instance.LevelService.ActiveEnemies[b].GetTransform() == _collidedObjects[i].transform) { if (Services.Instance.LevelService.ActiveEnemies[b] is IDamageAddressee ActiveEnemy) { ActiveEnemy.RegisterDamage(_damage, ArmorTypes.None); } } } } } }
public void FindGameObject() { Target = GameObject.FindGameObjectWithTag(TagManager.GetTag(TagType.Target)); }
public MainBuild() { _mainBuildData = Data.Instance.MainBuildData; _hp = _mainBuildData.Hp; _build = GameObject.FindGameObjectWithTag(TagManager.GetTag(TagType.Target)); }
protected virtual void GetTarget() { _target = GameObject.FindWithTag(TagManager.GetTag(TagType.Target)).transform; }