예제 #1
0
    void UpdateKeys()
    {
        if (!MogaGamepad.IsConnected())
        {
            return;
        }

        foreach (E_InputAction a in m_KeyInput.Keys)
        {
            KeyInput ki = m_KeyInput[a];
            if (MogaGamepad.GetKeyCode(ki.key) == Moga.ACTION_DOWN && !ki.isDown)
            {
                ki.isDown = true;

                if (ki.onKeyDown != null)
                {
                    ki.onKeyDown();
                }
            }
            else if (MogaGamepad.GetKeyCode(ki.key) == Moga.ACTION_UP && ki.isDown)
            {
                ki.isDown = false;

                if (ki.onKeyUp != null)
                {
                    ki.onKeyUp();
                }
            }
        }
    }
예제 #2
0
 void OnDpadRight()
 {
     if (MogaGamepad.IsMogaPro())
     {
         ChangeWeaponNext();
     }
 }
예제 #3
0
    void UpdateMove()
    {
        if (!MogaGamepad.IsConnected())
        {
            return;
        }

        //move by joystick
        Vector2 dir = Vector2.zero;

        dir.x = MogaGamepad.GetAxis(Moga.AXIS_X);
        dir.y = -MogaGamepad.GetAxis(Moga.AXIS_Y);         //moga gamepad has inverted y axis

        float dist = dir.magnitude;

        if (dist > 0.001f)
        {
            States.Move.Direction.x = dir.x;
            States.Move.Direction.z = dir.y;
            States.Move.Direction.Normalize();

            States._Temp.eulerAngles = new Vector3(0, Player.LocalInstance.Owner.Transform.rotation.eulerAngles.y, 0);
            States.Move.Direction    = States._Temp.TransformDirection(States.Move.Direction);
            States.Move.Force        = dist;
        }
    }
예제 #4
0
 void OnDpadUp()
 {
     if (MogaGamepad.IsMogaPro())
     {
         GuiHUD.Instance.Gadgets.SelectPrev();
     }
 }
예제 #5
0
 void OnDpadLeft()
 {
     if (MogaGamepad.IsMogaPro())
     {
         ChangeWeaponPrev();
     }
 }
예제 #6
0
    public void ShowHelp(bool showSwitch)
    {
        if (m_initialised && MFGuiManager.Instance != null)
        {
            m_HelpSwitch.SetValue(GuiOptions.showMogaHelp);
            GuiBaseUtils.RegisterButtonDelegate(m_HelpCloseButton, null, OnCloseButton);
            GuiBaseUtils.RegisterSwitchDelegate(m_HelpLayout, "ShowHelp_Switch", OnHelpSwitch);

            MFGuiManager.Instance.ShowLayout(m_HelpLayout, true);

            if (MogaGamepad.IsMogaPro())
            {
                m_MogaPro.Show(true, true);
            }
            else
            {
                m_MogaPocket.Show(true, true);
            }

            InputManager.FlushInput();
            InputManager.IsEnabled = false;
            m_IsHelpOn             = true;

            //hide switch pokud jej nechceme zobrazovat
            m_HelpSwitch.Widget.Show(showSwitch, true);
        }
    }
예제 #7
0
 void OnL2Up()
 {
     if (MogaGamepad.IsMogaPro())
     {
         OnSprintUp();
     }
 }
예제 #8
0
 void OnSelectDown()
 {
     if (MogaGamepad.IsMogaPro() == false)
     {
         OnNextWeaponDown();
     }
 }
예제 #9
0
 void OnR2Up()
 {
     if (MogaGamepad.IsMogaPro())
     {
         OnFireUp();
     }
 }
예제 #10
0
 void OnL2Down()
 {
     if (MogaGamepad.IsMogaPro())
     {
         OnSprintDown();
     }
 }
예제 #11
0
 void OnR2Down()
 {
     if (MogaGamepad.IsMogaPro())
     {
         OnFireDown();
     }
 }
예제 #12
0
 void OnL1Up()
 {
     if (MogaGamepad.IsMogaPro() == false)
     {
         OnSprintUp();
     }
 }
