本文整理汇总了C#中PhotonStream.ReceiveNext方法的典型用法代码示例。如果您正苦于以下问题:C# PhotonStream.ReceiveNext方法的具体用法?C# PhotonStream.ReceiveNext怎么用?C# PhotonStream.ReceiveNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhotonStream
的用法示例。
在下文中一共展示了PhotonStream.ReceiveNext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnPhotonSerializeView
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if (stream.isWriting) {
//We own this player: send the others our data
stream.SendNext(transform.position);
if(GetComponent<PlayerMult>())
stream.SendNext(GetComponent<PlayerMult>().velocity);
// else if(GetComponent<Wind>())
// stream.SendNext(GetComponent<Wind>().velocity);
else
stream.SendNext(Vector3.zero);
}
else {
//Network player, receive data
Vector3 syncPosition = (Vector3)stream.ReceiveNext();
syncVelocity = (Vector3)stream.ReceiveNext();
//Debug.Log ("INCOMING");
syncTime = 0f;
syncDelay = Time.time - lastSynchronizationTime;
lastSynchronizationTime = Time.time;
syncEndPosition = syncPosition + syncVelocity * syncDelay;
syncStartPosition = transform.position;
}
}
示例2: OnPhotonSerializeView
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if(stream.isWriting)
{
// this is my player. need to send my actual position to the network
stream.SendNext(transform.position);
stream.SendNext(_charController.velocity);
stream.SendNext(transform.rotation);
}
else
{
//this is another player. need to get his position data. then update my version of this player
Vector3 syncPosition = (Vector3)stream.ReceiveNext();
Vector3 syncVelocity = (Vector3)stream.ReceiveNext();
syncEndRotation = (Quaternion)stream.ReceiveNext();
syncStartRotation = transform.rotation;
syncTime = 0f;
syncDelay = Time.time - lastSynchronizationTime;
lastSynchronizationTime = Time.time;
syncEndPosition = syncPosition + syncVelocity * syncDelay;
syncStartPosition = transform.position;
}
}
示例3: OnPhotonSerializeView
void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if (stream.isWriting)
{
// write time & position to stream
stream.SendNext(PhotonNetwork.time);
// send orientation
stream.SendNext( (double)transform.rotation.eulerAngles.y); // get Y-rotation
}
else
{
// receive keyframe
double time = (double)stream.ReceiveNext();
double orientation = (double)stream.ReceiveNext();
if (m_OrientationKeyframesList == null) m_OrientationKeyframesList = new KeyframeList<double>();
m_OrientationKeyframesList.Add(time, orientation);
if (m_OrientationKeyframesList.Count > 2)
{
//Debug.Log("removing old keyframes");
// remove old keyframes ( let's say 5 seconds old? )
m_OrientationKeyframesList.RemoveAllBefore(time - 5);
}
}
}
示例4: OnPhotonSerializeView
void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if (stream.isWriting)
{
//We own this player: send the others our data
stream.SendNext((int)controllerScript._characterState);
stream.SendNext(transform.position);
stream.SendNext(transform.rotation);
}
else
{
//Network player, receive data
controllerScript._characterState = (CharacterState)(int)stream.ReceiveNext();
correctPlayerPos = (Vector3)stream.ReceiveNext();
correctPlayerRot = (Quaternion)stream.ReceiveNext();
// avoids lerping the character from "center" to the "current" position when this client joins
if (firstTake)
{
firstTake = false;
this.transform.position = correctPlayerPos;
transform.rotation = correctPlayerRot;
}
}
}
示例5: OnPhotonSerializeView
void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if(stream.isWriting)
{
stream.SendNext(transform.position);
stream.SendNext(transform.rotation);
if(anim.IsPlaying("Run"))
{
stream.SendNext(useThisMove = 1);
}
if(anim.IsPlaying ("Idle"))
{
stream.SendNext (useThisMove = -1);
}
if(anim.IsPlaying ("AutoAttack"))
{
stream.SendNext(useThisMove = -2);
}
}
else
{
realPosition = (Vector3)stream.ReceiveNext();
realRotation = (Quaternion)stream.ReceiveNext();
useThisMove = (int)stream.ReceiveNext();
}
}
示例6: OnPhotonSerializeView
void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
UnityEngine.Debug.Log("point");
if (stream.isWriting)
{
var pointText = GameObject.Find("Point").GetComponent<Text>();
string point = pointText.text;
// We own this player: send the others our data
stream.SendNext(transform.position);
stream.SendNext(transform.rotation);
UnityEngine.Debug.Log(pointText.text);
stream.SendNext(pointText.text);
UnityEngine.Debug.Log("point2");
}
else
{
// Network player, receive data
this.correctPlayerPos = (Vector3)stream.ReceiveNext();
this.correctPlayerRot = (Quaternion)stream.ReceiveNext();
UnityEngine.Debug.Log((Vector3)stream.ReceiveNext());
var pointText = GameObject.Find("EnemyPoint").GetComponent<Text>();
UnityEngine.Debug.Log("point3");
pointText.text = (string)stream.ReceiveNext();
}
}
示例7: OnPhotonSerializeView
public void OnPhotonSerializeView(PhotonStream aStream, PhotonMessageInfo aInfo)
{
if (aStream.isWriting)
{
aStream.SendNext(transform.position);
aStream.SendNext(transform.rotation.eulerAngles.z);
aStream.SendNext(m_health);
}
else
{
m_photonPosition = (Vector3)aStream.ReceiveNext();
m_photonRotation = (float)aStream.ReceiveNext();
m_health = (int)aStream.ReceiveNext();
stopWatch.Stop();
if (stopWatch.ElapsedMilliseconds > (1000 / PhotonNetwork.sendRate))
{
m_photonReleasedPositions.Add(new TimePosition(m_photonPosition, (float)stopWatch.ElapsedMilliseconds, m_photonRotation));
if (m_once && m_photonReleasedPositions.Count >= 4)
{
m_once = false;
StartCoroutine("ReleasePositions");
}
stopWatch.Reset();
}
stopWatch.Start();
}
}
示例8: OnPhotonSerializeView
void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
// For our player
if(stream.isWriting)
{
stream.SendNext(transform.position);
stream.SendNext(transform.rotation);
//stream.SendNext(anim.GetFloat("Speed"));
//stream.SendNext(anim.GetBool("Jumping"));
}
// For other players
else
{
realPosition = (Vector3)stream.ReceiveNext();
realRotation = (Quaternion)stream.ReceiveNext();
//anim.SetFloat("Speed", (float)stream.ReceiveNext());
//anim.SetBool("Jumping", (bool)stream.ReceiveNext());
if(gotFirstUpdate == false)
{
transform.position = realPosition;
transform.rotation = realRotation;
gotFirstUpdate = true;
}
}
}
示例9: OnPhotonSerializeView
void OnPhotonSerializeView(PhotonStream aStream, PhotonMessageInfo aInfo)
{
CacheComponents ();
if (aStream.isWriting) {
// this is our player, we must send out our actual position
aStream.SendNext(transform.position);
aStream.SendNext(transform.rotation);
aStream.SendNext(anim.GetFloat("Speed"));
aStream.SendNext(anim.GetBool("Jumping"));
aStream.SendNext (anim.GetFloat("AimAngle"));
}
else {
// this is someone elses player, we need to receive their player and update
// our version of that player
realPosition = (Vector3) aStream.ReceiveNext();
realRotation = (Quaternion) aStream.ReceiveNext();
anim.SetFloat("Speed", (float)aStream.ReceiveNext());
anim.SetBool("Jumping", (bool)aStream.ReceiveNext());
realAimAngle = (float) aStream.ReceiveNext();
if(gotFirstUpdate == false) {
transform.position = realPosition;
transform.rotation = realRotation;
anim.SetFloat("AimAngle", realAimAngle);
gotFirstUpdate = true;
}
}
}
示例10: OnPhotonSerializeView
void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if (stream.isWriting)
{
//We own this player: send the others our data
// stream.SendNext((int)controllerScript._characterState);
stream.SendNext(transform.position);
stream.SendNext(transform.rotation);
//stream.SendNext(GetComponent<Rigidbody>().velocity);
}
else
{
//Network player, receive data
//controllerScript._characterState = (CharacterState)(int)stream.ReceiveNext();
correctPlayerPos = (Vector3)stream.ReceiveNext();
correctPlayerRot = (Quaternion)stream.ReceiveNext();
//GetComponent<Rigidbody>().velocity = (Vector3)stream.ReceiveNext();
if (!appliedInitialUpdate)
{
appliedInitialUpdate = true;
transform.position = correctPlayerPos;
transform.rotation = correctPlayerRot;
//GetComponent<Rigidbody>().velocity = Vector3.zero;
}
}
}
示例11: OnPhotonSerializeView
private void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
//Debug.Log("============>");
if (stream.isWriting)
{
stream.SendNext(transform.position);
PlayerController player = GetComponent<PlayerController>();
string blockName = player.currentBlock == null ? "" : player.currentBlock.name;
stream.SendNext(blockName);
}
else
{
PlayerController player = GetComponent<PlayerController>();
this.playerPos = (Vector3)stream.ReceiveNext();
string currentBlock = (string)stream.ReceiveNext();
if (currentBlock != "")
{
player.transform.parent = null;
}
else
{
Node block = GameBoard.FindBlockByName(currentBlock);
Debug.Log("===>"+block.name);
player.transform.parent = block.transform;
}
transform.localPosition = this.playerPos;
}
}
示例12: OnPhotonSerializeView
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if(stream.isWriting) {
// This is our player. We need to send our actual position to the network.
stream.SendNext(transform.position);
stream.SendNext(transform.rotation);
stream.SendNext(anim.GetFloat("Speed"));
stream.SendNext(anim.GetBool("Jumping"));
}
else {
// This is someone else's player. We need to reciece their position.
// Right now, "realPosition" holds the other person's position at the LAST frame.
// Instead of simply updating "realPosition" and continuing to lerp,
//we MAY want to set our transform.position to immediately to this old "realPosition"
//and then update realPosition
realPosition = (Vector3)stream.ReceiveNext ();
realRotation = (Quaternion)stream.ReceiveNext ();
anim.SetFloat ("Speed", (float)stream.ReceiveNext() );
anim.SetBool ("Jumping", (bool)stream.ReceiveNext() );
if(gotFirstUpdate == false) {
transform.position = realPosition;
transform.rotation = realRotation;
gotFirstUpdate = true;
}
}
}
示例13: OnPhotonSerializeView
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if (stream.isWriting == true)
{
if (this.m_SynchronizeVelocity == true)
{
stream.SendNext(this.m_Body.velocity);
}
if (this.m_SynchronizeAngularVelocity == true)
{
stream.SendNext(this.m_Body.angularVelocity);
}
}
else
{
if (this.m_SynchronizeVelocity == true)
{
this.m_Body.velocity = (Vector3)stream.ReceiveNext();
}
if (this.m_SynchronizeAngularVelocity == true)
{
this.m_Body.angularVelocity = (Vector3)stream.ReceiveNext();
}
}
}
示例14: OnPhotonSerializeView
void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if (stream.isWriting)
{
//We own this player: send the others our data
stream.SendNext(myRigid);
stream.SendNext(transform.position);
stream.SendNext(transform.rotation);
if(myRigid){
stream.SendNext(rigidbody.velocity);
}
}
else
{
if (!appliedInitialUpdate && hisRigid)
{
appliedInitialUpdate = true;
transform.position = correctPlayerPos;
transform.rotation = correctPlayerRot;
rigidbody.velocity = Vector3.zero;
}
//Network player, receive data
hisRigid = (bool)stream.ReceiveNext();
correctPlayerPos = (Vector3)stream.ReceiveNext();
correctPlayerRot = (Quaternion)stream.ReceiveNext();
if(hisRigid){
rigidbody.velocity = (Vector3)stream.ReceiveNext();
}
}
}
示例15: OnPhotonSerializeView
//Serilize Data Across the network, we want everyone to know where they are
void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
//Send to everyone else a local players variables to be synced and recieved by all other players on network
if (stream.isWriting)
{
//send to clients where we are
stream.SendNext(transform.position);
stream.SendNext(transform.rotation);
stream.SendNext(health);
//Sync Animation States
}
else
{
//Get from clients where they are
//Write in the same order we read, if not writing we are reading.
realPosition = (Vector3)stream.ReceiveNext();
realRotation = (Quaternion)stream.ReceiveNext();
health = (float)stream.ReceiveNext();
//Sync Animation States
}
}