Files
MRCS/Assets/_MrCs/Scripts/Guns/PoisonGun.cs

98 lines
2.5 KiB
C#

using System.Collections;
using System.Collections.Generic;
using Mirror;
using UnityEngine;
public class PoisonGun : Launcher
{
private void Start()
{
if (isServer && isClient && isOwned)
{
type = GunType.DuQiGun;
GunInfo gunInfo = GameManager.Ins.GunInfos[type][1];
shootRate = gunInfo.ShootRate;
recoil = gunInfo.Recoil;
userTime = gunInfo.Time;
curUserTime = gunInfo.Time;
waitBulletTime = gunInfo.CoolDown;
if (hand == HandType.Left)
{
MRInput.Ins.RegisterHoldPressLeftTrigger(ClickLeftTrigger);
}
else if (hand == HandType.Right)
{
MRInput.Ins.RegisterHoldPressRightTrigger(ClickRrightTrigger);
}
}
// 主机其他
else if (isServer && isClient)
{
type = GunType.DuQiGun;
GunInfo gunInfo = GameManager.Ins.GunInfos[type][1];
shootRate = gunInfo.ShootRate;
recoil = gunInfo.Recoil;
userTime = gunInfo.Time;
curUserTime = gunInfo.Time;
//bullet_amount=gunInfo.BulletAmount;
waitBulletTime = gunInfo.CoolDown;
}
// 从机自身
else if (isClient && isOwned)
{
if (hand == HandType.Left)
{
MRInput.Ins.RegisterHoldPressLeftTrigger(ClickLeftTrigger);
}
else 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()
{
CmdShoot();
}
[Command]
public void CmdShoot()
{
Shoot();
}
}