///<summary>
    ///Combination of kick and rumble methods.
    ///Rumble duration still be in seconds and still don't stop if you set this parameter at 0.0f.
    ///</summary>
    public static void Shoot(Byte kickPower, Byte rumblePower, float rumbleDuration, ForceTubeVRChannel target = ForceTubeVRChannel.rifle)
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        if (ForceTubeVRPlugin != null)
        {
            ForceTubeVRPlugin.Call("sendShot", kickPower, rumblePower, (int)(rumbleDuration * 1000.0f), (int)target);
        }
#endif

#if (UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN || UNITY_WSA)
        if (IntPtr.Size == 8)
        {
            Shot_x64(kickPower, rumblePower, rumbleDuration, target);
        }
        else
        {
            Shot_x32(kickPower, rumblePower, rumbleDuration, target);
        }
#endif
    }
    ///<summary>
    ///For power : 0 = no power, 255 = max power, if power is 126 or less, only the little motor is activated, this function is linear.
    ///For timeInSeconds : 0.0f seconds is a special command that make the ForceTubeVR never stop the rumble.
    ///</summary>
    public static void Rumble(Byte power, float duration, ForceTubeVRChannel target = ForceTubeVRChannel.rifle)
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        if (ForceTubeVRPlugin != null)
        {
            ForceTubeVRPlugin.Call("sendRumble", power, (int)(duration * 1000.0f), (int)target);
        }
#endif

#if (UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN || UNITY_WSA)
        if (IntPtr.Size == 8)
        {
            Rumble_x64(power, duration, target);
        }
        else
        {
            Rumble_x32(power, duration, target);
        }
#endif
    }
    ///<summary>
    ///0 = no power, 255 = max power, this function is linear.
    ///</summary>
    public static void Kick(Byte power, ForceTubeVRChannel target = ForceTubeVRChannel.rifle)
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        if (ForceTubeVRPlugin != null)
        {
            ForceTubeVRPlugin.Call("sendKick", power, (int)target);
        }
#endif

#if (UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN || UNITY_WSA)
        if (IntPtr.Size == 8)
        {
            Kick_x64(power, target);
        }
        else
        {
            Kick_x32(power, target);
        }
#endif
    }
 public void SetTargetChannel(int target)
 {
     this.target = (ForceTubeVRChannel)target;
 }
 public void SelectChannelToTest(int target)
 {
     this.ChannelToTest = (ForceTubeVRChannel)target + 2;
 }
 private static extern void Shot_x64(Byte kickPower, Byte rumblePower, float rumbleDuration, ForceTubeVRChannel channel);
 private static extern void Rumble_x64(Byte power, float timeInSeconds, ForceTubeVRChannel channel);
 private static extern void Kick_x64(Byte power, ForceTubeVRChannel channel);
Пример #9
0
    public static bool RemoveFromChannel(int nChannel, string sName)
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        /*if (ForceTubeVRPlugin != null)
         * {
         *  return ForceTubeVRPlugin.Call<bool>("RemoveFromChannel",nChannel,sName);
         * }
         * else
         * return false;*/

        SaveChannelJSon();

        string path     = Application.persistentDataPath;
        string filePath = path + "/ProTubeVR/Channels.json";
        Debug.Log("ReadAllText : " + filePath);
        string dataAsJson = File.ReadAllText(filePath);

        FTChannelFile FTList = JsonUtility.FromJson <FTChannelFile>(dataAsJson);



        ForceTubeVRChannel nFTChannel = (ForceTubeVRChannel)nChannel;
        switch (nFTChannel)
        {
        case ForceTubeVRChannel.rifleButt:
        {
            FTChannel channel = FTList.channels.rifleButt.Find((x) => x.name == sName);
            FTList.channels.rifleButt.Remove(channel);
        }
        break;

        case ForceTubeVRChannel.rifleBolt:
        {
            FTChannel channel = FTList.channels.rifleBolt.Find((x) => x.name == sName);
            FTList.channels.rifleBolt.Remove(channel);
        }
        break;

        case ForceTubeVRChannel.pistol1:
        {
            FTChannel channel = FTList.channels.pistol1.Find((x) => x.name == sName);
            FTList.channels.pistol1.Remove(channel);
        }
        break;

        case ForceTubeVRChannel.pistol2:
        {
            FTChannel channel = FTList.channels.pistol2.Find((x) => x.name == sName);
            FTList.channels.pistol2.Remove(channel);
        }
        break;

        case ForceTubeVRChannel.other:
        {
            FTChannel channel = FTList.channels.other.Find((x) => x.name == sName);
            FTList.channels.other.Remove(channel);
        }
        break;

        case ForceTubeVRChannel.vest:
        {
            FTChannel channel = FTList.channels.vest.Find((x) => x.name == sName);
            FTList.channels.vest.Remove(channel);
        }
        break;
        }

        dataAsJson = JsonUtility.ToJson(FTList);

        Debug.Log("WriteAllText : " + filePath);
        File.WriteAllText(filePath, dataAsJson);
        LoadChannelJSon();
        return(true);
#endif
#if (UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN)
        if (IntPtr.Size == 8)
        {
            return(RemoveFromChannel_x64(nChannel, sName));
        }
        else
        {
            return(false);
        }
#endif
    }