C#
2
Вклад в тег
version: "2.15.1"
services:
postgres:
image: postgres:13.3
environment:
POSTGRES_DB: "username"
POSTGRES_USER: "username"
POSTGRES_PASSWORD: "username"
PGDATA: "/var/lib/postgresql/data/pgdata"
volumes:
- ./Initer:/docker-entrypoint-initdb.d
- usr-data:/var/lib/postgresql/data
ports:
- "5437:5432"
volumes:
usr-data:
using UnityEngine;
using UnityEngine.Networking;
public class PlayerScrolWeapon : NetworkBehaviour
{
public GameObject[] weapon;
[SyncVar] int syncWeaponIndex;
private int weaponIndex = 0;
[Client]
void FixedUpdate()
{
ScrolWeapon();
if(isLocalPlayer)
CmdSendToServerSyncWeapon(weaponIndex);
SendToClientSyncWeapon();
}
void ScrolWeapon()
{
if(isLocalPlayer)
{
if(Input.GetAxisRaw("Mouse ScrollWheel") > 0f)
{
if (weaponIndex > 3)
weaponIndex = 0;
else
weaponIndex++;
}
else if(Input.GetAxisRaw("Mouse ScrollWheel") < 0f)
{
if (weaponIndex < 0)
weaponIndex = 3;
else
weaponIndex--;
}
for (int i = 0; i < 4; i++)
if (i == weaponIndex)
weapon[i].SetActive(true);
else
weapon[i].SetActive(false);
}
}
void SendToClientSyncWeapon()
{
if(!isLocalPlayer)
{
for (int i = 0; i < 4; i++)
if (i == syncWeaponIndex)
weapon[i].SetActive(true);
else
weapon[i].SetActive(false);
}
}
[Command]
void CmdSendToServerSyncWeapon(int _weaponIndex)
{
syncWeaponIndex = _weaponIndex;
}
}