예제 #1
0
    public override void Init()
    {
        base.Init();

        controller = GetComponent <Controller2D>();
        controller.Init(horizontalRayCount, verticalRayCount, collisionMask);

        playerSprites = GetComponent <PlayerSprites>();
        playerSprites.Init(sprites, weaponSprite);

        playerAnimation = GetComponent <PlayerAnimation>();
        playerAnimation.Init();

        playerWeapon = GetComponent <PlayerWeapon>();
        playerWeapon.Init(weaponSprite, startingWeaponId, damageLayer, GameObject.FindWithTag(ammoTag).GetComponent <AmmoUI>());

        healthUI = GameObject.FindWithTag(heartTag).GetComponent <HealthUI>();
        healthUI.Init(healthSettings.maxHealth);
    }
    //Player's initialization
    private void Init()
    {
        physics.Init();
        jumpSettings.Init();
        controller.Init(GetComponent <BoxCollider2D>(), transform);

        hitBox.enabled = true;

        //Set the initial difficulty
        ChangeDifficulty();

        //subcribe our functions to input events
        input.dashInput.OnInputDown    += Dash;
        input.jumpInput.OnInputDown    += Jump;
        input.jumpInput.OnInput        += JumpHold;
        input.jumpInput.OnInputUp      += JumpRelease;
        GameManager.OnDifficultyChange += ChangeDifficulty;

        EnableInput();
        EnableMovement();
    }