void OnTriggerStay2D(Collider2D other) { if (other.tag == "enemy" || other.tag == "Boss") { var phase = GodTouch.GetPhase(); //タッチ判定 if (phase == GodPhase.Began) { startTime = Time.time; } else if (phase == GodPhase.Ended) { if (Time.time - startTime < CheckTime) { //相手のDamage関数を実行する if (other.tag == "enemy") { EnemyDamageScript Edam = other.GetComponent <EnemyDamageScript> (); Edam.Damage(); DamageSeScript DamSEScript = this.GetComponent <DamageSeScript>(); DamSEScript.EmemyDamageSound(); } else if (other.tag == "Boss") { BossDamageScript Bdam = other.GetComponent <BossDamageScript> (); Bdam.Damage(); DamageSeScript DamSEScript = this.GetComponent <DamageSeScript>(); DamSEScript.BossDamageSound(); } //相手がいたところにエフェクト Instantiate(AttackEffect, other.transform.position, Quaternion.identity); } } } }
private void Start() { rend = GetComponent<SpriteRenderer>(); enemyDmg = GetComponent<EnemyDamageScript>(); enemyMovement = GetComponent<Enemymovement>(); attack = GetComponent<AttackScript>(); boxCollider = GetComponent<Collider2D>(); sprite = GetComponent<SpriteRenderer>(); }