public void CreateRespondWaveInDir(Vector3 position, string layerName, Vector3 dir) { //flash effect GameObject layer = GameObject.Find("/LayerMask/" + layerName); GameObject effect = Instantiate(FlashEffect, layer.transform.position, Quaternion.identity) as GameObject; effect.transform.parent = layer.transform.parent; SpriteRenderer effectSprite = effect.GetComponent <SpriteRenderer> (); SpriteRenderer layerSprite = layer.GetComponent <SpriteRenderer> (); effectSprite.sortingOrder = layerSprite.sortingOrder + 1; effectSprite.sprite = layerSprite.sprite; SoundFXCtrl.instance.PlaySound((AudioClip)LayerAudioTable[DataManager.instance.GetLayerProperty(layerName).type], 1); //create respond wave GameObject respondWave = Instantiate(RespondWave, position, Quaternion.identity) as GameObject; RespondWave respondScript = respondWave.GetComponent <RespondWave> (); respondScript.layername = layerName; //respondScript.wavecolor = DataManager.instance.GetColorOfLayerName (layerName); //respondWave.transform.up = -dir; respondScript.wavecolor = Color.white; respondWave.transform.rotation = Quaternion.LookRotation(Vector3.forward, dir); respondWave.transform.parent = waves; }
public void CreateRespondWave(Vector3 position, string layerName) { //flash effect GameObject layer = GameObject.Find("/LayerMask/" + layerName); GameObject effect = Instantiate(FlashEffect, layer.transform.position, Quaternion.identity) as GameObject; effect.transform.parent = layer.transform.parent; SpriteRenderer effectSprite = effect.GetComponent <SpriteRenderer> (); SpriteRenderer layerSprite = layer.GetComponent <SpriteRenderer> (); effectSprite.sortingOrder = layerSprite.sortingOrder + 1; effectSprite.sprite = layerSprite.sprite; SoundFXCtrl.instance.PlaySound((AudioClip)LayerAudioTable[DataManager.instance.GetLayerProperty(layerName).type], 1); //create respond wave Vector3 randomReceivePos = LeftBound.position; randomReceivePos.x += Random.Range(0f, horRespownPos); GameObject respondWave = Instantiate(RespondWave, position, Quaternion.identity) as GameObject; RespondWave respondScript = respondWave.GetComponent <RespondWave> (); respondScript.layername = layerName; respondScript.wavecolor = DataManager.instance.GetColorOfLayerName(layerName); respondWave.transform.up = randomReceivePos - position; respondWave.transform.parent = waves; }