void Spawn() { if (_randomSpawn != null) { _points = _randomSpawn.Spawn(2, 2f); } }
/// <summary> /// Zerstört den Feind, wenn er vom Schwert getroffen wird. /// (Wird aufgerufen von Sword.onCollisionDetected.) /// </summary> public void OnHitBySword() { RandomSpawn rs = GetComponent <RandomSpawn>(); if (rs != null) { GameObject item = rs.Spawn(); //Zufällig gespawnter Schatz. if (item != null) { item.transform.position = transform.position; } } GameObject explosion = Instantiate(explosionPrototype, transform.parent); explosion.transform.position = transform.position; SaveGameData.current.RecordDestroy(gameObject); //Destroy(gameObject); }
protected IEnumerator PlayOnHitBySwordAni() { isHitAniPlaying = true; RandomSpawn rs = GetComponent <RandomSpawn>(); if (rs != null) { GameObject item = rs.Spawn(); //Zufällig gespawnter Schatz. if (item != null) { item.transform.position = transform.position; } } SpriteRenderer sr = GetComponent <SpriteRenderer>(); for (int i = 0; i < destructionFrames.Length; i++) { sr.sprite = destructionFrames[i]; yield return(new WaitForSeconds(duration / destructionFrames.Length)); } SaveGameData.current.RecordDestroy(gameObject); }