void OnTriggerEnter2D(Collider2D col) { targetdir = parentscript.gettargetdir(); if (col.CompareTag("normal")) { hitbody = col.transform; normalscript = hitbody.GetComponent <normalai>(); //if (normalscript.checkincar()) //{ // normalscript.hitincar(hitcoefficient * (1 - hitbody.GetComponent<normalai>().checkslowpercent())); //} //else {} hitvel = hitcoefficient * targetdir * (basepower + (maxhitcharge)); normalscript.hit(hitvel); hitbody.GetComponent <health>().Hurt(damagecoefficient * (basedamage + (maxdamagecharge))); screenctrl.StopScreen(0.01f); return; } if (col.CompareTag("Player")) { hitbody = col.transform; playerscript = hitbody.GetComponent <movementctrl>(); hitvel = hitcoefficient * targetdir * (basepower + (maxhitcharge)); playerscript.hit(hitvel); hitbody.GetComponent <health>().Hurt(damagecoefficient * (basedamage + (maxdamagecharge))); screenctrl.StopScreen(0.01f); return; } }
void OnTriggerEnter2D(Collider2D col) { mousedir = parentscript.getmousedir(); charge = parentscript.getcharging(); if (col.CompareTag("normal")) { hitbody = col.transform; normalscript = hitbody.GetComponent <normalai>(); if (normalscript.checkincar()) { normalscript.hitincar(hitcoefficient * 1.5f * charge * (1 - normalscript.checkslowpercent())); } else { hitvel = hitcoefficient * mousedir * (basepower + (maxhitcharge * (charge / 100))); normalscript.hit(hitvel); } hitbody.GetComponent <health>().Hurt(damagecoefficient * (basedamage + (maxdamagecharge * (charge / 100)))); if (charge == 100) { screenctrl.StopScreen(0.05f); } return; } if (col.CompareTag("normal enemy")) { hitbody = col.transform; damage = damagecoefficient * (basedamage + (maxdamagecharge * (charge / 100))); hitbody.GetComponent <health>().Hurt(damage); incarscript = hitbody.GetComponent <ableincar>(); if (incarscript == null) { enemyscript = hitbody.GetComponent <enemyai>(); hitvel = hitcoefficient * mousedir * (basepower + (maxhitcharge * (charge / 100))); enemyscript.hit(hitvel, parent); enemyscript.CheckWillScared(damage, hitvel); } else { if (incarscript.checkincar()) { incarscript.hitincar(hitcoefficient * 1.5f * charge * (1 - incarscript.checkslowpercent())); } else { enemyscript = hitbody.GetComponent <enemyai>(); hitvel = hitcoefficient * mousedir * (basepower + (maxhitcharge * (charge / 100))); enemyscript.hit(hitvel, parent); enemyscript.CheckWillScared(damage, hitvel); } } if (charge == 100) { screenctrl.StopScreen(0.05f); } return; } if (col.CompareTag("bodyfragment")) { hitvel = hitcoefficient * 1.5f * mousedir * (basepower + (maxhitcharge * (charge / 100))); col.GetComponent <Rigidbody2D>().velocity = hitvel; return; } if (col.CompareTag("chest") || col.CompareTag("dropweapon")) { targetweight = col.GetComponent <dropweapon>().getweight(); hitvel = hitcoefficient * 1.5f * mousedir * (basepower + (maxhitcharge * (charge / 100))) * (10 / targetweight); col.GetComponent <Rigidbody2D>().velocity = hitvel; return; } }