public void SpawnOne() { nbSpawned++; Vector3 pos = Random.onUnitSphere; pos.y = 0; pos.Normalize(); pos *= spawnRadius; // instanciation GameObject alien = Instantiate(alienPrefab, pos, transform.rotation) as GameObject; // set la destination int i = Random.Range(0, defend.Length); NavMeshAgent nma = alien.GetComponent <NavMeshAgent>(); nma.destination = defend[i].transform.position; // config l'ai du monstre alienAI alienai = alien.GetComponent <alienAI>(); float scale = Random.Range(minSize, maxSize); alien.transform.localScale = Vector3.one * scale; alienai.defendMe = defend[i]; alienai.score = score; //stocker dans liste enemies.Add(alienai); }
void OnCollisionEnter(Collision collision) { Destructible destructible; if ((destructible = collision.collider.GetComponent <Destructible>()) != null && destructible.layerNo == damager.layerNo) { Debug.Log("Hit sth destructible"); destructible.TakeDamage(damager, collision.contacts[0]); alienAI al = null; if ((al = destructible.GetComponent <alienAI>()) != null) { al.Explode(collision); } } else { Debug.Log("Hit sth"); } }
private void OnTriggerEnter(Collider other) { alienAI ai = null; if ((ai = other.gameObject.GetComponent <alienAI>()) != null && ai.isdead) { //anim.SetTrigger("die"); Destroy(this.gameObject, 1); anim.SetTrigger("die"); s.addScore(pointsValue); //Debug.Log("Target Hit"); onTargetHit.Invoke(); onTargetDestroy.Invoke(this); if (soundIsHit != null) { soundIsHit.Play(); } Destroy(this); } }
private void Start() { ai = GetComponentInParent <alienAI>(); }
public void RemoveAI(alienAI ai) { enemies.Remove(ai); }