Beispiel #1
0
    new void OnEnable()
    {
        base.OnEnable();
        if (!_isCheckBox)
        {
            SetButtonState(OVButtonState.Normal);
        }
        else
        {
            if (_Checknormal)
            {
                IsChecked(this.gameObject);
            }
        }

        OVUIEventListener listener = OVUIEventListener.Get(this.gameObject);

        listener.onClick += this.OnClick;
        listener.onUp    += this.onUp;
        listener.onDown  += this.onDown;
        listener.onExit  += this.onExit;

        listener.onDrag += this.OnDrag;

        listener.onEnter += this.onEnter;
        if (_Buttontext != "" && OVSDK.HasInitialized())
        {
            Text t;
            if (null != (t = this.GetComponentInChildren <Text>()))
            {
                t.text = OVSDK.GetString(_Buttontext);
            }
        }
    }
Beispiel #2
0
    void Start()
    {
        OVSDK.Init(1000, "01ec17dac7140c0fbe936ee128310000", "omni=1");

        OVSDK.LoadString("SampleString");
        _MsgboxIniting = OVSDK.MsgBox("", "", OVSDK.GetString("WaitInit"));
    }
Beispiel #3
0
 public void OnToggleStateChange(bool state)
 {
     if (name == "OmniCoupleMode")
     {
         OVSDK.SetOmniCoupleMode(state);
     }
 }
Beispiel #4
0
 public void OnSliderValueChange(float val)
 {
     if (name == "OmniCoupleRate")
     {
         OVSDK.SetOmniCoupleRate(val);
     }
 }
Beispiel #5
0
    void OnOVSDKInit()
    {
        Debug.Log("OnOVSDKInit: " + OVSDK.GetInitResult());

        OVSDK.DeviceInfo dev = OVSDK.GetDeviceInfo();
        Debug.Log("shop=" + dev.sShopName + ";shopid=" + dev.nShop + ";shop_category=" + dev.sCategory + ";device_sn=" + dev.sNo);

        OVSDK.UserInfo user = OVSDK.GetUserInfo();
        Debug.Log(string.Format("{0}name={1};id={2};phone={3};qrcode={4};balance={5}", OVSDK.IsGuest() ? "[GUEST]" : "", user.sUserName, user.nUserId, user.sUserPhone, user.sQrcode, user.nUserBalance));

        OnClickLoadGame();

//#if UNITY_EDITOR
        OVSDK.CheckOmniViveAvailable();
//#endif

        // buttons in sample-scene
        OVSDK._ControllerRay.RayVisibility = OVControllerRay.RayVisibility_AlwaysShow;

        if (_MsgboxIniting != null)
        {
            _MsgboxIniting.Close();
            _MsgboxIniting = null;
        }

        if (OVSDK.GetUserInfo().nGamePrepareLeft > 0)
        {
            //OVMsgBox hmb = OVSDK.MsgBox("prepare_game", OVSDK.GetString("PrepareStage"), OVSDK.GetString("PrepareConfirm"), OVSDK.GetString("Close"), "", OVSDK.GetUserInfo().nGamePrepareLeft);
            //hmb._onEvent = OnPrepareMsgBoxEvent;
        }
        else
        {
            //OVSDK.MsgBox("", OVSDK.GetString("InitResult"), OVSDK._sInitResult, OVSDK.GetString("Close"));
        }
    }
Beispiel #6
0
    public void OnClickSampleBuy(GameObject sender)
    {
        // Game customized trader-no
        string out_trade_no = sender.transform.position.x + "," + sender.transform.position.y + "," + sender.transform.position.z + "," + Time.time;

        OVSDK.Buy("Box", 0.88, out_trade_no, OnBuyResult);
    }
Beispiel #7
0
 void Update()
 {
     //OVSDK.Drive();
     if (OVSDK.JustInitialized())
     {
         OnOVSDKInit();
     }
 }
Beispiel #8
0
    bool UpdateText(Text compo, string cmd)
    {
        bool need_update = false;

        char[]   sep  = { '|' };
        string[] cmds = cmd.Split(sep);
        if (cmds.Length > 1)
        {
            string           content = "";
            OVSDK.UserInfo   ui      = OVSDK.GetUserInfo();
            OVSDK.DeviceInfo di      = OVSDK.GetDeviceInfo();
            int type = cmds[0].Length == 0 ? 0 : int.Parse(cmds[0]);
            if (type == 0)
            {
                compo.text = cmds[1];
            }
            else
            {
                switch (type)
                {
                case 1:
                    content     = string.Format("{0}", ui.nGameDurationLeft);
                    need_update = true;
                    break;

                case 2:
                    content     = string.Format("{0}", ui.nGamePrepareLeft);
                    need_update = true;
                    break;

                case 3:
                    content = string.Format("{0}", ui.nUserId);
                    break;

                case 4:
                    content = ui.sUserName;
                    break;

                case 5:
                    content = string.Format("{0}", di.nShop);
                    break;

                case 6:
                    content = di.sShopName;
                    break;

                case 7:
                    content     = string.Format("{0}", ui.nGameDuration / 60);
                    need_update = true;
                    break;
                }

                compo.text = string.Format(cmds[1], content);
            }
        }
        return(need_update);
    }
