Ejemplo n.º 1
0
        protected void PrepareSimulation(SimulationParameters parameters)
        {
            Simulation = new NetworkSimulation(parameters);

            Connection = Simulation.Connect("InstanceID");

            LocalStorage = new LocalStorageSimulation(parameters);

            Engine = new Engine(
                new EngineConfiguration
            {
                Connection   = Connection,
                LocalStorage = LocalStorage,
            });
        }
Ejemplo n.º 2
0
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.IsWriting)
        {
            // Position
            Vector3 _pos = transform.position;
            stream.SendNext(_pos.x);
            stream.SendNext(_pos.z);
            // Rotation
            stream.SendNext(transform.rotation.eulerAngles.y);
            // Combat
            stream.SendNext(bulletsFired);
            bulletsFired = 0;
        }
        else
        {
            if (PlayerManager.LocalPlayerPrefab != null && networkSimulation == null)
            {
                networkSimulation = PlayerManager.LocalPlayerPrefab.GetComponentInChildren <NetworkSimulation>();
            }
            // Position
            float posX = (float)stream.ReceiveNext();
            float posZ = (float)stream.ReceiveNext();
            // Rotation
            float rotationY = (float)stream.ReceiveNext();
            // Combat
            bulletsFired += (byte)stream.ReceiveNext();

            if (networkSimulation != null)
            {
                float _packetLoss = networkSimulation.GetPacketLossPercentage() / 100.0f;
                float _rand       = randomNumbers[randomIndex];
                randomIndex = (randomIndex + 1) % randomNumbers.Length;

                if ((1.0f - _packetLoss) > _rand)
                {
                    previousPosition = transform.position;
                    newPosition      = new Vector3(posX, transform.position.y, posZ);
                    previousRotation = transform.rotation;
                    newRotation      = Quaternion.Euler(previousRotation.x, rotationY, previousRotation.z);

                    timeSinceLastUpdate = 0;
                }
            }
        }
    }
Ejemplo n.º 3
0
 public NetworkInterface(NetworkSimulation simulation, DeviceNode devNode)
 {
     _simulation = simulation;
     _devNode    = devNode;
 }
Ejemplo n.º 4
0
 public void BeforeEach()
 {
     simulation = new NetworkSimulation();
 }
Ejemplo n.º 5
0
        internal SimulatedConnection(SimulationParameters parameters)
        {
            simulation = parameters.Simulation;

            _ServiceState = parameters.ServiceState;
        }
Ejemplo n.º 6
0
 public HackStartInfo(NetworkSimulation netSim, SaveManager saveManager, Hackable hackable)
 {
     _netSim      = netSim;
     _saveManager = saveManager;
     _hackable    = hackable;
 }