コード例 #1
0
        public override void Hit(int amount, cGameObject entity_by)
        {
            base.Hit(amount, entity_by);

            if (this.health <= 0)
            {
                this.Kill(entity_by);
                //this.Scene.ParticleManager.AddNormalBloodExplosion(this.Bounds.center);


                return;
            }

            //this.spriteControl.ChangeState(new cSpriteState(MotionType.FALL, this.spriteControl.getCurrentState().HorizontalFacing));
            //this.Scene.ParticleManager.AddLittleBloodExplosion(this.Bounds.center, 3);

            this.Scene.QueueAction(
                () =>
            {
                Scene.Assets.PlaySound("body_hit1", 8);
                var e = pscene.ParticleManager["explosions"] as cExplosionController;
                // e.LittleBlood(new Particles.EmissionInfo(this.Bounds.center));
                var dir = AppMath.Vec2NormalizeReturn(entity_by.Velocity);

                float maxLen = (float)AppMath.GetRandomDoubleInRange(10.0, this.Bounds.diagonalLength());
                Vector2f end = AppMath.ScaleVector(entity_by.Position, AppMath.Vec2NormalizeReturn(dir), maxLen);

                // approximately:
                Vector2f point = AppMath.GetRandomPointOnLine(entity_by.Position, end);
                e.LittleLine(new Particles.EmissionInfo(point, dir));
            });
        }