using System; using System.Collections; using System.Collections.Generic; using DG.Tweening; using JetBrains.Annotations; using Mirror; using UnityEngine; using UnityEngine.PlayerLoop; public class WeaponProp : NetworkBehaviour { public Collider box; public GameObject[] weapons; [SyncVar] public GunType weaponType; [SyncVar] public int amount = 0; [Server] public void Init(GunType type) { ShowWeapon(type); } [ClientRpc] public void ShowWeapon(GunType type) { weaponType = type; for (int i = 0; i < weapons.Length; i++) { weapons[i].SetActive(false); } switch (type) { case GunType.FireGun: weapons[0].SetActive(true); amount = 20; break; case GunType.LaserGun: weapons[1].SetActive(true); amount = 20; break; case GunType.LightSphereGun: weapons[2].SetActive(true); amount = 100; break; case GunType.BeamGun: weapons[3].SetActive(true); amount = 100; break; case GunType.GrenadeGun: weapons[4].SetActive(true); amount = 30; break; } } public void Start() { if (isServer) { transform.DORotate(new Vector3(0f, 360f, 0f), 5f, RotateMode.LocalAxisAdd).SetLoops(-1, LoopType.Restart); } } [Server] public void Collider() { box.enabled = false; transform.gameObject.SetActive(false); NetworkServer.Destroy(transform.gameObject); } }