예제 #13
0
    public void OnApplicationFocus(bool focus)
    {
        //Debug.Log( "Game OnApplicationFocus focus:" + focus );

        // When the application is switched to the fullscreen mode (web player on Mac OS X)
        // this method is called with focus == false.
        // Focus must be set to true otherwise InputManager is disabled
        // and mouse contol is not working.
        if (Application.platform == RuntimePlatform.OSXWebPlayer)
        {
            if (Screen.fullScreen)
            {
                focus = true;
            }
        }

#if UNITY_ANDROID && !UNITY_EDITOR
        m_IsFocused = focus;
        Debug.Log("Moga: Application focused " + focus);
        MogaGamepad.OnFocus(focus);
#endif

        if (focus == false)
        {
            InputManager.FlushInput();
        }

#if !UNITY_EDITOR
        InputManager.IsEnabled = focus;
#endif
    }
예제 #14
0
 void OnR1Up()
 {
     if (MogaGamepad.IsMogaPro() == false)
     {
         OnFireUp();
     }
 }
예제 #15
0
 void OnDpadDown()
 {
     if (MogaGamepad.IsMogaPro())
     {
         GuiHUD.Instance.Gadgets.SelectNext();
     }
 }
예제 #16
0
 public void ShowSelection(bool show)
 {
     if (m_SelectionWidget != null)
     {
         UpdateSelectionPos();
         bool gamepadControl = MogaGamepad.IsConnected();
         m_SelectionWidget.Show(show && gamepadControl && IsValidSelection(), true);
     }
 }
예제 #17
0
 void OnL1Down()
 {
     if (MogaGamepad.IsMogaPro())
     {
         OnRollDown();
     }
     else
     {
         OnSprintDown();
     }
 }
예제 #18
0
 //------------------------------------key handlers
 void OnR1Down()
 {
     if (MogaGamepad.IsMogaPro())
     {
         OnReloadDown();
     }
     else
     {
         OnFireDown();
     }
 }
예제 #19
0
    protected override void OnMenuUpdate()
    {
#if UNITY_ANDROID //&& !UNITY_EDITOR
        if (MogaGamepad.IsConnected() && (MogaGamepad.MenuKeyPressed() || MogaGamepad.MenuMovePressed()))
        {
            if (GuiMogaPopup.Instance != null && !(GuiMogaPopup.Instance.IsShown() || GuiMogaPopup.Instance.IsHelpShown()))
            {
                GuiMogaPopup.Instance.Show(02900033, 3.5f);
            }
        }
#endif
    }
예제 #20
0
 void Update()
 {
     if (m_IsHelpOn)
     {
         if (MogaGamepad.MenuKeyPressed())
         {
             HideHelp();
         }
         else
         {
             UpdateTouchableWidgets();
         }
     }
 }
예제 #21
0
    protected override void OnMenuUpdate()
    {
#if !MADFINGER_KEYBOARD_MOUSE
        if ((GamepadInputManager.Instance != null && GamepadInputManager.Instance.ControlDown(PlayerControlsGamepad.E_Input.Fire))
#if UNITY_ANDROID && !UNITY_EDITOR
            || (MogaGamepad.IsConnected() && MogaGamepad.GetKeyCode(Moga.KEYCODE_BUTTON_A) == Moga.ACTION_DOWN) ||
            (Input.GetKeyDown("8") || Input.GetKeyDown("1")) ||             //bluetooth
            (GamepadInputManager.Instance.IsNvidiaShield() && Input.GetKeyDown(KeyCode.Joystick1Button0))
#endif
            )
        {
            DoCommand("ResumeGame");
        }
#endif
    }
예제 #22
0
    protected override void OnViewShow()
    {
        BindControls(true);

#if UNITY_IPHONE && !UNITY_EDITOR
        //skryj gpad button na ios
        m_GamepadButton.Widget.Show(false, true);
        m_MogaHelpButton.Widget.Show(false, true);
#endif

#if UNITY_ANDROID || UNITY_EDITOR || UNITY_STANDALONE
        // na androideck detekuj pripojeni gamepadu
        InvokeRepeating("CheckGpadChange", 0, 2.0f);
#endif
#if UNITY_ANDROID
        MogaGamepad.OnConnectionChange += OnMogaChange;
        OnMogaChange(MogaGamepad.IsConnected());
#endif
    }
