Ejemplo n.º 1
0
 public void add(int id, Socket cliSoc, string room, int clientId, string name, Vector3 Position, Quaternion Rotation)
 {
     numActors++;
     count++;
     NetworkObjectsList newObject = new NetworkObjectsList (id, cliSoc, room, clientId, name, Position, Rotation);
     newObject.next = first;
     first = newObject;
 }
Ejemplo n.º 2
0
        //Rooms
        //public static Dictionary<String, List<Socket>> rooms = new Dictionary<String, List<Socket>>();
        //-------------------------------//
        //----Object related commands----//
        //-------------------------------//
        //This is used to determain the and start the tracking of new network objects
        public void Instantiate(string objectName, float x, float y, float z, float rx, float ry, float rz, float rw, Socket soc)
        {
            int clientId = MainClass.GetClientId (soc); //get the id for the person who sent it
            string room = MainClass.GetPlayerRoom (soc); //get the room name of the sender
            int newActorId = Commander.rooms.GetRoomId(room) + NetList.AssignActorId(); //new id for the object
            Vector3 position = new Vector3(x, y, z);
            Quaternion rotation = new Quaternion (rx, ry, rz, rw);

            NetList.add (newActorId, soc, room, clientId, objectName, position, rotation); //add the object to the the network object list

            if (clientId != -1) {
                string sendMsg = "/Instantiate " + objectName + " " + x + " " + y + " " + z + " " + rx + " " + ry + " " + rz + " " + rw +  " " + newActorId + " " + clientId; //the string to send

                MsgInRoom (room, sendMsg, null); //send the message to everyone in the room
                Debug.Log ("Netowrk object created...");
                Debug.Log ("Network objects in list: " + NetList.Length);
            }
        }
Ejemplo n.º 3
0
        //This is used to update the stored netowrking objects data and send the update to all the cleints in the room.
        public void UpdatePosition(int actorId, float x, float y, float z, float rx, float ry, float rz, float rw, Socket soc)
        {
            int id = System.Convert.ToInt32 (actorId); //this id is for the object
            Vector3 position = new Vector3(x, y, z);
            Quaternion rotation = new Quaternion(rx, ry, rz, rw);

            NetList.SetPosition (id, position); //change the saved data for the network object
            NetList.SetRotation(id, rotation);

            string sendMsg = "/UpdatePosition " + id + " " + x + " " + y + " " + z + " " + rz + " " + ry + " " + rz + " " + rw; //the string to send
            string room = MainClass.GetPlayerRoom (soc);//get the room name of the sender

            MsgInRoom (room, sendMsg, soc);//send the message to everyone in the room
        }
Ejemplo n.º 4
0
 public NetworkObjectsList(int id, Socket cliSoc, string room, int cliId, string name, Vector3 position, Quaternion rotation)
 {
     actorId = id;
     soc = cliSoc;
     objectName = name;
     roomName = room;
     clientId = cliId;
     this.Position = position;
     this.Rotation = rotation;
 }
Ejemplo n.º 5
0
        public void SetRotation(int actorId, Quaternion Rotation)
        {
            NetworkObjectsList current = first;
            while (current.actorId != actorId) {
                if (current.next == null) {
                    return;
                } else {
                    current = current.next;
                }
            }

            current.Rotation = Rotation;
        }