Example #1
0
        public void LoopSound__HACK(object sound_key)
        {
            Sound sound      = Sound.Get(sound_key);
            var   sound_anim = new SpriteAnimation(Texture, (int)(1000 * sound.Duration), true, false, Texture.DefaultRegionIndex);

            PlayAnimation(sound_anim);
        }
Example #2
0
        public BulletCollisionParticle(Scene scene, double x, double y) :
            base(scene.Stage, x, y, Texture.Get("sprite_bullet_collision_particle"))
        {
            Hit       = new SpriteAnimation(Texture, 10, false, "f1", "f2", "f3", "f4");
            Hit.Sound = Sound.Get("sfx_bullet_impact");
            WeakReference game_wr       = new WeakReference(Set.Scene.Game);
            WeakReference render_set_wr = new WeakReference(Set);

            _AnimationNext = new Lazy <SpriteAnimation>(() => {
                ((PositronGame)game_wr.Target).AddUpdateEventHandler(this, (sender, e) =>
                {
                    ((RenderSet)render_set_wr.Target).Remove(this);
                    this.Dispose();
                    return(true);
                });
                return(null);
            });
            PlayAnimation(Hit);
        }
Example #3
0
 public void SetLoop(object loop_me, bool restart = false)
 {
     lock (CurrentLoopLock) {
         Sound new_loop = Sound.Get(loop_me);
         bool  change   = (new_loop != CurrentLoop);
         ResetLooper = change || restart;
         if (ResetLooper)
         {
             if (CurrentLoop != null)
             {
                 CurrentLoop.Stop();
             }
             if (change)
             {
                 CurrentLoop = new_loop;
             }
         }
     }
 }
Example #4
0
        // Main constructor:
        public Player(RenderSet render_set, double x, double y, Texture texture) :
            base(render_set, x, y, texture)
        {
            HealthChanged += (object sender, HealthChangedEventArgs e) => { _Health = Math.Max(0, e.HealthNow); };
            OnHealthChanged(this, _HealthMax);

            AnimationStand        = new SpriteAnimation(texture, "stand");
            AnimationWalk         = new SpriteAnimation(texture, 100, true, false, "stand", "walk1", "walk2", "walk3", "walk4", "walk5", "walk6");
            AnimationStationaryFw = new SpriteAnimation(texture, "stand"); // new SpriteAnimation(texture, "protag standing facing front");
            AnimationWalkFw       = new SpriteAnimation(texture, "stand"); // new SpriteAnimation(texture, true, "protag walking front 1", "protag walking front 2", "protag walking front 3", "protag walking front 4");
            AnimationStationaryBk = new SpriteAnimation(texture, "stand"); // new SpriteAnimation(texture, "protag standing back" );
            AnimationWalkBk       = new SpriteAnimation(texture, "stand"); // new SpriteAnimation(texture, true, "protag walking back 1", "protag walking back 2", "protag walking back 3", "protag walking back 4");

            AnimationCrouch = new SpriteAnimation(texture, "stand");       // new SpriteAnimation(texture, true, "protag crouch");
            AnimationCrawl  = new SpriteAnimation(texture, "stand");       // new SpriteAnimation(texture, 150, true, "protag crouch walk 1", "protag crouch walk 2", "protag crouch walk 3", "protag crouch walk 4");

            AnimationPreJump       = new SpriteAnimation(texture, true, "jump");
            AnimationJumping       = new SpriteAnimation(texture, true, "jump");
            AnimationEndJump       = new SpriteAnimation(texture, "stand"); // new SpriteAnimation(texture, "protag jumping 4");
            AnimationEndJump.Sound = Sound.Get("sfx_player_land_two_feet");

            AnimationSlingshot       = new SpriteAnimation(texture, 50, true, false, "shoot1", "shoot2", "shoot3", "shoot4");
            AnimationAimGunFwd       = new SpriteAnimation(texture, "stand"); // new SpriteAnimation(texture, true, "protag aiming gun");
            AnimationAimGunFwdUp     = new SpriteAnimation(texture, "stand"); // new SpriteAnimation(texture, true, "protag aiming gun up");
            AnimationAimGunFwdDown   = new SpriteAnimation(texture, "stand"); // new SpriteAnimation(texture, true, "protag aiming gun down");
            AnimationAimGunFwdCrouch = new SpriteAnimation(texture, "stand"); // new SpriteAnimation(texture, true, "protag aiming gun crouch");
            AnimationAimGunFwdJump   = new SpriteAnimation(texture, "stand"); // new SpriteAnimation(texture, true, "protag aiming gun jump");

            AnimationTakeHit = new SpriteAnimation(texture, "hit1", "hit2");

            AnimationPreJump.Frames[0].FrameTime = 100;
            //AnimationPreJump.Frames[1].FrameTime = 50;

            AnimationEndJump.Frames[0].FrameTime = 200;

            _FrameTimer.Start();
            JumpTimer.Start();
        }