예제 #23
0
    void Update()
    {
        if (IsLoading == true)
        {
            return;
        }

        InputManager.Update();
        GamepadInputManager.Update();

#if UNITY_ANDROID && !UNITY_EDITOR
        MogaGamepad.Update();
#endif

        if (Input.touchCount != 0)
        {
            LastTouchControlTime = Time.timeSinceLevelLoad;
        }
    }
예제 #24
0
    public void Update()
    {
        if (CaptureInput == false)
        {
            return;
        }
        if (Game.Instance.GameState != E_GameState.Game)
        {
            return;
        }

#if UNITY_EDITOR || MADFINGER_KEYBOARD_MOUSE
        if (PCControls != null)
        {
            PCControls.Update();
        }
#endif

#if UNITY_ANDROID && !UNITY_EDITOR
        if (MogaControls != null && MogaGamepad.IsConnected())
        {
            MogaControls.Update();
        }

        if (BlueToothControls != null)
        {
            BlueToothControls.Update();
        }
#endif
        GamepadControls.Update();

        if (TouchControls != null)
        {
            TouchControls.Update();
        }

        if (null != DroneControls)
        {
            DroneControls.Update();
        }
    }
예제 #25
0
    void UpdateView()
    {
        if (!MogaGamepad.IsConnected())
        {
            return;
        }

        float yaw1   = MogaGamepad.GetAxis(Moga.AXIS_Z) * ViewSensitivityX;
        float pitch1 = MogaGamepad.GetAxis(Moga.AXIS_RZ) * ViewSensitivityY;

        bool Changed = (Mathf.Abs(yaw1) > 0.001F || Mathf.Abs(pitch1) > 0.001F);

        if (Changed)
        {
            //clamp to frame limit
            float RotSpeed   = 360;
            float FrameLimit = (RotSpeed * Time.deltaTime);
            float OutYaw     = PlayerControlStates.ClampAngle(yaw1, -FrameLimit, FrameLimit);
            float OutPitch   = PlayerControlStates.ClampAngle(pitch1, -FrameLimit, FrameLimit);

            States.View.SetNewRotation(OutYaw, OutPitch);
        }
    }
예제 #26
0
    void OnDestroy()
    {
        if (_Instance == this)
        {
            // shutdown plugins
            EtceteraWrapper.Done();

            TapJoy.Done();
            TwitterWrapper.Done();

#if UNITY_ANDROID && !UNITY_EDITOR
            MogaGamepad.Done();
            MogaGamepad.OnConnectionChange -= OnMogaConnectionChange;
            MogaGamepad.OnBatteryLowChange  = null;
#endif

            GamepadInputManager.DestroyInstance();

            CloudUser.authenticationChanged -= OnUserAuthenticationChanged;
            OnUserAuthenticationChanged(false);

            //FacebookPlugin.Instance.OnApplicationFocus -= OnApplicationPause;  kua ja to nemuzu delat ;)
        }
    }
