Files
Zombie/Assets/_Zombie/Scripts/Guns/NewGun/BeamGun.cs

87 lines
2.0 KiB
C#

using System.Collections;
using System.Collections.Generic;
using Mirror;
using UnityEngine;
public class BeamGun : Launcher
{
public override void Start()
{
// 主机自身
if (isServer && isClient && isOwned)
{
type = GunType.BeamGun;
GunInfo gunInfo = GameManager.Ins.GunInfos[type];
shootRate = gunInfo.ShootRate;
recoil = gunInfo.Recoil;
if (hand == HandType.Right)
{
MRInput.Ins.RegisterHoldPressRightTrigger(ClickRrightTrigger);
}
}
// 主机其他
else if (isServer && isClient)
{
type = GunType.BeamGun;
GunInfo gunInfo = GameManager.Ins.GunInfos[type];
shootRate = gunInfo.ShootRate;
recoil = gunInfo.Recoil;
}
// 从机自身
else if (isClient && isOwned)
{
if (hand == HandType.Right)
{
MRInput.Ins.RegisterHoldPressRightTrigger(ClickRrightTrigger);
}
}
}
private void OnDestroy()
{
MRInput.Ins.UnregisterHoldPressRightTrigger(ClickRrightTrigger);
}
public void Update()
{
if (!isOwned)
{
return;
}
// 左手
if (hand == HandType.Left)
{
transform.position = GameLocal.Ins.self.LeftHand.position;
transform.rotation = GameLocal.Ins.self.LeftHand.rotation;
}
// 右手
else if (hand == HandType.Right)
{
transform.position = GameLocal.Ins.self.RightHand.position;
transform.rotation = GameLocal.Ins.self.RightHand.rotation;
}
}
[Client]
public void ClickLeftTrigger()
{
//Debug.Log("点击左trigger");
CmdShoot();
}
[Client]
public void ClickRrightTrigger()
{
MRInput.Ins.VibrateRightController(0.4F, 50, 300);
CmdShoot();
}
[Command]
public void CmdShoot()
{
Shoot();
}
}