Beispiel #9
0
 // Use this for initialization
 void Start()
 {
     if (!OVSDK.HasInitialized())
     {
         //Replace the GameID and GameKey below with the values provided to you for this game by Virtuix.
         //If you have not received a unique GameID or GameKey, please contact Virtuix to register your game.
         OVSDK.Init(0000, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "omni=1");
     }
 }
Beispiel #10
0
    public void OnClickSampleMsgBox()
    {
        OVMsgBox hmb = OVSDK.MsgBox("", "OVSDK", "Hello World!!", OVSDK.GetString("OK"));

        hmb._onEvent = OnClickSampleMsgBoxOK;
        // test MsgBoxJson;
        //if (OVMsgBoxMenu._AllMsgBoxJson.Count == 0)	{
        //	OVSDK.MsgBoxJson("test");
        //}
        //else {
        //	OVSDK.onEventMsgBoxJsonText("test ExtendButton 1|<size=14><color=#FFFFFF>Remaining Game time : </color><color=#00FFFF>{0} Min.</color></size>");
        //}
    }
Beispiel #11
0
    protected override void OnDestroy()
    {
        // save user's coupling percentage;
        if (_PreOmniCoupleRate != OVSDK.GetUserOmniCoupleRate())
        {
            OVSDK.sendMsg(14, "");
        }
        OVSDK.sendMsg(15, _MenuName);
        _AllMsgBoxJson.Remove(this);
        refreshButtonsState();

        base.OnDestroy();
    }
Beispiel #12
0
    bool OnPrepareMsgBoxEvent(OVMsgBox hmb, string sEvent, GameObject sender)
    {
        if (sEvent == "timeout")
        {
            hmb.Reset("prepare_game_done", null, OVSDK.GetString("PrepareEnd"), OVSDK.GetString("OK"));
            return(true);
        }

        if (sEvent == "click" && sender.name == "OK" && hmb.usage == "prepare_game")
        {
            OVSDK.ConfirmPlayGame();
        }
        return(false);
    }
Beispiel #13
0
    public void OnClickSaveGame()
    {
        GameData gd = new GameData();

        gd.red   = _goRed.transform.localToWorldMatrix;
        gd.green = _goGreen.transform.localToWorldMatrix;

        int    len  = Marshal.SizeOf(typeof(GameData));
        IntPtr data = Marshal.AllocHGlobal(len);

        Marshal.StructureToPtr(gd, data, true);

        OVSDK.SaveGameData(data, len, OnSaveGameDone);
        //OVSDK.DllTest(data);

        Marshal.FreeHGlobal(data);
        data = IntPtr.Zero;
    }
Beispiel #14
0
    void OnClick(GameObject sender)
    {
        if (_onEvent != null &&
            _onEvent(this, "click", sender))
        {
            return;
        }

        int index = 0;

        if (tryGetMenuItem(sender, ref index))
        {
            if (_Items[index].directClose)
            {
                Close();
            }
            else
            {
                string msg = "dlg=" + _MenuName + ";" + "wgt=" + _Items[index].name;
                OVSDK.sendMsg(_Items[index].msgId, msg);
            }
        }
    }
Beispiel #15
0
 /// <summary>
 /// Calibration Function. Sets up proper alignment between Omni and HMD based on Omni input data and HMD orientation.
 /// </summary>
 public virtual void CalibrateOmni()
 {
     if (!hasCalibrated)
     {
         //set offset to be current ring angle
         if (motionData != null)
         {
             if ((cameraReference.transform.position.x != 0) && (cameraReference.transform.position.y != 0) && (cameraReference.transform.position.z != 0) &&
                 (cameraReference.rotation.eulerAngles.x != 0) && (cameraReference.rotation.eulerAngles.y != 0) && (cameraReference.rotation.eulerAngles.z != 0))
             {
                 omniOffset    = OVSDK.GetOmniYawOffset();
                 hasCalibrated = true;
                 Debug.Log(System.DateTime.Now.ToLongTimeString() + ": OmniMovementComponent(CalibrateOmni) - Successfully calibrated Omni.");
             }
             if (!hasFullyInitialized)
             {
                 //grab initial step count here
                 ResetStepCount();
                 hasFullyInitialized = true;
             }
         }
     }
 }
