You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.2 KiB
67 lines
2.2 KiB
3 years ago
|
using HTC.UnityPlugin.Vive;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class BulletClip : MonoBehaviour {
|
||
|
public bool isUsed;
|
||
|
public int maxBulletNum;
|
||
|
public int nowBulletNum;
|
||
|
private GameObject handOff;
|
||
|
public GameObject self_;
|
||
|
public int Damage;
|
||
|
public GameObject bulletHole;
|
||
|
public GameObject bulletExplode;
|
||
|
//定义弹夹的类型(会被装在什么样的枪上)
|
||
|
//1为手枪
|
||
|
//2为冲锋枪
|
||
|
//--------往后依次进行设定--------//
|
||
|
public int Type;
|
||
|
|
||
|
// Use this for initialization
|
||
|
void Start () {
|
||
|
isUsed = true;
|
||
|
nowBulletNum = maxBulletNum;
|
||
|
handOff = GameObject.FindGameObjectWithTag("handOff");
|
||
|
}
|
||
|
|
||
|
// Update is called once per frame
|
||
|
void Update () {
|
||
|
/*if (nowBulletNum<=0 && isUsed) {
|
||
|
self_.GetComponent<Rigidbody>().isKinematic = false;
|
||
|
self_.transform.parent = handOff.transform;
|
||
|
isUsed = false;
|
||
|
}*/
|
||
|
|
||
|
}
|
||
|
public void DrawPieces(RaycastHit Hit_loaded)
|
||
|
{
|
||
|
GameObject Bullet_H = Transform.Instantiate(bulletHole);
|
||
|
Bullet_H.transform.position = new Vector3(Hit_loaded.point.x, Hit_loaded.point.y, Hit_loaded.point.z);
|
||
|
GameObject Bullet_Par = Transform.Instantiate(bulletExplode);
|
||
|
Bullet_Par.transform.position = new Vector3(Hit_loaded.point.x, Hit_loaded.point.y, Hit_loaded.point.z);
|
||
|
//Clamp强制取区间的数值,如果不在区间内则取最大/最小值
|
||
|
float angle_x = Mathf.Acos(Mathf.Clamp(Hit_loaded.normal.x, -1f, 1f)) * 180 / Mathf.PI - 90.0f;
|
||
|
float angle_y = Mathf.Asin(Mathf.Clamp(Hit_loaded.normal.y, -1f, 1f)) * 180 / Mathf.PI;
|
||
|
if (Hit_loaded.normal.z > 0.0f)
|
||
|
{
|
||
|
angle_x = 180 - angle_x;
|
||
|
}
|
||
|
//print(new Vector3(angle_y, angle_x, 0.0f));
|
||
|
if (Bullet_H.transform.eulerAngles.y != 0f)
|
||
|
{
|
||
|
Bullet_H.transform.eulerAngles += new Vector3(-angle_y, angle_x, 0.0f);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
Bullet_H.transform.eulerAngles += new Vector3(angle_y, angle_x, 0.0f);
|
||
|
}
|
||
|
Destroy(Bullet_H, 1.0f);
|
||
|
Destroy(Bullet_Par, 2.0f);
|
||
|
}
|
||
|
|
||
|
public GameObject getHandOff() {
|
||
|
return handOff;
|
||
|
}
|
||
|
}
|