private void OnTriggerEnter2D(Collider2D collision) { //Vector3 vector = gameObject.transform.eulerAngles; Heathscrips health = collision.gameObject.GetComponent <Heathscrips>();//获取碰撞对象的健康 // print(collision.gameObject.name); if (collision.gameObject.tag == "ground" && !ishack) { if (damageelect != null) //如果有粒子效果 { particlescrips.particl.instantiate(damageelect, transform.position); //进行一次粒子效果 } Destroy(gameObject); } if (health != null && health.isenemay != isenemy) { health.Damage(damage); destroy(health.gameObject); Vector2 forcer = gameObject.transform.right * force; collision.gameObject.GetComponent <move>().AddSpeeds(forcer); //给予对象物理击退 backer(forcer); //给予自身物理击退 } }
//以下是其他函数,用来具体控制 protected override void Awakes() { dash = gameObject.GetComponent <Dash>(); health = gameObject.GetComponent <Heathscrips>(); attack = gameObject.GetComponent <Attack>(); jump = gameObject.GetComponent <Jump>(); moves = gameObject.GetComponent <Moves>(); }
private void Awake() { if (player != null) { hps = player.gameObject.GetComponent <Heathscrips>(); } size = gameObject.transform.localScale; maxhealth = hps.qimax; }
private void OnTriggerExit2D(Collider2D collision) { Heathscrips health = collision.gameObject.GetComponent <Heathscrips>(); if (health != null) { if (health.isenemay != gameObject.GetComponentInParent <Heathscrips>().isenemay) { insight = true; target = null; } } }
public void dash(Charactercontral a) {//冲刺 Heathscrips health = gameObject.GetComponent <Heathscrips>(); if (a.GetStatenum() < 2 && (health == null || health.cando())) { animator.SetBool("dashing", true); move.setX(0); move.setY(0); contral = a; dashes = dashtime; //dash的时间设置为dashtime contral.Setstatenum(3); //技能状态 right = move.Turn(); if (health != null) { health.consumeqi(6); } } }
private bool jumping;//是否在自主跳跃的途中,用于判断是否会废气 private void Awake() { move = GetComponent <move>();//进行角色方向控制时就调用move中的函数 contral = GetComponent <Charactercontral>(); health = gameObject.GetComponent <Heathscrips>(); }
private void Awake() { weapons = GetComponentsInChildren <weaponscript>();//从子物体中获取武器 health = GetComponent <Heathscrips>(); contral = GetComponent <Charactercontral>(); }
//以下是其他函数,用来具体控制 protected override void Awakes() { dash = gameObject.GetComponent <Dash>(); health = gameObject.GetComponent <Heathscrips>(); }