public override void RoomInitialized(int dangerValue) { if (!EnemyPool.isPoolEmpty() && this.allSpawnedObstacles.Count > 0) { StartCoroutine(BeginBloomProcess(30 - (dangerValue / 10 * 20))); } }
public override EnemyType InvokeEnemies() { if (TimeCounter >= 30) { for (int i = 0; i < contador; i++) { Debug.Log("123"); EnemyPool pool = GameObject.Find("Pools").GetComponentInChildren <EnemyPool> (); GameObject rey = pool.GetEnemy(EnemyType.Rey); GameObject reina = pool.GetEnemy(EnemyType.Reina); Vector2 position = Random.insideUnitCircle * 15; while (position.magnitude < 10) { position = Random.insideUnitCircle * 15; } rey.transform.position = new Vector3(position.x, position.y); rey.GetComponent <GameEntityController> ().SetGameController(GameObject.Find("GameController").GetComponent <GameController> ()); position = Random.insideUnitCircle * 15; while (position.magnitude < 10) { position = Random.insideUnitCircle * 15; } reina.transform.position = new Vector3(position.x, position.y); reina.GetComponent <GameEntityController> ().SetGameController(GameObject.Find("GameController").GetComponent <GameController> ()); } TimeCounter = 0f; contador += 2; } return(EnemyType.Peon); }
/// <summary> /// Processes trigger collisions with other game objects /// </summary> /// <param name="other">information about the other collider</param> void OnTriggerEnter2D(Collider2D other) { // if colliding with teddy bear, add score, destroy teddy bear, // and return self to pool if (other.gameObject.CompareTag("Enemy")) { unityEvents[EventName.PointsAddedEvent].Invoke(ConfigurationUtils.BearPoints); Instantiate(prefabExplosion, other.gameObject.transform.position, Quaternion.identity); // Destroy(other.gameObject); Instantiate(prefabExplosion, transform.position, Quaternion.identity); BulletPool.ReturnBullets(gameObject); EnemyPool.ReturnEnemies(other.gameObject); } else if (other.gameObject.CompareTag("EnemyProjectile")) { // if colliding with teddy bear projectile, destroy projectile and // return self to pool Instantiate(prefabExplosion, other.gameObject.transform.position, Quaternion.identity); Destroy(other.gameObject); Instantiate(prefabExplosion, transform.position, Quaternion.identity); BulletPool.ReturnBullets(gameObject); } }
public void FullInit(Enemy eType, Transform target) { Init(eType, target); //Do things based on the settings. if (eType.movePattern == MovementType.Worm) { transform.up = Vector3.left; //instantiate other worm parts behind this one right away. EnemyBehaviour previousSegment = this; for (int i = 0; i < settings.chainLength - 1; i++) { var segment = EnemyPool.GetPoolObject(); segment.follow = previousSegment; //next segment should listen for when the segment in front of it died. previousSegment.OnEnemyDied += segment.SetHead; previousSegment = segment; //init the segment segment.Init(eType, target); segment.Body.position = Body.position + Vector2.right * i * settings.segmentSize; segment.transform.up = Vector3.left; } this.follow = null; } else { follow = PlayerController.current; } }
// Use this for initialization void Start() { ResetHealth(); _pool = GameObject.Find("Pools").GetComponentInChildren <EnemyPool>(); switch (EnemyType) { case EnemyType.Peon: brain = new PeonBrain(); break; case EnemyType.Alfil: brain = new AlfilBrain(); break; case EnemyType.Caballo: brain = new CaballoBrain(); break; case EnemyType.Torre: brain = new TorreBrain(); break; case EnemyType.Reina: brain = new ReinaBrain(this, invoke_enemies); break; case EnemyType.Rey: brain = new ReyBrain(this, invoke_enemies); break; case EnemyType.Kasparov: brain = new KasparovBrain(); break; } }
void Awake() { instance = this; enemyPool = new EnemyPool(); enemyPool.Initialize(100, enemyPrefab); }
private GameObject[] GenerateRow(Vector3 position, Transform parent) { var row = new GameObject[View._gridWidth]; for (int x = 0; x < View._gridWidth; ++x) { var newLocation = new Vector3(position.x + (x * View._gridCellSize), position.y, position.z + 1); var gridUnitType = UnityEngine.Random.Range(0, 100); GameObject gridUnitGO = null; if (gridUnitType <= 95) { gridUnitGO = SandPool.GetInstance(); row[x] = gridUnitGO; } else if (gridUnitType <= 97) { gridUnitGO = ItemPool.GetInstance(); } else if (gridUnitType <= 100) { gridUnitGO = EnemyPool.GetInstance(); } gridUnitGO.transform.localPosition = newLocation; gridUnitGO.transform.parent = parent; gridUnitGO.SetActive(true); } return(row); }
private void Initialize() { _score = 0; _levelConfig = new LevelConfig(); InitializeLocation(); _floor.Initialize(OnEnemyLeftArea); Player = new Player(); Player.Initialize(_levelConfig.PlayerConfig, _levelConfig.ProjectileConfig); CameraController cameraController = _cameraController.GetComponent <CameraController>(); cameraController.Initialize(this, Player.View.transform, _levelConfig.CameraConfig); _enemyPool = new EnemyPool(this, _levelConfig.EnemyConfig, _spawnPoints); _enemyPool.Initialize(); EventManager.OnEnemyDied += OnEnemyDied; _gui.Initialize(_levelConfig.PlayerConfig); _spawnController = Observable.FromCoroutine(SpawnEnemy).Subscribe(); }
private void AddAllEnemiesToPool() { foreach (Enemy enemy in FindObjectsOfType <Enemy>()) { EnemyPool.addEnemy(enemy); } }
private void Inject(ArenaConfig config, Player player, EnemyPool enemyPool, BonusPool bonusPool) { _config = config; _player = player; _enemyPool = enemyPool; _bonusPool = bonusPool; }
public UIController(InputModel inputModel, PointModel pointModel, EnemyPool enemyPool, PauseModel pauseModel) { _controllers = new ControllerList(); _pause = inputModel.Pause(); _pause.OnKeyPressed += OnPauseKeyPressed; _pointModel = pointModel; _pointModel.OnPointsChanged += OnPointsChanged; _enemyPool = enemyPool; _enemyPool.OnEnemyKilledAndReturned += OnEnemyKilled; _lastEnemyKilledPanelController = new LastEnemyKilledPanelController(); _scorePanelController = new ScorePanelController(); _pausePanelController = new PausePanelController(pauseModel); _nullPanelController = new NullPanelController(); _controllers.Add(_pausePanelController); _scorePanelController.SetText("0"); _pausePanelController.Close(); _pausePanelController.OnResumeButtonPressed += ChangePanelController; _currentPanelController = _nullPanelController; _controllers.Initialize(); }
// Use this for initialization private void Awake() { random = new Random(); KilledEnemies = 0; EnemyPool = GetComponent<EnemyPool>(); BattleShellPool = GetComponent<BattleShellPool>(); work = true; }
/// <summary> /// Use this for initialization /// </summary> void Start() { float widthRatio = (float)Screen.width / BaseWidth; float heightRatio = (float)Screen.height / BaseHeight; float resolutionRatio = (widthRatio + heightRatio) / 2; int spawnBorderSize = (int)(BaseBorderSize * resolutionRatio); // save spawn boundaries for efficiency // minSpawnX = spawnBorderSize; // maxSpawnX = Screen.width - spawnBorderSize; minSpawnY = spawnBorderSize; maxSpawnY = Screen.height - spawnBorderSize; // spawn and destroy a bear to cache collider values GameObject tempEnemy = EnemyPool.GetEnemies(); // GameObject tempBear = Instantiate(prefabEnemies) as GameObject; BoxCollider2D collider = tempEnemy.GetComponent <BoxCollider2D>(); teddyBearColliderHalfWidth = collider.size.x / 2; teddyBearColliderHalfHeight = collider.size.y / 2; // Destroy(tempBear); EnemyPool.ReturnEnemies(tempEnemy); // create and start timer spawnTimer = gameObject.AddComponent <Timer>(); spawnTimer.AddTimerFinishedEventListener(HandleSpawnTimerFinishedEvent); StartRandomTimer(); }
// Start is called before the first frame update new void Awake() { base.Awake(); enemyPool = GetComponentInParent <EnemyPool>(); canMove = false; direction = Mathf.Sign(enemyPool.Target.position.y - transform.position.y); }
private void SpawnEnemy() { // Get the enemy from the pool. Enemy.EnemyAI enemy = EnemyPool.GetInstance().Dequeue(); // Spawn enemy at a random spawnpoint in the array. enemy.gameObject.transform.position = spawnPoints[Random.Range(0, spawnPoints.Length)].position + new Vector3(0, 1, 0); }
void Start() { EnemyPool.removeEnemy(this); int whichCorner = Random.Range(1, 5); Vector3 spawnLocation; if (whichCorner == 1) { spawnLocation = new Vector3(-5, 5); } else if (whichCorner == 2) { spawnLocation = new Vector3(-5, -5); } else if (whichCorner == 3) { spawnLocation = new Vector3(5, 5); } else { spawnLocation = new Vector3(5, -5); } spawnLocation += Camera.main.transform.position; transform.position = spawnLocation; whatCornerSpawned = whichCorner; spawnFishMen(); }
protected override void OnZeroHP() { // When AI zero get's to be 0 or under, reward the player and re-pool this object. PlayerSettings.GetInstance().Funds += data.FundGiveAmount; PlayerSettings.GetInstance().Score += data.ScoreGiveAmount; EnemyPool.GetInstance().Enqueue(this); }
void Start() { GameObject play = (GameObject)Instantiate(player); if (play) { play.name = "Player"; } else { Debug.LogError("Could not find GameObject Player"); } enemy = (GameObject)Instantiate(enemPool); if (enemy) { enemy.name = "Enemy Pool"; enemyPool = enemy.GetComponent <EnemyPool>(); } else { Debug.LogError("Could not find GameObject EnemyPool"); } time = 0f; }
private void Start() { EnemyPool.addEnemy(this); randomPos = pickRandPos(); animator.enabled = false; mainCamera = Camera.main; }
IEnumerator spawnUnArmoured() { this.GetComponent <AudioSource>().Play(); animator.enabled = true; shattering = true; if (spriteRenderer.sprite == facingLeft) { animator.SetTrigger("Shatter1"); } else if (spriteRenderer.sprite == facingDown) { animator.SetTrigger("Shatter2"); } else if (spriteRenderer.sprite == facingUp) { animator.SetTrigger("Shatter4"); } else if (spriteRenderer.sprite == facingRight) { animator.SetTrigger("Shatter3"); } EnemyPool.enemyPool.Add(null); yield return(new WaitForSeconds(6f / 12f)); Destroy(this.gameObject); animator.enabled = false; GameObject spawnedSpearMan = Instantiate(unarmouredSpearman, transform.position, Quaternion.identity); EnemyPool.addEnemy(spawnedSpearMan.GetComponent <Enemy>()); this.GetComponent <Collider2D>().enabled = false; spawnedSpearMan.GetComponent <SkeletalSpearman>().health = 1; spawnedSpearMan.GetComponent <SkeletalSpearman>().travelAngle = travelAngle; }
private void LateUpdate() { foreach (KeyValuePair <FieldEffect, float> pair in m_enemyFieldEffect) { //current time < start time + duration if (pair.Key.effect == FieldEffect.EffectType.Damage && m_time < (pair.Value + pair.Key.duration)) { List <EnemyUnit> enemies = EnemyPool.GetPool(); for (int i = 0; i < enemies.Count; i++) { if (enemies[i].isActiveAndEnabled) { enemies[i].currentHp -= pair.Key.effectPower; } } } } foreach (KeyValuePair <FieldEffect, float> pair in m_slimeFieldEffect) { //current time < start time + duration if (pair.Key.effect == FieldEffect.EffectType.Damage && m_time < (pair.Value + pair.Key.duration)) { List <Unit> slimes = SlimePool.GetPool(); for (int i = 0; i < slimes.Count; i++) { if (slimes[i].isActiveAndEnabled) { slimes[i].currentHp -= pair.Key.effectPower; } } } } }
void LateUpdate() { if (Vector2.Distance(playerShip.transform.position, transform.position) < 5f && playerShip.GetComponent <PlayerScript>().enemiesDefeated == true && activated == false) { if (spawnedIndicator == null) { spawnedIndicator = Instantiate(examineIndicator, transform.position + new Vector3(0, 1f, 0), Quaternion.identity); spawnedIndicator.GetComponent <ExamineIndicator>().parentObject = this.gameObject; } if (playerShip.GetComponent <PlayerScript>().windowAlreadyOpen == false) { if (Input.GetKeyDown(KeyCode.E)) { numberWaves = whatTier + 1; playerScript.enemiesDefeated = false; activated = true; spawnedGrid = Instantiate(aStarGrid, transform.position, Quaternion.identity); animator.enabled = true; anti.trialDefeated = false; anti.spawnDoorSeals(); } } } else { if (spawnedIndicator != null) { Destroy(spawnedIndicator); } } if (activated == true && anti.trialDefeated == false && summoningEnemies == false) { if (EnemyPool.isPoolEmpty()) { if (currRound < numberWaves) { currRound++; StartCoroutine(generateEnemies()); } else { animator.enabled = true; animator.SetTrigger("Exhaust"); this.GetComponents <AudioSource>()[1].Play(); GameObject instant = Instantiate(chestParticles, transform.position + new Vector3(0, 1.5f, 0), Quaternion.identity); instant.GetComponent <CrystalParticles>().target = transform.position + new Vector3(0, -2f, 0); anti.trialDefeated = true; playerScript.enemiesDefeated = true; GameObject.Find("PlayerShip").GetComponent <PlayerScript>().enemiesDefeated = true; if (spawnedGrid) { Destroy(spawnedGrid); } } } } }
private void Start() { spriteRenderer = GetComponent <SpriteRenderer>(); if (addToPool) { EnemyPool.addEnemy(this); } }
void Start() { spriteRenderer = GetComponentsInChildren <SpriteRenderer>()[0]; playerShip = GameObject.Find("PlayerShip"); FindObjectOfType <BossHealthBar>().bossStartUp("Awakened Stone Giant"); FindObjectOfType <BossHealthBar>().targetEnemy = this; EnemyPool.addEnemy(this); }
void AddToPool(EnemyPool enemyPool) { Enemy newEnemy = Instantiate(enemyPool.enemy) as Enemy; pool.Add(newEnemy); newEnemy.isPooled = true; newEnemy.transform.SetParent(poolObjects.transform); newEnemy.gameObject.SetActive(false); }
public void SetStageBase(StageInfoBase stage) { stageInfo = stage; Waves = stage.enemyWaves; stageLevel = stage.monsterLevel; EnemyPool = new EnemyPool(ResourceManager.Instance.EnemyPrefab); DamageTextPool = new DamageTextPool(ResourceManager.Instance.DamageTextPrefab); }
public Enemy GetEnemyAt(Vector2 pos, float zRot) { EnemyPool pool = GetEnemyPool(GetAbilitableEnemy()); Enemy e = pool.GetAt(pos, zRot); e.Active = true; return(e); }
void Start() { playerShip = GameObject.Find("PlayerShip"); GameObject.Find("PlayerShip").GetComponent <PlayerScript>().enemiesDefeated = false; FindObjectOfType <BossHealthBar>().bossStartUp("Serpent Colossus"); FindObjectOfType <BossHealthBar>().targetEnemy = this; EnemyPool.addEnemy(this); }
void AddToPool(EnemyPool enemyPool) { Enemy newEnemy = Instantiate(enemyPool.enemy) as Enemy; pool.Add(newEnemy); newEnemy.isPooled = true; newEnemy.transform.SetParent(poolObjects.transform); newEnemy.gameObject.SetActive(false); }
void Start() { bulletPool = transform.FindChild("Bullets").GetComponent <BulletPool>(); enemyPool = transform.FindChild("Enemies").GetComponent <EnemyPool>(); greenPool = transform.FindChild("Greens").GetComponent <GreenPool>(); lootPool = transform.FindChild("Loot").GetComponent <LootPool>(); objectSpawner = GetComponent <ObjectSpawner>(); generateMap(MapType.rockyForest); }
private void Start() { mainCamera = Camera.main; StartCoroutine(attackProcedure()); healthBar = FindObjectOfType <BossHealthBar>(); healthBar.bossStartUp("Adamantoise"); healthBar.targetEnemy = this; EnemyPool.addEnemy(this); }
void Awake() { if (instance == null) instance = this; else Destroy(this); ActivePool = new List<EnemyBase>(); InActivePool = new List<EnemyBase>(); }
public EnemySpawner(EnemyPool[] enemyPools) { _manager = GameObject.FindObjectOfType<EnemyManager>(); _enemyPools = enemyPools; _totalEnemies = 0; _spawnCount = 0; foreach (EnemyPool pool in _enemyPools) { _totalEnemies += pool.count; } //DebugPrint(); //~jus fo debug SetSpawnType(SpawnType.LINEAR); }
void Update() { if (instance == null) instance = this; }
public void SetEnemyManager(EnemyPool p_enemyManager) { m_enemyManager = p_enemyManager; }
public SpawnEnemy_Command(EnemyPool p_enemyPool, Vector2 p_spawnPosition) { m_spawnPosition = p_spawnPosition; m_enemyPool = p_enemyPool; }
public void AddSpawnEnemyCommand(EnemyPool p_enemyPool, Vector2 m_position) { if (!m_isRewinding) { m_currentFrame.Value.AddFirst(new SpawnEnemy_Command(p_enemyPool, m_position)); m_currentFrame.Value.First.Value.Execute(); //execute the command you just added } }