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)); }
public override void _Ready() { base._Ready(); SoftCollision = this.GetChildNodeOrNull <SoftCollision>(); DetectionZone = this.GetChildNode <DetectionZone>(); DetectionZone.Connect(nameof(DetectionZone.TargetSpotted), this, nameof(OnTargetSpotted)); // DetectionZone.Connect(nameof(DetectionZone.TargetLost), this, nameof(OnTargetLost)); PushState(new IdleState(this)); StartPosition = Position; HpIndicator.UpdateHealthIndication(); }