void spawnOn(LidgrenGameObject go, NetConnection c) { NetOutgoingMessage msg = c.Peer.CreateMessage(); msg.Write(LidgrenMessageHeaders.Spawn); msg.Write(go.Id); c.SendMessage(msg, NetDeliveryMethod.ReliableOrdered, 1); }
private void spawnOn(LidgrenGameObject go, NetConnection c) { NetOutgoingMessage netOutgoingMessage = c.Peer.CreateMessage(); netOutgoingMessage.Write(LidgrenMessageHeaders.Spawn); netOutgoingMessage.Write(go.Id); c.SendMessage(netOutgoingMessage, NetDeliveryMethod.ReliableOrdered, 1); }
public static LidgrenGameObject Spawn(int myId, int id, NetConnection con) { GameObject gameObject = (GameObject)Object.Instantiate(Resources.Load("Player"), new Vector3(45f, 10f, 45f), Quaternion.identity); LidgrenGameObject component = gameObject.GetComponent <LidgrenGameObject>(); component.Id = id; component.IsMine = (myId == id); component.Connection = con; return(component); }
private void onMovement(NetIncomingMessage msg) { Debug.Log("onMovement"); int key = msg.ReadInt32(); LidgrenGameObject lidgrenGameObject = null; if (this.lgos.TryGetValue(key, out lidgrenGameObject)) { lidgrenGameObject.GetComponent <PlayerAnimator>().OnPlayerMovement(msg.ReadByte()); } }
public static LidgrenGameObject Spawn(int myId, int id, NetConnection con) { GameObject go = (GameObject)GameObject.Instantiate(Resources.Load("Player"), new Vector3(45, 10, 45), Quaternion.identity); LidgrenGameObject lgo = go.GetComponent <LidgrenGameObject>(); lgo.Id = id; lgo.IsMine = myId == id; lgo.Connection = con; return(lgo); }
private void Start() { target.wrapMode = WrapMode.Loop; target["Jump"].wrapMode = WrapMode.Once; target["Jump"].layer = 1; target["Land"].wrapMode = WrapMode.Once; target["Land"].layer = 1; target["Run"].speed = 1.75f; target["Walk"].speed = -1.25f; target.Play("Idle"); lgo = GetComponent <LidgrenGameObject>(); }
void onMovement(NetIncomingMessage msg) { Debug.Log("onMovement"); int id = msg.ReadInt32(); LidgrenGameObject lgo = null; if (lgos.TryGetValue(id, out lgo)) { lgo.GetComponent <PlayerAnimator>().OnPlayerMovement(msg.ReadByte()); } }
private void onRequestSpawn(NetIncomingMessage msg) { LidgrenPlayer lidgrenPlayer = (LidgrenPlayer)msg.SenderConnection.Tag; if (lidgrenPlayer.GameObject == null) { lidgrenPlayer.GameObject = LidgrenGameObject.Spawn(-1, lidgrenPlayer.Id, msg.SenderConnection); foreach (NetConnection connection in server.Connections) { spawnOn(lidgrenPlayer.GameObject, connection); } } }
private void onPosition(NetIncomingMessage msg) { Debug.Log("onPosition"); int key = msg.ReadInt32(); LidgrenGameObject lidgrenGameObject = null; if (this.lgos.TryGetValue(key, out lidgrenGameObject)) { Vector3 position = new Vector3(msg.ReadFloat(), msg.ReadFloat(), msg.ReadFloat()); lidgrenGameObject.transform.position = position; Quaternion rotation = new Quaternion(msg.ReadFloat(), msg.ReadFloat(), msg.ReadFloat(), msg.ReadFloat()); lidgrenGameObject.transform.GetChild(0).rotation = rotation; } }
void onPosition(NetIncomingMessage msg) { Debug.Log("onPosition"); int id = msg.ReadInt32(); LidgrenGameObject lgo = null; if (lgos.TryGetValue(id, out lgo)) { // Update position Vector3 pos = new Vector3(msg.ReadFloat(), msg.ReadFloat(), msg.ReadFloat()); lgo.transform.position = pos; // Update rotation Quaternion rot = new Quaternion(msg.ReadFloat(), msg.ReadFloat(), msg.ReadFloat(), msg.ReadFloat()); lgo.transform.GetChild(0).rotation = rot; } }
void Start() { // Setup animations target.wrapMode = WrapMode.Loop; target["Jump"].wrapMode = WrapMode.Once; target["Jump"].layer = 1; target["Land"].wrapMode = WrapMode.Once; target["Land"].layer = 1; target["Run"].speed = 1.75f; target["Walk"].speed = -1.25f; // always start with idle target.Play("Idle"); lgo = GetComponent<LidgrenGameObject>(); }
void Start() { // Setup animations target.wrapMode = WrapMode.Loop; target["Jump"].wrapMode = WrapMode.Once; target["Jump"].layer = 1; target["Land"].wrapMode = WrapMode.Once; target["Land"].layer = 1; target["Run"].speed = 1.75f; target["Walk"].speed = -1.25f; // always start with idle target.Play("Idle"); lgo = GetComponent <LidgrenGameObject>(); }
private void Start() { LidgrenGameObject component = GetComponent <LidgrenGameObject>(); if (component.IsMine) { capsule = (base.collider as CapsuleCollider); body = base.rigidbody; body.drag = 0f; body.freezeRotation = true; RPGThirdPersonCamera.Instance.Target = base.transform; RPGThirdPersonCamera.Instance.Camera.transform.localPosition = Vector3.zero; RPGThirdPersonCamera.Instance.Camera.transform.rotation = Quaternion.identity; } else { Object.Destroy(this); Object.Destroy(base.rigidbody); } }
void Start() { LidgrenGameObject lgo = GetComponent <LidgrenGameObject>(); if (lgo.IsMine) { capsule = collider as CapsuleCollider; // We will rotate ourselves and we dont want any drag body = rigidbody; body.drag = 0f; body.freezeRotation = true; // Set camera to target this transform RPGThirdPersonCamera.Instance.Target = transform; RPGThirdPersonCamera.Instance.Camera.transform.localPosition = Vector3.zero; RPGThirdPersonCamera.Instance.Camera.transform.rotation = Quaternion.identity; } else { Destroy(this); Destroy(rigidbody); } }
private void onSpawn(NetIncomingMessage msg) { int num = msg.ReadInt32(); this.lgos.Add(num, LidgrenGameObject.Spawn(this.clientId, num, msg.SenderConnection)); }
void onSpawn(NetIncomingMessage msg) { int id = msg.ReadInt32(); lgos.Add(id, LidgrenGameObject.Spawn(clientId, id, msg.SenderConnection)); }