Ejemplo n.º 1
0
        public override void _Ready()
        {
            CharacterSprite = this.GetChildNode <Sprite>(nameof(CharacterSprite));

            AnimationPlayer  = this.GetChildNode <AnimationPlayer>();
            CollisionShape2D = this.GetChildNode <CollisionShape2D>(nameof(CollisionShape2D));

            State = this.GetChildNode <StateComponent>();

            Stats           = this.GetChildNode <Stats>();
            CharacterHitBox = this.GetChildNode <CharacterHitBox>();
            CharacterHitBox.Disable();

            CharacterHurtBox     = this.GetChildNode <CharacterHurtBox>();
            BlinkAnimationPlayer = this.GetChildNodeOrNull <AnimationPlayer>(nameof(BlinkAnimationPlayer));

            CharacterHurtBox.Connect(nameof(CharacterHurtBox.DamageReceived), this, nameof(ReceiveDamage));

            HpIndicator         = this.GetChildNode <HpIndicator>();
            HpIndicator.Visible = true;
            Stats.Connect(nameof(Stats.HpWasChanged), HpIndicator, nameof(HpIndicator.OnChangeHp));
            Stats.Connect(nameof(Stats.MaxHpWasChanged), HpIndicator, nameof(HpIndicator.OnChangeMaxHP));
            HpIndicator.UpdateHealthIndication();

            InvincibilityComponent = this.GetChildNode <InvincibilityComponent>();
            InvincibilityComponent.Connect(nameof(InvincibilityComponent.InvincibilityStarted), this, nameof(StartInvincibility));
            InvincibilityComponent.Connect(nameof(InvincibilityComponent.InvincibilityEnded), this, nameof(EndInvincibility));
        }
Ejemplo n.º 2
0
        public override void Die()
        {
            CharacterHurtBox.Disable();
            CharacterHitBox.Disable();

            CollisionShape2D.SetDeferred("disabled", true);
            AnimationPlayer.Play("Death");
        }
Ejemplo n.º 3
0
 public override void EndInvincibility()
 {
     CharacterHurtBox.Enable();
     BlinkAnimationPlayer.ToEnd();
     BlinkAnimationPlayer.Stop();
 }
Ejemplo n.º 4
0
 public override void StartInvincibility()
 {
     CharacterHurtBox.Disable();
     BlinkAnimationPlayer.Play("Blink");
     AnimationPlayer.Play("Hit");
 }
Ejemplo n.º 5
0
 public void EndRoll()
 {
     CharacterHurtBox.Enable();
 }
Ejemplo n.º 6
0
 public void StartRoll()
 {
     AnimationPlayer.Play("Roll");
     CharacterHurtBox.Disable();
 }