private void RpcProgressUpdate() { if (isServer) { progresses = pDiamondScript.progresses; } }
public static void WriteInstance(NetworkWriter writer, SyncListFloat items) { writer.Write((ushort)items.Count); foreach (float item in items) { float value = item; writer.Write(value); } }
public static SyncListFloat ReadInstance(NetworkReader reader) { ushort num = reader.ReadUInt16(); SyncListFloat syncListFloat = new SyncListFloat(); for (ushort num2 = 0; num2 < num; num2 = (ushort)(num2 + 1)) { syncListFloat.AddInternal(reader.ReadSingle()); } return(syncListFloat); }
public void SyncListFloatTest() { SyncListFloat serverList = new SyncListFloat(); SyncListFloat clientList = new SyncListFloat(); serverList.Add(1.0F); serverList.Add(2.0F); serverList.Add(3.0F); SerializeDeltaTo(serverList, clientList); Assert.That(clientList, Is.EquivalentTo(new[] { 1.0F, 2.0F, 3.0F })); }
public override void OnDeserialize(NetworkReader reader, bool initialState) { if (initialState) { SyncListFloat.ReadReference(reader, m_modifiedStats); } else { if (((int)reader.ReadPackedUInt32() & 1) == 0) { return; } SyncListFloat.ReadReference(reader, m_modifiedStats); } }
// Use this for initialization void Start() { rnd = new System.Random(); runOrder = new List <GameObject>(); /*for(int rc = 0; rc < ROOM_COUNT; rc++) * { * int traps = rnd.Next(3,6); * GameObject startRoom = possibleRoomList[rnd.Next(0, possibleRoomList.Count)]; * for(int i = 3; i< 6; i++) * { * startRoom.transform.GetChild(i).gameObject.SetActive(false); * } * startRoom.transform.GetChild(traps).gameObject.SetActive(true); * runOrder.Add(startRoom); * }*/ /*p1r1 = Instantiate(runOrder[0], p1Space); * p2r1 = Instantiate(runOrder[0], p2Space); * p3r1 = Instantiate(runOrder[0], p3Space); * p4r1 = Instantiate(runOrder[0], p4Space);*/ endGameStarted = false; gameStarted = false; //Unfill all progress player1progress.fillAmount = 0; player2progress.fillAmount = 0; player3progress.fillAmount = 0; player4progress.fillAmount = 0; //Initalize Cameras main.rect = new Rect(0, 0, 1, 1); //Deinitialize progress diamond progressCanvas.gameObject.SetActive(false); pDiamondScript = FindObjectOfType <ProgressDiamondScript>(); progresses = pDiamondScript.progresses; gameOver = false; player1RespawnPoint = p1Space.position; player2RespawnPoint = p1Space.position; startCamera.enabled = (false); }
public void CommSyncStart(NetworkManager mgr) { NetMgr = mgr; syncBall = true; // Only bother with x and z (can expand later) syncData = new SyncListFloat(); if (mgr.IsServer()) { syncData.Add(StoredPosition.x); syncData.Add(StoredPosition.z); syncData.Add(Direction.x); syncData.Add(Direction.z); } else { syncData.Callback = this.OnDataChanged; } }
public override bool OnSerialize(NetworkWriter writer, bool forceAll) { if (forceAll) { SyncListFloat.WriteInstance(writer, m_modifiedStats); return(true); } var flag = false; if (((int)syncVarDirtyBits & 1) != 0) { writer.WritePackedUInt32(syncVarDirtyBits); flag = true; SyncListFloat.WriteInstance(writer, m_modifiedStats); } if (!flag) { writer.WritePackedUInt32(syncVarDirtyBits); } return(flag); }