Exemplo n.º 1
0
    public void Fire()
    {
        if (isFire)
        {
            return;
        }
        if (!magazine.IsRemaining())
        {
            GameObject.Find(SocketManager.id).transform.GetChild(2).GetComponent <PlayerSound>().PlaySound(3, 5f, 5f);
            return;
        }
        isFire = !isFire;

        magazine.Decrease();

        JSONObject json      = new JSONObject();
        JSONObject posJson   = new JSONObject();
        JSONObject angleJson = new JSONObject();

        posJson.AddField("x", fireTransform.position.x);
        posJson.AddField("y", fireTransform.position.y);
        angleJson.AddField("x", playerMove.vector.x);
        angleJson.AddField("y", playerMove.vector.y);
        json.AddField("pos", posJson);
        json.AddField("angle", angleJson);

        SocketManager.socket.Emit("fire", json);
    }