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; } }
// Use this for initialization void Start() { parent = transform.root.root.root; parentscript = parent.GetComponent <movementctrl>(); sprite = GetComponentsInChildren <SpriteRenderer>(); spritecount = sprite.Length; sortinggroup = transform.parent.GetComponent <SortingGroup>(); }
//**************// // Use this for initialization void Awake() { startpos = transform.localPosition; transform.localPosition = Vector3.zero; parent = transform.parent.parent.parent; parentscript = parent.GetComponent <movementctrl>(); sprite = GetComponentsInChildren <SpriteRenderer>(); spritecount = sprite.Length; zeroVector = Vector3.zero; bodypos = transform.Find("bodypos"); if (havebullet) { bulletpt = transform.Find("bulletoutpt"); bullet = Resources.Load(bulletpath) as GameObject; } }
private float pauseEndTime, stopinterval = 1f; // useless now //****************************// // Use this for initialization void Start() { parent = transform.root.root.root; parentscript = parent.GetComponent <movementctrl>(); }
// Use this for initialization void Awake() { parentbody = transform.root.GetComponent <Rigidbody2D>(); parentscript = transform.root.GetComponent <movementctrl>(); }