Beispiel #16
0
    public void GetOmniInputForCharacterMovement()
    {
        if (cameraReference == null)
        {
            Debug.LogError("OmniMovementComponent(GetOmniInputForCharacterMovement) - Camera Reference not set in prefab.");
            return;
        }

        forwardMovement = new Vector3(0.0f, 0.0f, 0.0f);
        strafeMovement  = forwardMovement;

        //calculate angle between camera and omni
        angleBetweenOmniAndCamera = ComputeAngleBetweenControllerAndCamera();

        float forwardRotation = 0f;

        //keep within bounds (0, 360)
        if (currentOmniYaw > 360f)
        {
            currentOmniYaw -= 360f;
        }
        if (currentOmniYaw < 0f)
        {
            currentOmniYaw += 360f;
        }

        //Get the coupling percentage from Omniverse
        couplingPercentage = developerMode ? 1.0f : OVSDK.GetOmniCoupleRate();


        //calculate forward rotation
        forwardRotation = (currentOmniYaw - omniOffset + transform.rotation.eulerAngles.y) + (angleBetweenOmniAndCamera * couplingPercentage);

        //display forward rotation defined by our coupling percentage
        dummyObject.rotation = Quaternion.Euler(0, forwardRotation, 0);
        dummyForward         = dummyObject.forward;

        //calculate forward movement
        Vector3 movementInputVector = new Vector3(hidInput.y * dummyForward.x, 0, hidInput.y * dummyForward.z);

        //apply multiplier to reduce backwards movement speed by a given percentage
        if (hidInput.y < 0)
        {
            movementInputVector *= backwardsSpeedMultiplier;
        }

        //display rounded values
        if (dummyForward.x != 0)
        {
            dummyForward.x = Mathf.Round(dummyForward.x * 100) / 100;
        }
        if (dummyForward.z != 0)
        {
            dummyForward.z = Mathf.Round(dummyForward.z * 100) / 100;
        }

        //apply gravity
        movementInputVector += Physics.gravity * gravityMultiplier;
        //perform forward movement
        forwardMovement = (movementInputVector * maxSpeed * Time.deltaTime);


        //check if there is strafe input
        if (hidInput.x != 0)
        {
            //calculate strafe movement
            movementInputVector = new Vector3(hidInput.x * dummyObject.right.x, 0, hidInput.x * dummyObject.right.z);
            //apply modifier to reduce strafe movement by a given percentage
            movementInputVector *= strafeSpeedMultiplier;
            //apply gravity
            movementInputVector += Physics.gravity * gravityMultiplier;
            //perform strafe movement
            strafeMovement = (movementInputVector * maxSpeed * Time.deltaTime);
        }
    }
Beispiel #17
0
    protected override void Start()
    {
        base.Start();

        _nTime = 0;

        _BG = transform.Find("BG");
        if (null == _BG)
        {
            _BG = transform;
        }

        string    path = OVSDK.GetUserInfo().sConsolePath + "\\" + _JsonFilePrefix + "_unity.json";
        string    json = ReadFile(path);
        OVMenuDef def;

        def.x     = def.y = def.w = def.h = 0;
        def.items = null;
        try
        {
            def       = JsonUtility.FromJson <OVMenuDef>(json);
            _MenuName = def.name;
            def.items = OVJsonHelper.FromJson <OVMenuItemDef>(json);
        }
        catch (Exception e) {
            Debug.Log("Parse json menu-items failed: " + e.Message);
        }
        if (null == _MenuName)
        {
            _MenuName = "";
        }
        if (def.w > 0 && def.h > 0)
        {
            ApplyTransRect(_BG as RectTransform, def.x, def.y, def.w, def.h, 0, false);
        }

        for (int i = 0; def.items != null && i < def.items.Length; ++i)
        {
            OVMenuItem item = CreateItem(def.items[i]);
            if (item != null)
            {
                if (def.items[i].type == "Button")
                {
                    item.directClose = (0 != def.items[i].close);
                    OVButton btn = item.go.gameObject.GetComponent <OVButton>();
                    btn.m_OnClick.AddListener(delegate(){ this.OnClick(item.go.gameObject); });
                    // OVUIEventListener.Get(item.go.gameObject).onClick += this.OnClick;
                }
                else if (def.items[i].type == "Slider")
                {
                    Slider slider = item.go.GetComponent <Slider>();
                    if (slider != null)
                    {
                        if (item.name == "OmniCoupleRate")
                        {
                            _PreOmniCoupleRate = OVSDK.GetUserOmniCoupleRate();
                            slider.value       = OVSDK.GetOmniCoupleRate();
                        }
                        slider.onValueChanged.AddListener(item.OnSliderValueChange);
                    }
                }
                else if (def.items[i].type == "Toggle")
                {
                    Toggle toggle = item.go.GetComponent <Toggle>();
                    if (toggle != null)
                    {
                        if (item.name == "OmniCoupleMode")
                        {
                            _PreOmniCoupleRate = OVSDK.GetUserOmniCoupleRate();
                            toggle.isOn        = OVSDK.GetOmniCoupleRate() < 0.5f ? false : true;
                        }
                        toggle.onValueChanged.AddListener(item.OnToggleStateChange);
                    }
                }
            }
        }

        _AllMsgBoxJson.Add(this);
        refreshButtonsState();
    }
Beispiel #18
0
 void OnSaveGameDone(int nRetCode, string sRetMsg)
 {
     OVSDK.MsgBox("SaveGame", "Save", nRetCode == 0 ? "Save Success." : "Save failed\n" + sRetMsg, OVSDK.GetString("OK"));
 }
Beispiel #19
0
 public void OnClickLoadGame()
 {
     OVSDK.LoadGameData(OnLoadGameDone);
     _MsgboxLoadingGame = OVSDK.MsgBox("LoadGame", "Loading", "Loading saved game data...");
 }