public void StartSpawners() { foreach (Transform child in transform) { ItemSpawner itemSpawner = child.GetComponent <ItemSpawner>(); if (itemSpawner != null && (difficulty == 1 || difficulty == 2)) { itemSpawner.Spawn(0, 1); } EnemySpawner spawner = child.GetComponent <EnemySpawner>(); if (spawner != null) { switch (difficulty) { case 1: spawner.Spawn(0, 1); break; case 2: spawner.Spawn(1, 2); break; case 3: spawner.Spawn(2, 3); break; default: break; } } } }
public void Spawn() { ClutterSpawner.Spawn(); EnemySpawner.Spawn(); print("Spawned things"); //Invoke("EnableSkellys", 3); }
void Update() { if (player.position.z - basePosition >= sectorLength) { myFormations.enabled = false; if (position == Position.Transitioning) { nextSector.Initialize(); nextSector.enabled = true; enabled = false; } else if (position == Position.Transitioning_Boss) { enemySpawner.Spawn(myBossIndex, Vector3.zero); nextSector.Initialize(); nextSector.enabled = true; enabled = false; } else if (position == Position.Last) { enemySpawner.InitiateRandomBiome(); enabled = false; } else { enemySpawner.Spawn(myBossIndex, Vector3.zero); enemySpawner.InitiateRandomBiome(); enabled = false; } } }
private void SpawnEnemies() { Utlities.random.Randomize(); int randomEnemyNum = Utlities.random.RandiRange(0, enemyCount); int randomBigEnemyNum = Utlities.random.RandiRange(0, bigEnemyCount); int randomAcidEnemyNum = Utlities.random.RandiRange(0, acidEnemyCount); enemySpawner.Spawn(enemyScene, randomEnemyNum); enemySpawner.Spawn(bigEnemyScene, randomBigEnemyNum); enemySpawner.Spawn(acidEnemyScene, randomAcidEnemyNum); }
public void Update() { if (Input.GetKeyDown(KeyCode.A)) { var tank = (Tank)enemySpawner.Spawn(tankPrototype); tank.Run(); } if (Input.GetKeyDown(KeyCode.Z)) { var drone = (Drone)enemySpawner.Spawn(dronePrototype); drone.Fly(); } }
void Awake() { Debug.Log($"FactoryTest.Awake: {_enemy1Factory}"); Debug.Log(spawner.Spawn(0).GetType()); Debug.Log(spawner.Spawn("hoge").GetType()); Debug.Log("--- create from EnemyFactoryImpl"); Debug.Log(enemyFactory.Create(1).GetType()); var cv = cubeViewFactory.Create("test cube"); cv.SetColor(Color.red); }
public void Spawn(float deltaTime) { if (_isCompleted) { return; } _countDown -= deltaTime; if (_countDown >= 0) { return; } if (!_isStarted) { foreach (var enemyData in _enemies) { _enemySpawner.Spawn(enemyData.Key, enemyData.Value, _waveDuration / enemyData.Value); } _isStarted = true; } if (_countDown + _waveDuration <= 0) { _isCompleted = true; } }
private void Spawn() { Wave wave = waves [Mathf.Min(currentSpawner, waves.Length - 1)]; enemySpawner.Spawn(wave.amountByEnemy); itemSpawner.Spawn(wave.itens); }
private IEnumerator SpawnLoop() { if (State != GameState.Playing) { yield break; } var timePlaying = Time.time - TimeStarted; var nextSpawn = _gameplaySettings.SpawnCurve.Evaluate(timePlaying); var spawnAmount = Mathf.RoundToInt(_gameplaySettings.SpawnAmountCurve.Evaluate(timePlaying)); var spawnHealthModifier = _gameplaySettings.SpawnHealthModifier.Evaluate(timePlaying); for (var i = 0; i < spawnAmount; i++) { var enemy = _enemySpawner.Spawn(); if (enemy != null) // can be null if max limit enemies is reached { var stats = enemy.Stats; stats.Health = Mathf.RoundToInt(stats.Health * spawnHealthModifier); enemy.Stats = stats; } } yield return(new WaitForSeconds(nextSpawn)); _monoBehaviourUtil.StartCoroutine(SpawnLoop()); }
// Update is called once per frame void Update() { if (frame) { if (PrevRoomSide == "DownWall") { GameObject player = GameObject.Find("Player"); player.transform.position = new Vector3(GameObject.Find("SpawnDoor").transform.position.x, GameObject.Find("SpawnDoor").transform.position.y - 1, -1); } if (PrevRoomSide == "UpWall") { GameObject player = GameObject.Find("Player"); player.transform.position = new Vector3(GameObject.Find("SpawnDoor").transform.position.x, GameObject.Find("SpawnDoor").transform.position.y + 1, -1); } if (PrevRoomSide == "LeftWall") { GameObject player = GameObject.Find("Player"); player.transform.position = new Vector3(GameObject.Find("SpawnDoor").transform.position.x - 1, GameObject.Find("SpawnDoor").transform.position.y, -1); } if (PrevRoomSide == "RightWall") { GameObject player = GameObject.Find("Player"); player.transform.position = new Vector3(GameObject.Find("SpawnDoor").transform.position.x + 1, GameObject.Find("SpawnDoor").transform.position.y, -1); } frame = false; EnemySpawner spawner = transform.GetComponentInParent <EnemySpawner>(); spawner.Spawn(Height, Width); } }
private IEnumerator Manager() { WaitForEndOfFrame wait = new WaitForEndOfFrame(); yield return(new WaitForSeconds(0.15f)); // 안하면 EnemyList에 Transform 채워지기 전에 클리어 됨 while (true) { enemy.text = EnemyList.Count.ToString(); if (Player.Instance.hp <= 0) { GameOver(); } else if (EnemyList.Count <= 0) { Debug.Log("GameManager| EnemyList Size: " + EnemyList.Count); if (addCnt <= 0) { GameClear(); } else { EnemySpawner.Spawn(); } } yield return(wait); } }
// Use this for initialization protected void Start() { level2Rewards.SetActive(false); for (int i = 0; i < 5; i++) { spawner.Spawn(); } }
private IEnumerator Spawn() { foreach (var wave in waveStats.wave) { enemySpawner.Spawn(wave.enemy, wave.count); yield return(new WaitForSeconds(wave.count * waveStats.spawnInterval)); } }
void Update() { DetectCollision(); if (enemyKilled) { enemySpawner.Spawn(); enemyKilled = false; } }
public void EnemyDead(GameObject enemy) { enemies.Remove(enemy); if (enemies.Count == 0) { InitNextLevel(); spawner.Spawn(); } }
/// <summary> /// Spawns an enemy into the game. /// </summary> /// <typeparam name="T"> /// The type of enemy to spawn into the game. /// </typeparam> /// <param name="position"> /// Where the enemy should be spawned. /// </param> /// <returns> /// The spawned enemy. /// </returns> public T SpawnEnemy <T>(Vector2 position) where T : Enemy { // Spawn in the enemy. T enemy = _enemySpawner.Spawn <T>(position); // Keep track of this enemy. AddSpawnedEnemy(enemy); return(enemy); }
public override void OnInspectorGUI() { DrawDefaultInspector(); EnemySpawner myScript = (EnemySpawner)target; if (GUILayout.Button("SpawnEnemy")) { myScript.Spawn(); } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.K)) { Spawner1.Spawn(); } if (Input.GetKeyDown(KeyCode.L)) { Spawner1.DeleteLast(); } }
private IEnumerator StartGameRoutine() { resetPlayer(); enemySpawner.Spawn(300); screenFader?.CrossFadeAlpha(0f, delay, true); yield return(new WaitForSeconds(delay)); gameState = GameState.Playing; }
IEnumerator GameRoutine() { while (gameState == GameState.Running) { if (enemySpawner.SpawnedEnemies.Count <= 0) { enemySpawner.Spawn(); } yield return(null); } }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { initIfNeeded(); _playerLauncher.AwaitingInput = true; for (int i = 0; i < _spawnCount; i++) { Vector2 pos = new Vector2(); pos.x = Random.Range(-2f, 2f); pos.y = Random.Range(_spawner.MinSpawnY, _spawner.MaxSpawnY); _spawner.Spawn(pos); } }
void SpawnEnemies() { if (spawnAmount == 1) { enemySpawner.Spawn(EnemySpawner.EnemyType.EASY); return; } if (spawnAmount == 2) { enemySpawner.Spawn(EnemySpawner.EnemyType.HARD); return; } if (spawnAmount == 3) { enemySpawner.Spawn(EnemySpawner.EnemyType.MEDIUM); return; } for (int i = 0; i < Mathf.Log(spawnAmount, 2); i++) { if (coinToss()) { enemySpawner.Spawn(EnemySpawner.EnemyType.EASY); } else if (coinToss()) { enemySpawner.Spawn(EnemySpawner.EnemyType.MEDIUM); } else { enemySpawner.Spawn(EnemySpawner.EnemyType.HARD); } } }
// TODO: Work out the formulas for spawning enemies. public override void Start() { base.Start(); lost = true; Debug.Log("SpaceInvaderManager present"); float difficulty = DifficultyManager.instance.difficulty; int enemyAmount = EnemyFormula(difficulty); int bullets = BulletFormula(difficulty, enemyAmount); this.enemyAmount = enemyAmount; profGame.GetComponent <Shooter>().ammo = bullets; spawner.Spawn(enemyPrefabs[UnityEngine.Random.Range(0, enemyPrefabs.Count)], enemyAmount); }
private IEnumerator DelayPlayerSpawn() { yield return(null); player = Instantiate(playerPrefab, new Vector3(10, 0, 0), Quaternion.identity); if (EnemySpawnDebug) { var enemy = enemySpawner.Spawn(enemyType); enemy.transform.position = new Vector3(10, -10, 0); } Events.FireEvent(new PlayerSpawn { Player = player }); }
void Update() { if (Input.GetKey("r")) { if (_isSpawning) { return; } _isSpawning = true; _spawner.Spawn(SpawnType.Random); } else if (Input.GetKey("c")) { if (_isSpawning) { return; } _isSpawning = true; _spawner.Spawn(SpawnType.ClosestToPlayer); } else if (Input.GetKey("f")) { if (_isSpawning) { return; } _isSpawning = true; _spawner.Spawn(SpawnType.FurthestFromPlayer); } else { _isSpawning = false; } }
private void InitGameManager() { enemies.Clear(); isRunning = true; spawner = GameObject.Find("Spawner").GetComponent <EnemySpawner>(); levelTextOverlay = GameObject.Find("LevelTextOverlay"); levelText = GameObject.Find("LevelText").GetComponent <Text>(); gameOverOverlay = GameObject.Find("GameOver"); gameOverText = GameObject.Find("GameOverHelpText").GetComponent <Text>(); gameOverOverlay.SetActive(false); InitNextLevel(); spawner.Spawn(); }
private IEnumerator GameFlowCoroutine() { while (true) { yield return(new WaitForSeconds(Random.Range(currentBalance.minimumSpawnInterval, currentBalance.maximumSpawnInterval))); if (enemiesSpawnedCount < currentBalance.totalEnemies) { EnemySpawner randomEnemySpawner = GetRandomEnemySpawner(); BaseEnemy enemy = randomEnemySpawner.Spawn(currentBalance.health, currentBalance.moveSpeed); enemy.EnemyDieEvent += OnEnemyDie; enemiesSpawnedCount += 1; } } }
public void SetAlarm() { if (alerted) { return; } spawner.Spawn(); foreach (Electronic electronic in GameManager.manager.electronics) { if (electronic is Alarm && !electronic.disabled) { ((Alarm)electronic).SetOff(); } } alerted = true; }
public void LoadLevel(int level) { if (_levels.Count < level) { _levels.Add(GenerateRandomLevel()); Root.DBManager.SerializeAndSave(_levels); } Level l = _levels[level - 1]; _currentLevel = level - 1; Instantiate(_spawner.gameObject); _spawner.Spawn(l); StartGame(); }
private IEnumerator SpawnBatch(EnemyData[] data, int index, int totalEnemies) { for (int i = 0; index < totalEnemies && i < portals.Count; i++, index++) { var type = GetEnemyType(data, index); var enemy = enemySpawner.Spawn(type); enemy.transform.position = portals[i].transform.position; alive++; enemy.GetComponent <Death>().OnDeath += () => { alive--; events.FireEvent(new WaveEnemyChange { EnemiesLeft = alive }); }; } yield return(new WaitForSeconds(1f)); }