/// <summary> /// Remove all enemies on the active scenes. /// Useful for example to end the level. /// </summary> public void RemoveAllEnemies() { Characters = new List <IsoObject>(); CharacterMovementScripts = new List <CharacterMovement>(); Characters.Add(GameObject.FindWithTag("Player").GetComponent <IsoObject>()); CharacterMovementScripts.Add(GameObject.FindWithTag("Player").GetComponent <CharacterMovement>()); List <GameObject> tAllEnemies = new List <GameObject>(); tAllEnemies.AddRange(GameObject.FindGameObjectsWithTag("SimpleEnemy")); tAllEnemies.AddRange(GameObject.FindGameObjectsWithTag("AdvancedEnemy")); tAllEnemies.AddRange(GameObject.FindGameObjectsWithTag("FollowEnemy")); for (int i = tAllEnemies.Count - 1; i >= 0; i--) { EnemyDie.Play(); Destroy(tAllEnemies[i]); } SimpleTimer = Random.Range(TimeBetweenSimplesMin, TimeBetweenSimplesMax); AdvancedTimer = Random.Range(TimeBetweenAdvancedMin, TimeBetweenAdvancedMax); FollowTimer = Random.Range(TimeUntilFollowerMin, TimeUntilFollowerMax); ActiveFollower = false; ActiveBlockChanger = false; }
protected virtual void Start() { enemy = GetComponent <Enemy>(); speedMove = enemy.MoveSpeed; enemyDie = GetComponent <EnemyDie>(); enemyDie.onReportMove += SetMove; }
protected override void OnDied() { base.OnDied(); GetComponent <Collider2D>().enabled = false; EnemyDie?.Invoke(this, EventArgs.Empty); GameplayCounter.getInstance().addMonster(); }
private void Instance_OnEnemyBoom(EnemyDie enemyboom) { if (EnemyManager.ContainsKey(enemyboom.enemy)) { if (EnemyManager[enemyboom.enemy] != null) { EnemyManager[enemyboom.enemy].GetComponent <BoomSoilder>().BoomToDie();; } } }
private void Instance_OnEnemyDie(EnemyDie enemydie) { if (EnemyManager.ContainsKey(enemydie.enemy)) { if (EnemyManager[enemydie.enemy] != null) { Destroy(EnemyManager[enemydie.enemy].gameObject); } } }
/// <summary> /// Remove an enemy to the list of active enemies. /// </summary> /// <param name="_Enemy">Transform of the instance of the enemy that will be removed.</param> public void RemoveEnemy(Transform _Enemy) { EnemyDie.Play(); if (_Enemy.tag == "BlockChangerEnemy") { ActiveBlockChanger = false; } Characters.Remove(_Enemy.GetComponent <IsoObject>()); Destroy(_Enemy.gameObject); }
/// <summary> /// Remove an enemy to the list of active enemies. /// </summary> /// <param name="_Enemy">Instance of the enemy that will be removed.</param> public void RemoveEnemy(IsoObject _Enemy) { EnemyDie.Play(); if (_Enemy.transform.tag == "BlockChangerEnemy") { ActiveBlockChanger = false; } Characters.Remove(_Enemy); Destroy(_Enemy.gameObject); }
private void InitStateMachine() { m_StateMachine = new StateMachine <Enemy>(); enemyDie = new EnemyDie(m_StateMachine); enemyFall = new EnemyFall(m_StateMachine); enemyFlee = new EnemyFlee(m_StateMachine); enemyIdle = new EnemyIdle(m_StateMachine); enemyJumping = new EnemyJumping(m_StateMachine); enemyWalk = new EnemyWalk(m_StateMachine); }
void OnCollisionEnter(Collision coll) { GameObject other = coll.gameObject; if (other.CompareTag("Enemy")) { if (other.GetComponent <EnemyDie> () != null) { EnemyDie otherDie = other.GetComponent <EnemyDie> (); otherDie.shouldShatter = false; otherDie.Die(Vector3.zero); sec.Grow(); rb.velocity = Vector3.zero; } } }
private void GenerateBonus(EnemyDie ev) { int roll = Random.Range(0, 100); int minIndex = -1; for (int i = 0; i < chances.Length; i++) { if ((roll < chances[i]) && ((minIndex < 0) || (chances[i] < chances[minIndex]))) { minIndex = i; } } if (minIndex > -1) { powerUps[minIndex].GetObject().Use(ev.Position); } }
private void ProcessEnemyDeath(EnemyDie ev) { AddScores(ev.Scores); }
public void HandleMessage(string message) { Debug.Log("HandleMessage:" + message); int target = message.IndexOf(":"); string tag = message.Substring(0, target); string content = message.Substring(target + 1); switch (tag) { case "register": if (OnRegisterResult != null) { OnRegisterResult(content); } break; case "login": if (OnLoginResult != null) { OnLoginResult(content); } break; case "createPlayer": RedayInfo redayinfo = GetData2 <RedayInfo>(content); if (OnCreatePlayer != null) { Debug.Log(content); OnCreatePlayer(redayinfo); } break; case "playerstatus": PlayerInfo player = GetData2 <PlayerInfo>(content); if (OnUpdataPlayer != null) { OnUpdataPlayer(player); } break; case "reday": if (content == "go!" && OnStartResult != null) { OnStartResult(content); } break; case "Tankstatus": Debug.Log(content); TankInfo tankinfo = GetData2 <TankInfo>(content); if (OnUpdateTank != null) { OnUpdateTank(tankinfo); } break; case "createEnemy": Debug.Log("收到创建"); enemyInfo enemyInfo = GetData2 <enemyInfo>(content); if (OnCreateEnemy != null) { OnCreateEnemy(enemyInfo); } break; case "GamePass": if (content == "first") { if (OnGameCount != null) { OnGameCount(content); } NetWorkManage.Instance.SendMessage("CreateEnemy:{\"enemy\":2}"); } else if (content == "second") { if (OnGameCount != null) { OnGameCount(content); } NetWorkManage.Instance.SendMessage("CreateEnemy:{\"enemy\":3}"); } else { SceneManager.LoadScene("Scenes/win"); } break; case "EnemyDie": EnemyDie enemydie = GetData2 <EnemyDie>(content); if (OnEnemyDie != null) { OnEnemyDie(enemydie); } break; case "EnemyBoom": EnemyDie enemyboom = GetData2 <EnemyDie>(content); if (OnEnemyBoom != null) { OnEnemyBoom(enemyboom); } break; case "PlayerUpdata": PlayerUpdata playerupdata = GetData2 <PlayerUpdata>(content); if (OnPlayerUpdata != null) { OnPlayerUpdata(playerupdata); } break; case "Enemytarget": NavMeshInfo navMeshInfo = GetData2 <NavMeshInfo>(content); if (OnWayPoint != null) { OnWayPoint(navMeshInfo); } break; case "MoneyUpdata": MoneyUpdata money = GetData2 <MoneyUpdata>(content); if (OnMoneyUpdata != null) { OnMoneyUpdata(money); } break; case "GameOver": SceneManager.LoadScene("Scenes/GameOver"); break; default: break; } }
public void Hit(GameObject go) { _ed = go.GetComponent<EnemyDie>(); _ed.Die(false, _power); }