// Use this for initialization void Awake() { startpos = transform.localPosition; transform.localPosition = Vector3.zero; parent = transform.parent.parent.parent; enemyscript = parent.GetComponent(typeof(enemyai)) as enemyai; sprite = GetComponentsInChildren <SpriteRenderer>(); spritecount = sprite.Length; }
// Use this for initialization void Awake() { imgRenderer = GetComponent <SpriteRenderer>(); parent = transform; for (int i = 0; i < parentstack; i++) { parent = parent.parent; } enemyscript = parent.GetComponent <enemyai>(); frontimg = imgRenderer.sprite; }
void Start() { recover(); healthbarupdate(); if (CompareTag("normal")) { normalscript = transform.GetComponent <normalai>(); } else if (CompareTag("normal enemy")) { enemyscript = transform.GetComponent <enemyai>(); } }
void OnCollisionEnter2D(Collision2D col) { colobject = col.transform; if (colobject.CompareTag("normal enemy")) { enemyscript = colobject.GetComponent <enemyai>(); if (enemyscript.IsScared() && !enemyscript.IsHit()) { colobject.tag = "runningenemy"; colobject.gameObject.layer = 18; } } }
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; } }
// Use this for initialization void Start() { parent = transform.parent.parent.parent.parent; parentscript = parent.GetComponent(typeof(enemyai)) as enemyai; }