Vector2 direction; // for now should not change during travel private void Start() { LS = GetComponent <ListAnimation>(); FX = GetComponent <SpawnFX>(); if (LS != null) { LS.PlayAnimation(0); primeTime = LS.currentAniTime(); //Debug.Log(primeTime); } bool f = false; if (transform.lossyScale.x > 0) { f = true; } direction = Menu.UsefulStuff.FromRotationToVector(transform.rotation.eulerAngles.z, f); if (FX != null) { FX.DoFX(direction, transform.position, 30, 10, new int[] { 0 }, 3); } SR = GetComponent <SpriteRenderer>(); SR.sortingOrder = Random.Range(-5, 6); }
private void DoDamage(Transform cg, Vector2 point) { Character.Health h; if (cg.CompareTag("Player") && primeTime > 0) { return; } if (Random.Range(0, accuracy) == 0) { return; } h = cg.GetComponent <Character.Health>(); bool pierce = true; if (h != null) { pierce = h.DealDamage(Dmg, transform.position, direction, punch); } /*if (punch != 0) { * //Rigidbody2D rb = GetComponent<Rigidbody2D>(); * float f = 1 ; * bool flip=false; * if (transform.lossyScale.x < 0) { f=-1; flip = true; } * //Replace with health punch * h.GetComponent<Rigidbody2D>().AddForceAtPosition( * Menu.UsefulStuff.FromRotationToVector(transform.rotation.eulerAngles.z,flip).normalized* * -punch,cg.position * , ForceMode2D.Impulse); * }*/ if (!pierce | Apierce < 1) { Evaporate(); return; } Apierce--; if (FX != null) { FX.DoFX(-direction, transform.position, 10, 3, new int[] { 3 }, 1); } //Debug.Log("Doing damage!"); }
private void Update() { if (fx) { if (fxcount > 0) { fxcount -= Time.deltaTime; } else { FX.DoFX(new Vector2(0, 1), transform.position, 90, 10, fxd, 1); fxcount = fxtime; } } timer -= Time.deltaTime; if (timer < 0) { Destroy(gameObject); } }