public void PlayInstrument() { var controller = GetComponentInParent <BeatController>(); if (!controller.onBeat() || lastHit == controller.hit_count || dead) { return; } lastHit = controller.hit_count; audioSource.mute = false; spriteSwapper = GetComponent <SpriteSwapper>(); GetComponent <SpriteSwapper>().isPlaying = true; GameObject obj = Resources.Load <GameObject>("InstrumentEffect"); //obj = Instantiate(obj, transform.position, Quaternion.identity); obj = Instantiate(obj, transform); obj.transform.localPosition = Vector3.zero; InstrumentEffect instrumentEffect = obj.AddComponent <InstrumentEffect>(); instrumentEffect.SetSize(3f); // TODO: Change size based on something instrumentEffect.owner = this; instrumentEffect.counteredEnemy = counteredEnemy; instrumentEffect.SetColor(instrumentColor); Debug.Log(instrumentEffect.GetComponent <SpriteRenderer>().color); }
// Start is called before the first frame update public override void OnInstrumentHit(InstrumentEffect instrumentEffect) { if (type == instrumentEffect.counteredEnemy) { Vector2 direction = instrumentEffect.transform.position - transform.position; rbody.AddForce(-direction * 5f, ForceMode2D.Impulse); } }
public override void OnInstrumentHit(InstrumentEffect instrumentEffect) { if (type == instrumentEffect.counteredEnemy) { float strength = 1; //instrumentEffect.GetStrength(); transform.localScale -= new Vector3(0.25f, 0.25f, 0.25f) * strength; if (transform.localScale.x <= 0.3f) { Destroy(gameObject); } } }
public override void OnInstrumentHit(InstrumentEffect instrumentEffect) { if (type == instrumentEffect.counteredEnemy) { Vector2 direction = instrumentEffect.transform.position - transform.position; rbody.AddForce(-direction * 20f, ForceMode2D.Impulse); stunTimer = maxStun; } if (instrumentEffect.owner) { target = instrumentEffect.owner.gameObject; } }
public abstract void OnInstrumentHit(InstrumentEffect instrumentEffect);