コード例 #1
0
        protected override void AddHurtbox(float damage, HurtboxTypes hurtboxType)
        {
            if (hurtboxType == HurtboxTypes.Torch)
            {
                var hurtbox = Torch.Clone() as Torch;

                hurtbox.Position    = this.Position + this._velocity + new Vector2(0f, -50f);
                hurtbox.HurtboxType = hurtboxType;
                hurtbox.Colour      = this.Colour;
                hurtbox.Layer       = 0.2f;
                hurtbox.LifeSpan    = 1f;
                hurtbox.Parent      = this;
                hurtbox.Target      = Target;
                hurtbox.Damage      = damage;
                hurtbox.Speed       = 10f;

                Children.Add(hurtbox);
            }
            if (hurtboxType == HurtboxTypes.ShadowWhirl)
            {
                var hurtbox = ShadowWhirl.Clone() as ShadowWhirl;

                hurtbox.Position    = this.Position + this._velocity;
                hurtbox.HurtboxType = hurtboxType;
                hurtbox.Colour      = this.Colour;
                hurtbox.Layer       = 0.2f;
                hurtbox.LifeSpan    = 0.01f;
                hurtbox.Velocity    = new Vector2(0f, 0f);
                hurtbox.Parent      = this;
                hurtbox.Damage      = damage;

                Children.Add(hurtbox);
            }
            if (hurtboxType == HurtboxTypes.Spirit)
            {
                var hurtbox = Spirit.Clone() as Spirit;

                hurtbox.Position    = this.Position + this._velocity + new Vector2(0f, -50f);
                hurtbox.HurtboxType = hurtboxType;
                hurtbox.Colour      = this.Colour;
                hurtbox.Layer       = 0.2f;
                hurtbox.LifeSpan    = 4.5f;
                hurtbox.Parent      = this;
                hurtbox.Target      = Target;
                hurtbox.Damage      = damage;
                hurtbox.Speed       = 1f;

                Children.Add(hurtbox);
            }
        }