Beispiel #1
0
    void Start()
    {
        _inputManager.IsUpdate.Skip(1).Where(x => x).Subscribe(_ =>
        {
            switch (_inputManager.LastInput)
            {
            case InputManager.InputType.Left:
                _arrowManager.Generate(Arrow.Type.Left);
                break;

            case InputManager.InputType.Right:
                _arrowManager.Generate(Arrow.Type.Right);
                break;

            case InputManager.InputType.None:
                _arrowManager.Reset();
                break;
            }
        }).AddTo(this);
    }
Beispiel #2
0
    public void Generate(Arrow.Type arrowType)
    {
        if (_arrows.Count >= 16)
        {
            Clear();
        }

        var arrowObj = Instantiate(_arrowPrefab, ArrowParentGameObject.transform);

        arrowObj.name = arrowType.ToString();

        var arrow = arrowObj.GetComponent <Arrow>();

        arrow.ArrowType.Value = arrowType;

        var arrowPosX     = arrowType == Arrow.Type.Left ? 0f : 1f;
        var arrowPosition = new Vector3(arrowPosX, -_arrows.Count - (_arrows.Count / 4), 0);

        arrowObj.transform.localPosition = arrowPosition;

        _arrows.Add(arrow);

        var count = _arrows.Count;

        if (count % 4 == 0)
        {
            if (_arrows[count - 4].ArrowType.Value == Arrow.Type.Left &&
                _arrows[count - 3].ArrowType.Value == Arrow.Type.Right &&
                _arrows[count - 2].ArrowType.Value == Arrow.Type.Right &&
                _arrows[count - 1].ArrowType.Value == Arrow.Type.Left)
            {
                if (NextArrowManager == null)
                {
                    GenerateNextArrowManager();
                }
                for (var i = 1; i <= 4; i++)
                {
                    SetColorChildrenObjects(_arrows[count - i].gameObject, Color.green);
                }
                NextArrowManager.Generate(Arrow.Type.Left);
            }
            else if (_arrows[count - 4].ArrowType.Value == Arrow.Type.Right &&
                     _arrows[count - 3].ArrowType.Value == Arrow.Type.Left &&
                     _arrows[count - 2].ArrowType.Value == Arrow.Type.Left &&
                     _arrows[count - 1].ArrowType.Value == Arrow.Type.Right)
            {
                if (NextArrowManager == null)
                {
                    GenerateNextArrowManager();
                }
                for (var i = 1; i <= 4; i++)
                {
                    SetColorChildrenObjects(_arrows[count - i].gameObject, Color.green);
                }
                NextArrowManager.Generate(Arrow.Type.Right);
            }
            else
            {
                for (var i = 1; i <= 4; i++)
                {
                    SetColorChildrenObjects(_arrows[count - i].gameObject, Color.red);
                }
            }
        }
    }