예제 #1
0
 // Update is called once per frame
 void Update()
 {
     if (!ps.isPlaying && isReEnd == true)
     {
         Invoke("Restart", 2.0f);
         isReEnd = false;
     }
     else if (ps.isPlaying && isReEnd == true)
     {
         hit = Physics2D.Raycast(gb.transform.position, Vector2.up, 3.0f, 1 << LayerMask.NameToLayer("Player"));
         if (hit.collider != null && isHurt == false && hit.collider.tag.CompareTo("Player") == 0)
         {
             NewPlayerControll tp = hit.collider.gameObject.GetComponent <NewPlayerControll>();
             tp.CURHP -= 25;
             tp.HanleHp(tp.CURHP, tp.MAXHP);
             if (tp.CURHP < 0)
             {
                 tp.HandleDead();
             }
             tp.HandleHpColor();
             isHurt = true;
             Invoke("ReHurt", 2.2f);
         }
     }
 }
예제 #2
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag.CompareTo("Player") == 0)
     {
         NewPlayerControll tp = collision.gameObject.GetComponent <NewPlayerControll>();
         tp.CURHP -= 20;
         tp.HanleHp(tp.CURHP, tp.MAXHP);
         if (tp.CURHP < 0)
         {
             tp.HandleDead();
         }
         tp.HandleHpColor();
     }
 }
예제 #3
0
파일: m1SkillCol.cs 프로젝트: lzhanz/Unity
 void SkillRaycast()
 {
     hit = Physics2D.Raycast(this.transform.position, Vector2.up, 1.2f, 1 << LayerMask.NameToLayer("Player"));
     if (hit.collider != null)
     {
         if (hit.collider.tag.CompareTo("Player") == 0)
         {
             NewPlayerControll tp = hit.collider.gameObject.GetComponent<NewPlayerControll>();
             tp.CURHP -= 12;
             tp.HanleHp(tp.CURHP, tp.MAXHP);
             if (tp.CURHP < 0)
             {
                 tp.HandleDead();
             }
             tp.HandleHpColor();
         }
     }
 }
예제 #4
0
    private void BossRaycast(int hurnum, float distance)
    {
        Vector2 pos = _monster.trs.position;

        pos.x += _monster.trs.rotation.y == 0 ? 0.7f : -0.7f;
        pos.y -= 0.3f;
        hit    = Physics2D.Raycast(pos, _monster.trs.rotation.y == 0 ? Vector2.left : Vector2.right, distance, 1 << 8);
        Debug.DrawRay(pos, _monster.trs.rotation.y == 0 ? Vector2.left : Vector2.right, Color.red);
        if (hit.collider != null && hit.collider.tag.CompareTo("Player") == 0)
        {
            NewPlayerControll tp = hit.collider.gameObject.GetComponent <NewPlayerControll>();
            tp.CURHP -= hurnum;
            tp.HanleHp(tp.CURHP, tp.MAXHP);
            if (tp.CURHP < 0)
            {
                tp.HandleDead();
            }
            tp.HandleHpColor();
        }
    }
예제 #5
0
    public void FixedUpdate()
    {
        if (_monster.anim.GetFloat("Num") == -1)
        {
            Vector2 pos = _monster.trs.position;
            pos.x += _monster.trs.rotation.y == 0 ? -0.5f : 0.5f;
            pos.y += 1.0f;
            hit    = Physics2D.Raycast(pos, _monster.trs.rotation.y == 0 ? Vector2.left : Vector2.right, 0.8f, 1 << LayerMask.NameToLayer("Player"));

            if (hit.collider != null && hit.collider.tag.CompareTo("Player") == 0)
            {
                NewPlayerControll tp = hit.collider.gameObject.GetComponent <NewPlayerControll>();
                tp.CURHP -= 15;
                tp.HanleHp(tp.CURHP, tp.MAXHP);
                if (tp.CURHP < 0)
                {
                    tp.HandleDead();
                }
                tp.HandleHpColor();
            }
        }
    }