Files
DefendNJ/Assets/_DefendNJ/Scripts/Guns/NewGun/Gun4.cs

94 lines
2.3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using Mirror;
using UnityEngine;
//电球枪
public class Gun4 : Launcher
{
public GameObject xl;
[SyncVar]
private int frame = 0;
public override void Start()
{
// 主机自身
if (isServer && isClient && isOwned)
{
type = GunType.LightSphereGun;
AiInfo gunInfo = GameManager.Ins.AiInfos[(int)type];
shootRate = gunInfo.FiringRate;
recoil = 100;
if (hand == HandType.Left)
{
MRInput.Ins.RegisterHoldPressLeftTrigger(ClickLeftTrigger);
}
else if (hand == HandType.Right)
{
MRInput.Ins.RegisterHoldPressRightTrigger(ClickRrightTrigger);
}
}
// 主机其他
else if (isServer && isClient)
{
type = GunType.LightSphereGun;
AiInfo gunInfo = GameManager.Ins.AiInfos[(int)type];
shootRate = gunInfo.FiringRate;
recoil = 100;
}
// 从机自身
else if (isClient && isOwned)
{
if (hand == HandType.Left)
{
MRInput.Ins.RegisterHoldPressLeftTrigger(ClickLeftTrigger);
}
else if (hand == HandType.Right)
{
MRInput.Ins.RegisterHoldPressRightTrigger(ClickLeftTrigger);
}
}
}
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()
{
Debug.Log("点击右trigger");
CmdShoot();
}
[Command]
public void CmdShoot()
{
Shoot();
}
}