Пример #1
0
    private void ProcessInputs()
    {
        float horizontalInput = Input.GetAxis("Horizontal");
        float depthInput      = Input.GetAxis("Vertical");

        if (horizontalInput != 0 || depthInput != 0)
        {
            m_moverComponent.activateMoverAction(MoverComponent.ActionTypeFlag.Run);

            if (m_runMover != null)
            {
                if (!m_runMover.getMoverBehavior().getMoveRelative())
                {
                    m_moverComponent.getTransform().forward = new Vector3(horizontalInput, 0, depthInput);
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (m_slideMover != null)
            {
                m_slideMover.pause();
            }
            m_moverComponent.activateMoverAction(MoverComponent.ActionTypeFlag.Jump);
        }
    }
    private void ProcessInputs()
    {
        float horizontalInput;

        if (Network.peerType == NetworkPeerType.Disconnected)
        {
            horizontalInput = Input.GetAxis("HorizontalGround");
        }
        else
        {
            horizontalInput = Input.GetAxis("Horizontal");
        }

        float depthInput = Input.GetAxis("Vertical");

        if (Network.peerType == NetworkPeerType.Disconnected)
        {
            depthInput = Input.GetAxis("VerticalGround");
        }
        else
        {
            depthInput = Input.GetAxis("Vertical");
        }

        if (horizontalInput != 0 || depthInput != 0)
        {
            m_moverComponent.activateMoverAction(MoverComponent.ActionTypeFlag.Run);

            if (m_runMover != null)
            {
                if (!m_runMover.getMoverBehavior().getMoveRelative())
                {
                    m_moverComponent.getTransform().forward = new Vector3(horizontalInput, 0, depthInput);
                }
            }
        }

        float yawInput = Input.GetAxis("HorizontalRightStick");

        //float pitchInput = Input.GetAxis("VerticalRightStick");

        if (yawInput != 0)         //|| pitchInput != 0)
        {
            //m_moverComponent.getTransform().Rotate(new Vector3(0, m_turnRate * yawInput, 0));
        }

        if ((Network.peerType == NetworkPeerType.Disconnected && Input.GetButtonDown("JumpGround")) ||
            Network.peerType != NetworkPeerType.Disconnected && Input.GetButtonDown("Jump"))
        {
            m_moverComponent.activateMoverAction(MoverComponent.ActionTypeFlag.Jump);
        }
    }
Пример #3
0
    private void ProcessInputs()
    {
        float horizontalInput = Input.GetAxis("Horizontal");
        float depthInput      = Input.GetAxis("Vertical");

        if (horizontalInput != 0 || depthInput != 0)
        {
            if (m_runMover != null)
            {
                m_moverComponent.getTransform().forward = new Vector3(horizontalInput, 0, depthInput);
            }
        }

        if (Input.GetButtonDown("Fire1"))
        {
            m_moverComponent.activateMoverAction(MoverComponent.ActionTypeFlag.Jump);
        }
    }
Пример #4
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        MoverComponent moverComponent = target as MoverComponent;

        EditorGUI.BeginChangeCheck();
        bool alwaysUpdate = EditorGUILayout.Toggle("Always Update", moverComponent.getAlwaysUpdate());

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(moverComponent, "Always Update");
            EditorUtility.SetDirty(moverComponent);
            moverComponent.setAlwaysUpdate(alwaysUpdate);
        }

        EditorGUILayout.LabelField("Affected Transform");
        EditorGUI.BeginChangeCheck();
        Transform transformComponent = (Transform)EditorGUILayout.ObjectField(moverComponent.getTransform(), typeof(Transform), true);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(moverComponent, "Affected Transform");
            EditorUtility.SetDirty(moverComponent);
            moverComponent.setTransform(transformComponent);
        }

        EditorGUI.BeginChangeCheck();
        MoverComponent.ActionTypeFlag allActions = (MoverComponent.ActionTypeFlag)EditorGUILayout.EnumMaskField("Mover Actions", moverComponent.getActionTypeFlags());
        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(moverComponent, "Mover Actions");
            EditorUtility.SetDirty(moverComponent);
            moverComponent.setActionTypeFlags(allActions);
        }

        Dictionary <MoverComponent.ActionTypeFlag, Mover> actionMoverBehaviors = moverComponent.getActionMovers();

        int actionTypeFlagCount = System.Enum.GetValues(typeof(MoverComponent.ActionTypeFlag)).Length;

        for (int i = 0; i < actionTypeFlagCount; ++i)
        {
            MoverComponent.ActionTypeFlag mask = (MoverComponent.ActionTypeFlag)(1 << i);
            MoverComponent.ActionTypeFlag maskedActionTypeFlag = mask & allActions;
            if (maskedActionTypeFlag != 0)
            {
                bool displayFoldout;
                if (!m_actionTypeFlagFoldoutDisplay.TryGetValue(maskedActionTypeFlag, out displayFoldout))
                {
                    m_actionTypeFlagFoldoutDisplay.Add(maskedActionTypeFlag, true);
                    displayFoldout = m_defaultFoldout;
                }

                m_actionTypeFlagFoldoutDisplay[maskedActionTypeFlag] = EditorGUILayout.Foldout(displayFoldout, maskedActionTypeFlag.ToString());
                if (displayFoldout)
                {
                    moverComponent.createMoverAction(maskedActionTypeFlag);
                    Mover mover = actionMoverBehaviors[maskedActionTypeFlag];

                    EditorGUILayout.LabelField("Mover Behaviour");
                    EditorGUI.BeginChangeCheck();
                    MoverBehavior moverBehavior = (MoverBehavior)EditorGUILayout.ObjectField(mover.getMoverBehavior(), typeof(MoverBehavior), true);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(moverComponent, "Mover Behaviour");
                        EditorUtility.SetDirty(moverComponent);
                        mover.setMoverBehavior(moverBehavior);
                    }

                    if (moverBehavior != null)
                    {
                        createMoverBehaviorUI(moverBehavior);

                        EditorGUI.BeginChangeCheck();
                        InterpolationHelper.InterpolationType interpolationType = (InterpolationHelper.InterpolationType)EditorGUILayout.EnumPopup("Interpolation Type", mover.getInterpolationType());
                        if (EditorGUI.EndChangeCheck())
                        {
                            Undo.RecordObject(moverComponent, "Interpolation Type");
                            EditorUtility.SetDirty(moverComponent);
                            mover.setInterpolationType(interpolationType);
                        }

                        if (interpolationType != InterpolationHelper.InterpolationType.None &&
                            interpolationType != InterpolationHelper.InterpolationType.Undefined)
                        {
                            if (interpolationType != InterpolationHelper.InterpolationType.Linear)
                            {
                                EditorGUI.BeginChangeCheck();
                                InterpolationHelper.EasingType easingType = (InterpolationHelper.EasingType)EditorGUILayout.EnumPopup("Easing Type", mover.getEasingType());
                                if (EditorGUI.EndChangeCheck())
                                {
                                    Undo.RecordObject(moverComponent, "Easing Type");
                                    EditorUtility.SetDirty(moverComponent);
                                    mover.setEasingType(easingType);
                                }
                            }

                            EditorGUI.BeginChangeCheck();
                            float duration = EditorGUILayout.FloatField("Duration (seconds)", mover.getDuration());
                            if (EditorGUI.EndChangeCheck())
                            {
                                Undo.RecordObject(moverComponent, "Duration");
                                EditorUtility.SetDirty(moverComponent);
                                mover.setDuration(duration);
                            }

                            EditorGUI.BeginChangeCheck();
                            float updateRate = EditorGUILayout.FloatField("Update Rate (seconds)", mover.getUpdateRate());
                            if (EditorGUI.EndChangeCheck())
                            {
                                Undo.RecordObject(moverComponent, "Update Rate");
                                EditorUtility.SetDirty(moverComponent);
                                mover.setUpdateRate(updateRate);
                            }
                        }
                    }
                }
            }
            else
            {
                moverComponent.removeMoverAction(mask);
            }
        }

        serializedObject.ApplyModifiedProperties();
    }