public void OnTriggerEnter2D(Collider2D col) { //确保胶水只砸中一个目标 if (isHitHaze == false && this.name == "Player" && col.tag == "Haze") { isHitHaze = true; propTranslate = new Vector3(0, -0.2f, 0);//用于设置胶水相对主角或者NPC的偏移量 HitPlay(col); scriHazeCon = col.GetComponent <HazeControl>(); this.GetComponent <SpriteRenderer>().sprite = m_GlueEffectSpri; this.transform.rotation = Quaternion.identity; scriHazeCon.GetGlueHit(true); } else if (isHitPlay == false && this.name == "HazeAttack" && col.tag == "Player") { isHitPlay = true; propTranslate = new Vector3(0, -0.5f, 0); HitPlay(col); scriPlayCon = col.GetComponent <PlayerControl>(); scriPlayCon.GetGlueHit(true); scriPlayCon.SetGlue(this.gameObject); this.GetComponent <SpriteRenderer>().sprite = m_GlueEffectSpri; this.transform.rotation = Quaternion.identity; } if (col.tag == "EndOfGame") { Destroy(this.gameObject); } }
public void OnTriggerEnter2D(Collider2D col) { //确保胶水只砸中一个目标 if (isHitHaze == false && this.name == "Player" && col.tag == "Haze") { isHitHaze = true; propTranslate = new Vector3(0, -0.2f, 0);//用于设置胶水相对主角或者NPC的偏移量 HitPlay(col); scriHazeCon = col.GetComponent<HazeControl>(); this.GetComponent<SpriteRenderer>().sprite = m_GlueEffectSpri; this.transform.rotation = Quaternion.identity; scriHazeCon.GetGlueHit(true); } else if (isHitPlay == false && this.name == "HazeAttack" && col.tag == "Player") { isHitPlay = true; propTranslate = new Vector3(0, -0.5f, 0); HitPlay(col); scriPlayCon = col.GetComponent<PlayerControl>(); scriPlayCon.GetGlueHit(true); scriPlayCon.SetGlue(this.gameObject); this.GetComponent<SpriteRenderer>().sprite = m_GlueEffectSpri; this.transform.rotation = Quaternion.identity; } if (col.tag == "EndOfGame") Destroy(this.gameObject); }
void OnTriggerEnter2D(Collider2D col) { if (isInit == false && col.tag == "Player") { scriPropUI.AddProp(PropType.Skelon); Instantiate(effectOfEat, this.transform.position, Quaternion.identity); Instantiate(musicOfEat, this.transform.position, Quaternion.identity); Destroy(this.gameObject); } else if (isInit == true && isHitted == false && col.tag == "Haze") { isHitted = true; roVelo = new Vector3(0, 0, 0); Animator anim = this.GetComponent <Animator>(); target = col.GetComponent <HazeControl>(); transTarget = col.GetComponent <Transform>(); StartCoroutine("AttackSucc"); } }
void OnTriggerEnter2D(Collider2D col) { if (isInit == false && col.tag == "Player") { scriPropUI.AddProp(PropType.Skelon); Instantiate(effectOfEat, this.transform.position, Quaternion.identity); Instantiate(musicOfEat, this.transform.position, Quaternion.identity); Destroy(this.gameObject); } else if (isInit == true && isHitted == false && col.tag == "Haze") { isHitted = true; roVelo = new Vector3(0, 0, 0); Animator anim = this.GetComponent<Animator>(); target = col.GetComponent<HazeControl>(); transTarget = col.GetComponent<Transform>(); StartCoroutine("AttackSucc"); } }