Beispiel #1
0
    private void HandleInput()
    {
        Direction direction = Direction.None;

        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            direction = Direction.North;
        }
        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            direction = Direction.East;
        }
        if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            direction = Direction.South;
        }
        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            direction = Direction.West;
        }

        if (direction != Direction.None)
        {
            //We go the the next from no matter what
            if (m_LevelTimeline != null)
            {
                m_LevelTimeline.NextFrame();
            }

            //Move the player
            Vector2Int offset      = UtilityMethods.DirectionToVector2Int(direction);
            Vector3    newPosition = transform.position + new Vector3(offset.x, offset.y, 0.0f);

            //Normally these variables should have a better home. But for now this is fine
            if (newPosition.x < BitsyExporter.s_PlayableZoneStartX)
            {
                return;
            }

            if (newPosition.x > BitsyExporter.s_PlayableZoneEndX)
            {
                return;
            }

            if (newPosition.y > BitsyExporter.s_PlayableZoneStartY * -1)
            {
                return;
            }

            if (newPosition.y < BitsyExporter.s_PlayableZoneEndY * -1)
            {
                return;
            }

            transform.position = newPosition;
        }
    }
Beispiel #2
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        LevelTimeline levelTimeline = (LevelTimeline)target;

        GUIStyle style = new GUIStyle(GUI.skin.button);

        style.fixedHeight = 30;

        //Title
        EditorGUILayout.LabelField("Current Frame", EditorStyles.boldLabel);
        EditorGUILayout.Space();

        //Step Slider
        SerializedProperty serializedProperty = serializedObject.FindProperty("m_CurrentFrame");
        int tempStep = serializedProperty.intValue;

        EditorGUI.BeginChangeCheck();
        tempStep = EditorGUILayout.IntSlider(tempStep, levelTimeline.TimelineMinRange, levelTimeline.TimelineMaxRange);

        if (EditorGUI.EndChangeCheck())
        {
            //We only want to change trough a function!
            levelTimeline.SetFrame(tempStep);
        }

        EditorGUILayout.Space();

        //Previous & Next Buttons
        EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button("< Previous", style))
        {
            levelTimeline.PreviousFrame();
        }
        if (GUILayout.Button("Next >", style))
        {
            levelTimeline.NextFrame();
        }

        EditorGUILayout.EndHorizontal();

        serializedObject.ApplyModifiedProperties();
    }