Esempio n. 1
0
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "bullet")
     {
         HP -= 1;
         if (HP <= 0)
         {
             Instantiate(explode, new Vector3(transform.position.x, transform.position.y, transform.position.z - .1f), Quaternion.identity);
             Destroy(this.gameObject);
             control.Explode_sound();
             control.Addscore(2);
         }
     }
     if (other.gameObject.tag == "smallbullet")
     {
         HP -= 0.5f;
         if (HP <= 0)
         {
             Instantiate(explode, new Vector3(transform.position.x, transform.position.y, transform.position.z - .1f), Quaternion.identity);
             Destroy(this.gameObject);
             control.Explode_sound();
             control.Addscore(2);
         }
     }
     if (other.gameObject.tag == "lazer")
     {
         HP -= 0.1f;
         if (HP <= 0)
         {
             Instantiate(explode, new Vector3(transform.position.x, transform.position.y, transform.position.z - .1f), Quaternion.identity);
             Destroy(this.gameObject);
             control.Explode_sound();
             control.Addscore(2);
         }
     }
     if (other.gameObject.tag == "lazer2")
     {
         HP -= 0.2f;
         if (HP <= 0)
         {
             Instantiate(explode, new Vector3(transform.position.x, transform.position.y, transform.position.z - .1f), Quaternion.identity);
             Destroy(this.gameObject);
             control.Explode_sound();
             control.Addscore(2);
         }
     }
     if (other.gameObject.tag == "lazer3")
     {
         HP -= 0.3f;
         if (HP <= 0)
         {
             Instantiate(explode, new Vector3(transform.position.x, transform.position.y, transform.position.z - .1f), Quaternion.identity);
             Destroy(this.gameObject);
             control.Explode_sound();
             control.Addscore(2);
         }
     }
 }
Esempio n. 2
0
    void FixedUpdate()
    {//这是现在的移动脚本,通过单位向量和速度来移动,没有惯性,但是用小键盘移动可能会有问题
        float moveHorizontal, moveVertical;

        if ((Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A)) && transform.position.x >= -8.5)
        {
            moveHorizontal = -1;
        }
        else
        if ((Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D)) && transform.position.x <= 8.5)
        {
            moveHorizontal = 1;
        }
        else
        {
            moveHorizontal = 0;
        }
        if ((Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W)) && uptime < 0 && transform.position.y <= 7)
        {
            moveVertical = 1;
        }
        else
        if ((Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S)) && uptime < 0 && transform.position.y >= -6)
        {
            moveVertical = -1;
        }
        else
        {
            moveVertical = 0;
        }
        Vector3 direction = new Vector3(moveHorizontal, moveVertical, 0);

        if (Input.GetKey(KeyCode.LeftShift))
        {
            transform.position += direction.normalized * 0.5f * speed * Time.deltaTime; power_kind = 2;
        }
        else
        {
            transform.position += direction.normalized * speed * Time.deltaTime; power_kind = 1;
        }
        if (Input.GetKeyDown(KeyCode.B) && bome > 0 && bombcd <= 0)//允许放B的条件
        {
            bome -= 1;
            control.Explode_sound();
            Instantiate(Bomb, new Vector3(transform.position.x, transform.position.y, -2f), Quaternion.identity);
            bombcd = 1f;
        }
    }
Esempio n. 3
0
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "bullet")
     {
         HP -= 1;
         Destroy(other.gameObject);
         if (HP <= 0)
         {
             Instantiate(bossexplode, new Vector3(transform.position.x, transform.position.y, transform.position.z - .1f), Quaternion.identity);
             Destroy(this.gameObject);
             control.PlayerWin();
             control.Explode_sound();
             //bossmusic.Time_stop();
         }
     }
     if (other.gameObject.tag == "smallbullet")
     {
         HP -= 0.5f;
         Destroy(other.gameObject);
         if (HP <= 0)
         {
             Instantiate(bossexplode, new Vector3(transform.position.x, transform.position.y, transform.position.z - .1f), Quaternion.identity);
             Destroy(this.gameObject);
             control.PlayerWin();
             control.Explode_sound();
             //bossmusic.Time_stop();
         }
     }
     if (other.gameObject.tag == "lazer")
     {
         HP -= 0.1f;
         Destroy(other.gameObject);
         if (HP <= 0)
         {
             Instantiate(bossexplode, new Vector3(transform.position.x, transform.position.y, transform.position.z - .1f), Quaternion.identity);
             Destroy(this.gameObject);
             control.PlayerWin();
             control.Explode_sound();
         }
     }
     if (other.gameObject.tag == "lazer2")
     {
         HP -= 0.2f;
         Destroy(other.gameObject);
         if (HP <= 0)
         {
             Instantiate(bossexplode, new Vector3(transform.position.x, transform.position.y, transform.position.z - .1f), Quaternion.identity);
             Destroy(this.gameObject);
             control.PlayerWin();
             control.Explode_sound();
         }
     }
     if (other.gameObject.tag == "lazer3")
     {
         HP -= 0.3f;
         Destroy(other.gameObject);
         if (HP <= 0)
         {
             Instantiate(bossexplode, new Vector3(transform.position.x, transform.position.y, transform.position.z - .1f), Quaternion.identity);
             Destroy(this.gameObject);
             control.PlayerWin();
             control.Explode_sound();
         }
     }
 }