Beispiel #1
0
    private void Attack()
    {
        if (!GameController.instance.songController.currentlyInBeat)
        {
            TakeDamage(5);
        }

        Vector3 attackPosition = transform.position + new Vector3(playerMovement.lastDirectionMoved.x, playerMovement.lastDirectionMoved.y, transform.position.z);
        Battery battery        = FindObjectOfType <BulletSpawner>().GetBatteryAtPosition(attackPosition);

        if (battery != null)
        {
            battery.OnAttack();
        }
        else if (BulletSpawner.IsBossAtPosition(attackPosition))
        {
            if (FindObjectOfType <BulletSpawner>().batteries.Count <= 0)
            {
                FindObjectOfType <Boss>().OnAttack();
            }
        }

        PlayerActedThisBeat = true;
    }
Beispiel #2
0
    public void MovePlayer(Vector2 move)
    {
        Vector3 newPosition = new Vector3(Mathf.Round(transform.position.x) + move.x, Mathf.Round(transform.position.y) + move.y, 0);

        Vector3 moveNormalized        = move.normalized;
        Vector3 newPositionNormalized = new Vector3(Mathf.Round(transform.position.x) + move.normalized.x, Mathf.Round(transform.position.y) + move.normalized.y, 0);

        bool moved = false;

        if (bulletSpawner.GetBatteryAtPosition(newPosition) == null && bulletSpawner.GetBatteryAtPosition(newPositionNormalized) == null && !BulletSpawner.IsBossAtPosition(newPosition))
        {
            if (newPosition.x >= -moveBounds.x && newPosition.x <= moveBounds.x && newPosition.y >= -moveBounds.y && newPosition.y <= moveBounds.y)
            {
                toLocation = newPosition;
                moved      = true;

                if (!songController.currentlyInBeat)
                {
                    playerController.TakeDamage(5);
                }
            }
        }

        if (!moved && prevDirection == lastDirectionMoved)
        {
            playerController.TakeDamage(5);
        }

        prevDirection = lastDirectionMoved;
    }