// Start is called before the first frame update void Start() { //Create instance of the different kind of the enemies enemyFactory = new EnemyFactory(); normalEnemy = enemyFactory.GetEnemy(EnemyType.Normal); bossEnemy = enemyFactory.GetEnemy(EnemyType.Boss); GameManager.Instance.GameStart += OnGameStart; GameManager.Instance.GameEnd += OnGameEnd; }
private void Awake() { enemies.Add(enemyFactory.GetEnemy(EnemyTypes.flying)); enemies.Add(enemyFactory.GetEnemy(EnemyTypes.walking)); enemies.Add(enemyFactory.GetEnemy(EnemyTypes.swimming)); foreach (IEnemy enemy in enemies) { enemy.Move(); enemy.Attack(); enemy.TakeDamage(); } }
void Start() { enemyList.Add(enemyFactory.GetEnemy(EnemyType.FLYING_ENEMY)); enemyList.Add(enemyFactory.GetEnemy(EnemyType.SWIMING_ENEMY)); enemyList.Add(enemyFactory.GetEnemy(EnemyType.WALKING_ENEMY)); for (int i = 0; i < enemyList.Count; i++) { enemyList[i].Attact(); enemyList[i].Move(); enemyList[i].TakeDamage(); } }
private void RandomSpawn() { if (this.rateOfEnemySpawn <= 0f) { return; } float durationBetweenTwoEnemySpawn = 1f / this.rateOfEnemySpawn; if (Time.time < this.lastEnemySpawnTime + durationBetweenTwoEnemySpawn) { // The bullet gun is in cooldown, it can't fire. return; } // Spawn an enemy. string prefabPath = "Prefabs/Enemy_01"; if (Random.value < 0.2f) { prefabPath = "Prefabs/Enemy_02"; } float randomY = Random.Range(-4f, 4f); EnemyFactory.GetEnemy(new Vector3(10f, randomY), Quaternion.Euler(0f, 0f, 0f), prefabPath); this.lastEnemySpawnTime = Time.time; // Up the difficulty. this.rateOfEnemySpawn += this.rateOfEnemySpawn > this.maximumRateOfEnemySpawn ? 0f : this.rateOfEnemySpawnIncreaseStep; }
public ArenaBattle() { _player = Player.GetInstance(); IEnemyFactory enemyFactory = new EnemyFactory(); _enemy = enemyFactory.GetEnemy(); }
public void GetAnEnemy() { Debug.Log("Model Get Enemy"); GameObject tempobj = enemyFac.GetEnemy(); tempobj.GetComponent <Enemy>().FindMother(enemyFac); }
//add enemy to scene public Enemy AddEnemy() { if (enemiesToSpawn.Count == 0) { return(null); } float height = GameManager.topBottomLimits.y; int width = 2100; Vector2 pos = new Vector2(); int enemyIndex; //always out of screen as we dont want hero to collide on spawn pos.x = ((2 * Random.Range(0, 2)) - 1) * (450 + Random.Range(0, width)); pos.y = ((2 * Random.Range(0, 2)) - 1) * Random.Range(0, height); enemyIndex = Random.Range(0, enemiesToSpawn.Count); Enemy enemy = enemyFactory.GetEnemy(enemiesToSpawn[enemyIndex], pos); craftsInScene.Add(enemy.displayObject, enemy); string intString = enemiesToSpawn[enemyIndex].Substring(6); enemy.paint = GameManager.colorPallette[int.Parse(intString) - 1]; //Debug.Log("Launch "+enemiesToSpawn[enemyIndex]); enemiesToSpawn.RemoveAt(enemyIndex); return(enemy); }
public void SpawnEnemies(EnemyType EnemyToSpawn) { //HAVE FACTORY MANUFACTURE THEM!!! Enemies mEnemy = mFactory.GetEnemy(EnemyToSpawn); mEnemy.Fight(); }
private IEnemy GetEnemy() { var enemy = _factory.GetEnemy(); enemy.SetPosition(_transform.position); enemy.SetRotation(_transform.rotation); return(enemy); }
public void SpawnCommonEnemy(float enemySpawnSpeed)//生成敌人 { spawnSpeed += spawnSpeed * Time.deltaTime; while (spawnSpeed >= enemySpawnSpeed) { spawnSpeed -= enemySpawnSpeed; Enemy enemy = enemyFactory.GetEnemy(); enemies.Add(enemy); SearchAndGo(enemy); } }
public void Update(float deltaTime) { timer -= deltaTime; if (timer <= 0f) { enemyManager.Spawn(EnemyFactory.GetEnemy($"Enemy{random.Next(1, 5)}")); timer = maxTimer; //tot++; } if (!Enabled) { Moldels.Enemy.ExtraDepth = 0; } }
private void SpawnSomething() { TimeSpan nao = _time.GetCurrent(); bool isFirstSpawn = _lastSpawn == TimeSpan.MinValue; // Spawn enemy if no enemy was spawned yet or if the time since last spawn is long enough. bool shouldSpawnEnemy = (_lastSpawn + _settings.SpawnFrequency <= nao) || isFirstSpawn; if (_monstersLeftToSpawn.Count > 0 && shouldSpawnEnemy) { EnemyTypeEnum enemyType = _monstersLeftToSpawn.Dequeue(); EnemyBase enemy = _enemyFactory.GetEnemy(enemyType); enemy.Init(); enemy.SetLocation(_settings.SpawnPoint); enemy.Waypoints = _settings.Waypoints; enemy.OnDeathAction = OnEnemyDeath; CurrentMonsters.Add(enemy); _lastSpawn = nao; } }
public void Execute() { if (!this.IsLevelStarted) { return; } float timePassedSinceBeginning = Time.time - this.currentLevelStartDate; if (this.description == null) { return; } if (this.description.Enemies == null) { return; } for (int index = 0; index < this.description.Enemies.Length; index++) { EnemyDescription enemyDescription = this.description.Enemies[index]; if (this.isEnemySpawned[index] == EnemyState.Spawned) { continue; } if (timePassedSinceBeginning < enemyDescription.SpawnDate) { continue; } // Spawn ! EnemyFactory.GetEnemy(enemyDescription.SpawnPosition, Quaternion.Euler(0f, 0f, 0f), enemyDescription.PrefabPath); this.isEnemySpawned[index] = EnemyState.Spawned; } }
public void TestMethod1() { Enemy testEnemy = EnemyFactory.GetEnemy(EnemyFactory.EnemyType.SwordEnemyHorizontal, 100, 100); Assert.IsTrue(testEnemy.EnemyWeapon is Rifle); }
public Battle(Player player, EnemyFactory enemyFactory) { this.player = player; this.enemy = enemyFactory.GetEnemy(); menu = new BattleMenu(player, enemy); }