예제 #27
0
    void Awake()
    {
        BuildInfo.DrawVersionInfo = false;

        // 1366x720=983520
        // 1024x720=737280
        // 900x640=614400
        //Screen.SetResolution (1024, 540, true);

        //new Texture().SetAnisotropicFilteringLimits(1,1);//2,2);

        //
        // warmup post-fx shaders
        //

        /*
         * if (iPhoneSettings.generation == iPhoneGeneration.iPodTouch3Gen || iPhoneSettings.generation == iPhoneGeneration.iPodTouch4Gen || iPhoneSettings.generation == iPhoneGeneration.iPhone3GS || iPhoneSettings.generation == iPhoneGeneration.iPad1Gen)
         * QualitySettings.masterTextureLimit = 1;
         *
         * if (iPhoneSettings.generation == iPhoneGeneration.iPad2Gen)
         * QualitySettings.antiAliasing = 4;
         */

        //CamExplosionFXMgr.PreloadResources();

        GraphicsDetailsUtl.DisableShaderKeyword("UNITY_IPHONE");

#if UNITY_IPHONE
        GraphicsDetailsUtl.EnableShaderKeyword("UNITY_IPHONE");
#endif

#if UNITY_ANDROID && !UNITY_EDITOR
        try
        {
            MogaGamepad.Init();
            MogaGamepad.OnConnectionChange += OnMogaConnectionChange;
            MogaGamepad.OnBatteryLowChange  = OnMogaBatteryLowChange;

            if (m_IsFocused)
            {
                //Debug.Log("Moga: Application focused");
                MogaGamepad.OnFocus(m_IsFocused);
            }
        }
        catch (System.Exception) {}
#endif

        QualitySettings.masterTextureLimit = 0;

        if (_Instance)
        {
            if (_Instance.Client == null)
            {
                _Instance.Client = Client;
            }
            Destroy(this.gameObject);
            return;
        }
        else
        {
            _Instance = this;
            uLink.NetworkView nw = GetComponent <uLink.NetworkView>();
            if (nw != null)
            {
                // This workaround fixes the warning about alredy registered manual ID
                // Now the NetworkView is registered only once (using given ManualViewIDWorkaround).
                nw.SetManualViewID(ManualViewIDWorkaround);
            }
        }

        CloudUser.authenticationChanged += OnUserAuthenticationChanged;

        GamepadInputManager.CreateInstance();

        DontDestroyOnLoad(this);
        this.transform.parent = null;

        InputManager.Initialize();

        if (AppType == E_AppType.DedicatedServer)
        {
            Application.targetFrameRate = 60;
        }
        else
        {
            Application.targetFrameRate = 30;
        }

        // test server optimization
        // not really great optimization I would say... (our servers were definitelly more laggy)
        // Changing back to 60FPS on the server
        //Application.targetFrameRate = 30;

        uLink.BitStreamCodec.Add <PlayerPersistantInfo>(PlayerPersistantInfo.Deserialize, PlayerPersistantInfo.Serialize);
        uLink.BitStreamCodec.Add <PPIInventoryList>(PPIInventoryList.Deserialize, PPIInventoryList.Serialize);
        uLink.BitStreamCodec.Add <PPIEquipList>(PPIEquipList.Deserialize, PPIEquipList.Serialize);
        uLink.BitStreamCodec.Add <PPIRoundScore>(PPIRoundScore.Deserialize, PPIRoundScore.Serialize);
        uLink.BitStreamCodec.Add <PPIUpgradeList>(PPIUpgradeList.Deserialize, PPIUpgradeList.Serialize);
        uLink.BitStreamCodec.Add <PPIOutfits>(PPIOutfits.Deserialize, PPIOutfits.Serialize);
        uLink.BitStreamCodec.Add <RoundFinalResult>(RoundFinalResult.Deserialize, RoundFinalResult.Serialize);
        uLink.BitStreamCodec.AddAndMakeArray <RoundFinalResult.PlayerResult>(RoundFinalResult.PlayerResult.Deserialize,
                                                                             RoundFinalResult.PlayerResult.Serialize);

#if UNITY_IPHONE || UNITY_ANDROID
        Screen.autorotateToPortrait           = false;
        Screen.autorotateToPortraitUpsideDown = false;
#endif

        Screen.sleepTimeout = 120;

        //
        // experimental networking stuff
        //

        if (AppType == E_AppType.Game && Application.isEditor == false)
        {
            // initialize plugins
            EtceteraWrapper.Init();

            if (TwitterConfiguration.IsAvailable)
            {
                TwitterWrapper.Init(TwitterConfiguration.CustomerKey, TwitterConfiguration.CustomerSecret);
            }

            if (ChartBoostConfiguration.IsAvailable)
            {
                ChartBoost.init(ChartBoostConfiguration.AppId, ChartBoostConfiguration.AppSignature);
            }

            if (TapJoyConfiguration.IsAvailable)
            {
                TapJoy.Init(TapJoyConfiguration.AppId, TapJoyConfiguration.SecurityKey);
            }
        }

        // Synchronize item settings managers with cloud
        SettingsCloudSync.GetInstance().UpdateSettingsManagersFromCloud();

        LastTouchControlTime = 0;
    }