Example #1
0
    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);
    }
Example #2
0
    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);
    }
Example #4
0
    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());
        }
    }
Example #5
0
    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>();
 }
Example #7
0
    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());
        }
    }
Example #8
0
    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);
            }
        }
    }
Example #9
0
    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;
        }
    }
Example #10
0
    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;
        }
    }
Example #11
0
    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>();
    }
Example #12
0
    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);
        }
    }
Example #14
0
    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);
        }
    }
Example #15
0
    private void onSpawn(NetIncomingMessage msg)
    {
        int num = msg.ReadInt32();

        this.lgos.Add(num, LidgrenGameObject.Spawn(this.clientId, num, msg.SenderConnection));
    }
Example #16
0
    void onSpawn(NetIncomingMessage msg)
    {
        int id = msg.ReadInt32();

        lgos.Add(id, LidgrenGameObject.Spawn(clientId, id, msg.SenderConnection));
    }