void Die(bool touchedByPlayer = false) { if (isAlive) { if (squad != null) { squad.RemoveUnit(gameObject); } state = State.Dead; GameObject shapeHolder = transform.GetChild(0).GetChild(0).gameObject; rb.velocity = Vector3.zero; StartCoroutine(WaitBeforeHiddingExplosionGO(timer, meshOfShipOriginalForm[0].isVisible)); isAlive = false; if (touchedByPlayer) { UI2D.ResetKillTimer(); GameObject.FindGameObjectWithTag("UI2D").GetComponent <UI2D>().AddKill(); } } GameObject.FindGameObjectWithTag("Player").GetComponent <Ship>().CheckEnemyDeath(gameObject); gameObject.tag = "Wreck"; }
void Start() { ui = GameObject.FindGameObjectWithTag("UI2D").GetComponent <UI2D>(); List <WeaponState> weapons = player.GetComponentInChildren <WeaponShootManager>().listWeaponState; machineguns = new List <WeaponState>(); cursors = new List <GameObject>(); foreach (WeaponState ws in weapons) { if (ws.type == WeaponStat.WeaponType.MachineGun) { machineguns.Add(ws); cursors.Add(Instantiate(cursor)); } } foreach (GameObject go in cursors) { go.transform.SetParent(gameObject.transform, false); } StartCoroutine(InitUI()); }