Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.mouseScrollDelta.y > 0)
        {
            currentSelection++;
            currentSelection = currentSelection % ammoTypes.Length;
        }
        else if (Input.mouseScrollDelta.y < 0)
        {
            currentSelection--;
            currentSelection = (currentSelection + ammoTypes.Length) % ammoTypes.Length;
        }

        if (mostReceentArrowFired != null)
        {
            flightCriticalPoint = mostReceentArrowFired.time;
            flightTime          = mostReceentArrowFired.flightTime;
            if (mostReceentArrowFired.rb.velocity.y != 0.0f && setTime)
            {
                mostReceentArrowFired.setTime();
                setTime = false;
            }
        }
        if (Input.GetMouseButton(0))
        {
            drawtime += Time.deltaTime;
        }
        if (Input.GetMouseButtonUp(0))
        {
            if (ammo[currentSelection] <= 0)
            {
                return;
            }
            ammo[currentSelection]--;
            drawtime += .2f;
            float force = arrowforce * drawtime;
            if (force >= MAX)
            {
                force = MAX;
            }
            temp = force;            //debug purposes
            GameObject firedarrow = Instantiate(ammoTypes[currentSelection], arrowspawn.transform.position, arrowspawn.transform.rotation);
            Rigidbody  rb         = firedarrow.GetComponent <Rigidbody>();
            rb.AddForce(-arrowspawn.transform.up * force, ForceMode.Impulse);
            mostReceentArrowFired = firedarrow.GetComponent <ArrowRotation>();
            setTime  = true;
            drawtime = 0.0f;
        }
    }
Exemple #2
0
    private void Awake()
    {
        _hitDirectionScript = GetComponent <ArrowRotation>();
        _hitDirectionScript.OnDirectionPicked += OnDirectionPicked;

        _powerMeterScript = GetComponent <PowerMeter>();
        _powerMeterScript.OnPowerPicked += OnPowerPicked;

        _maxMinPowerDiff        = MaxPower - MinPower;
        _rigidbody              = GetComponent <Rigidbody2D>();
        _rigidbody.gravityScale = 0;
        _rigidbody.drag         = 0.15f;

        _spriteRenderer = GetComponent <SpriteRenderer>();

        _animator = GetComponent <Animator>();
    }
Exemple #3
0
    private void Start()
    {
        _arrowRotation = GetComponent <ArrowRotation>();
        _bubbleShot    = GetComponent <BubbleShot>();

        //Bボタンでバブル発射
        KeyInput.Instance.OnInputB
        .Where(shot => GameStatus.PlayerStatusReactiveProperty.Value == PlayerStatusEnum.ShotReady)
        .Subscribe(shot => _bubbleShot.Shot())
        .AddTo(this);

        //左右キーで左右に回転
        KeyInput.Instance.OnInputHorizontal
        .Where(horizontal => GameStatus.GameStatusReactivePropety.Value != GameStatusEnum.ArrayCheck)
        .Subscribe(horizontal => _arrowRotation.Rotation(horizontal))
        .AddTo(this);

        //プレイヤーステータスがSetBubbleの時
        GameStatus.PlayerStatusReactiveProperty
        .DistinctUntilChanged()
        .Where(status => status == PlayerStatusEnum.SetBubble)
        .Subscribe(_ => StartCoroutine(BubbleReload.Instance.Reload()))
        .AddTo(this);
    }
Exemple #4
0
 // Start is called before the first frame update
 void Start()
 {
     _ball     = GetComponent <Rigidbody2D>();
     _rotation = GetComponent <ArrowRotation>();
 }