Ejemplo n.º 1
0
    void OnEventCockpitUnmount(ulong _ulPlayerId)
    {
        CGalaxyShipMotor cGalaxyShipMotor = CGameShips.GalaxyShip.GetComponent <CGalaxyShipMotor>();

        for (CGalaxyShipMotor.EThrusters i = 0; i < CGalaxyShipMotor.EThrusters.MAX; ++i)
        {
            cGalaxyShipMotor.SetThrusterEnabled(i, 0.0f);
        }
    }
Ejemplo n.º 2
0
    void OnEventInputControlShip(CUserInput.EInput _eInput, ulong _ulPlayerId, bool _bDown)
    {
        if (_ulPlayerId != 0 &&
            _ulPlayerId == m_cCockpitBehaviour.MountedPlayerId)
        {
            CGalaxyShipMotor cGalaxyShipMotor = CGameShips.GalaxyShip.GetComponent <CGalaxyShipMotor>();
            float            fPower           = _bDown ? 1.0f : 0.0f;

            switch (_eInput)
            {
            case CUserInput.EInput.GalaxyShip_Forward:
                cGalaxyShipMotor.SetThrusterEnabled(CGalaxyShipMotor.EThrusters.Forward, fPower);
                break;

            case CUserInput.EInput.GalaxyShip_Backward:
                cGalaxyShipMotor.SetThrusterEnabled(CGalaxyShipMotor.EThrusters.Backward, fPower);
                break;

            case CUserInput.EInput.GalaxyShip_StrafeLeft:
                cGalaxyShipMotor.SetThrusterEnabled(CGalaxyShipMotor.EThrusters.StrafeLeft, fPower);
                break;

            case CUserInput.EInput.GalaxyShip_StrafeRight:
                cGalaxyShipMotor.SetThrusterEnabled(CGalaxyShipMotor.EThrusters.StrafeRight, fPower);
                break;

            case CUserInput.EInput.GalaxyShip_Up:
                cGalaxyShipMotor.SetThrusterEnabled(CGalaxyShipMotor.EThrusters.Up, fPower);
                break;

            case CUserInput.EInput.GalaxyShip_Down:
                cGalaxyShipMotor.SetThrusterEnabled(CGalaxyShipMotor.EThrusters.Down, fPower);
                break;

            case CUserInput.EInput.GalaxyShip_YawLeft:
                cGalaxyShipMotor.SetThrusterEnabled(CGalaxyShipMotor.EThrusters.YawLeft, fPower);
                break;

            case CUserInput.EInput.GalaxyShip_YawRight:
                cGalaxyShipMotor.SetThrusterEnabled(CGalaxyShipMotor.EThrusters.YawRight, fPower);
                break;

            default:
                Debug.LogError("Unknown input");
                break;
            }
        }
    }
Ejemplo n.º 3
0
    void OnEventAxisControlShip(CUserInput.EAxis _eAxis, ulong _ulPlayerId, float _fValue)
    {
        if (_ulPlayerId != 0 &&
            _ulPlayerId == m_cCockpitBehaviour.MountedPlayerId)
        {
            CGalaxyShipMotor cGalaxyShipMotor = CGameShips.GalaxyShip.GetComponent <CGalaxyShipMotor>();

            switch (_eAxis)
            {
            case CUserInput.EAxis.MouseX:
                if (_fValue == 0.0f)
                {
                    cGalaxyShipMotor.SetThrusterEnabled(CGalaxyShipMotor.EThrusters.RollLeft, 0.0f);
                    cGalaxyShipMotor.SetThrusterEnabled(CGalaxyShipMotor.EThrusters.RollRight, 0.0f);
                }
                else
                {
                    if (_fValue > 0.0f)
                    {
                        // / Screen.width
                        cGalaxyShipMotor.SetThrusterEnabled(CGalaxyShipMotor.EThrusters.RollLeft, Mathf.Clamp(_fValue / 15, 0.0f, 1.0f));
                        cGalaxyShipMotor.SetThrusterEnabled(CGalaxyShipMotor.EThrusters.RollRight, 0.0f);
                    }
                    else
                    {
                        cGalaxyShipMotor.SetThrusterEnabled(CGalaxyShipMotor.EThrusters.RollLeft, 0.0f);
                        cGalaxyShipMotor.SetThrusterEnabled(CGalaxyShipMotor.EThrusters.RollRight, Mathf.Clamp(_fValue / 15 * -1.0f, 0.0f, 1.0f));
                    }
                }
                break;

            case CUserInput.EAxis.MouseY:
                if (_fValue == 0.0f)
                {
                    cGalaxyShipMotor.SetThrusterEnabled(CGalaxyShipMotor.EThrusters.PitchUp, 0.0f);
                    cGalaxyShipMotor.SetThrusterEnabled(CGalaxyShipMotor.EThrusters.PitchDown, 0.0f);
                }
                else
                {
                    if (_fValue > 0.0f)
                    {
                        // / Screen.width
                        cGalaxyShipMotor.SetThrusterEnabled(CGalaxyShipMotor.EThrusters.PitchUp, Mathf.Clamp(_fValue / 20, 0.0f, 1.0f));
                        cGalaxyShipMotor.SetThrusterEnabled(CGalaxyShipMotor.EThrusters.PitchDown, 0.0f);
                    }
                    else
                    {
                        cGalaxyShipMotor.SetThrusterEnabled(CGalaxyShipMotor.EThrusters.PitchUp, 0.0f);
                        cGalaxyShipMotor.SetThrusterEnabled(CGalaxyShipMotor.EThrusters.PitchDown, Mathf.Clamp(_fValue / 20 * -1.0f, 0.0f, 1.0f));
                    }
                }
                break;

            default:
                Debug.LogError("Unknown input");
                break;
            }
        }
    }