コード例 #1
0
    public void OnMovement(InputValue vector2)
    {
        if (StageManager.Instance.isPaused)
        {
            return;
        }

        movementDirection = vector2.Get <Vector2>();

        characterData.AddCharge(-0.1f, false);
    }
コード例 #2
0
    private void OnCollisionEnter(Collision other)
    {
        if (other.gameObject.CompareTag("Bullet"))
        {
            CharacterData playerData = GetComponent <CharacterData>();
            Bullet        bullet     = other.gameObject.GetComponent <Bullet>();

            if (playerData.charge > 0)
            {
                playerData.AddCharge(-bullet.damage);
            }
            else
            {
                playerData.AddHealth(-bullet.damage);
            }
        }
    }
コード例 #3
0
    protected virtual void Update()
    {
        if (StageManager.Instance.isPaused)
        {
            return;
        }

        // Charging target
        if (isCharging && !isDown)
        {
            if (target == null)
            {
                isCharging = false;
                return;
            }

            if (target.CompareTag("Player"))
            {
                target.AddCharge(chargeStrength);
            }

            else if (target.CompareTag("Enemy"))
            {
                target.AddHealth(-chargeStrength);
            }

            currentCapacity -= chargeStrength;

            chargeEffect.SetActive(true);

            if (currentCapacity <= 0)
            {
                // Overcharged
                isDown     = true;
                isCharging = false;
                target     = null;
            }
        }
        else
        {
            if (chargeEffect.activeInHierarchy)
            {
                chargeEffect.SetActive(false);
            }
        }

        // Refilling
        if (!isCharging && !isDown && currentCapacity < maxChargeCapacity)
        {
            currentCapacity = Mathf.Min(currentCapacity + chargeStrength, maxChargeCapacity);
        }

        // Is down
        if (isDown)
        {
            currentDownTime += Time.deltaTime;
            chargerDownAnimator.SetBool(IsChargerDownHash, true);

            if (currentDownTime >= maxDownTime)
            {
                isDown          = false;
                currentDownTime = 0;
                chargerDownAnimator.SetBool(IsChargerDownHash, false);
            }
        }

        // Update UI
        if (currentCapacity < maxChargeCapacity)
        {
            chargeCapacityDisplay.value = currentCapacity / maxChargeCapacity;
        }
    }