示例#1
0
    /* Player
     */

    /// <summary>
    /// deze funcite is voor je moeder
    /// </summary>
    /// <param name="e"></param>
    private void PlayerJoin(SocketIO.SocketIOEvent e)
    {
        string eventAsString             = "" + e.data;
        Dictionary <string, string> data = JsonConvert.DeserializeObject <Dictionary <string, string> >(eventAsString);

        if (data["clientId"] == this.socket.sid & !joined)
        {
            joined = true;

            GameObject newPlayer = Instantiate(playerPrefabs[int.Parse(data["playerTypeId"])],
                                               new Vector3(float.Parse(data["x"]), float.Parse(data["y"])),
                                               Quaternion.Euler(0, float.Parse(data["rotY"]), float.Parse(data["rotZ"])));

            MultiPlayerPlayer player = newPlayer.GetComponent <MultiPlayerPlayer>();
            player.Init(this, data["clientId"], true);
            players.Add(player);
            cam.SetPlayer(newPlayer);
        }
        else if (data["clientId"] != this.socket.sid)
        {
            GameObject newPlayer = Instantiate(playerPrefabs[int.Parse(data["playerTypeId"])],
                                               new Vector3(float.Parse(data["x"]), float.Parse(data["y"])),
                                               Quaternion.Euler(0, float.Parse(data["rotY"]), float.Parse(data["rotZ"])));

            MultiPlayerPlayer player = newPlayer.GetComponent <MultiPlayerPlayer>();
            player.Init(this, data["clientId"], false);
            players.Add(player);
        }
    }
示例#2
0
    public void MovePlayerOnServer(MultiPlayerPlayer player, Vector3 posTo, Quaternion rotation)
    {
        Dictionary <string, string> data = new Dictionary <string, string>();

        data["x"]        = "" + posTo.x;
        data["y"]        = "" + posTo.y;
        data["clientId"] = player.GetSocketId();
        data["rotZ"]     = "" + rotation.eulerAngles.z;
        data["rotY"]     = "" + rotation.eulerAngles.y;

        this.transform.position = posTo;
        socket.Emit("move", new JSONObject(data));
    }
示例#3
0
 private void Start()
 {
     foreach (Transform child in transform)
     {
         if (child.name == "BulletSpawner")
         {
             bulletSpawner = child;
         }
     }
     multiPlayerPlayer = GetComponentInParent <MultiPlayerPlayer>();
     if (multiPlayerPlayer.GetIfMainPlayer())
     {
         Transform  gunIconLocation = GameObject.FindWithTag("Health").transform.Find("Gun Icon");
         GameObject iconIns         = Instantiate(gunIcon, gunIconLocation);
         gunIconOverlay = iconIns.transform.Find("IconBackGround").GetComponent <Image>();
     }
 }