Exemplo n.º 1
0
        public Bullet(MainGameScene scene, Vector2 pPosition, Vector2 pVelocity, int pPower)
            : base(scene)
        {
            m_Power = pPower;
            IsMiss = false;
            CanDelete = false;
            frames = new List<Texture2D>();
            var content = HeartAttack.theGameInstance.Content;
            cross = content.Load<Texture2D>("cross");
            for (int i = 1; i <= 4; i++)
            {
                frames.Add(content.Load<Texture2D>("Bullet/bullet" + i));
            }

            m_Sprite = new Sprite(frames[0], pPosition);
            m_Sprite.AddUpdater(new VelocityUpdater(pVelocity));
            m_Sprite.Scale = new Vector2(0.15f);
            //m_Sprite.Centre *= m_Sprite.Scale;
            var anim = new SpriteAnimation(Scene.ClockManager,
                    frames,
                    frames[0],
                    this.m_Sprite,
                    0.05f);

            anim.Start();

            anim.Complete += (s, e) =>
                {
                    anim.Reset();
                    anim.Start();
                };
        }
Exemplo n.º 2
0
        public Bug(MainGameScene scene, Vector2 pPosition, int pHealth, float pSpeed)
            : base(scene)
        {
            this.scene = scene;
            m_Health = pHealth;
            radius = 15;

            frames = new List<Texture2D>();
            var content = HeartAttack.theGameInstance.Content;
            cross = content.Load<Texture2D>("cross");
            for (int i = 1 ; i <= 4 ; i++)
            {
                frames.Add(content.Load<Texture2D>("Bug/bug" + i));
            }

            blinkFrames = new List<Texture2D>();
            for (int i = 1; i <= 4; i++)
            {
                blinkFrames.Add(content.Load<Texture2D>("Bug/bugblink" + i));
            }

            m_bugDeathSound = HeartAttack.theGameInstance.Content.Load<SoundEffect>("bugDeath1");
            m_HeartHitSound = HeartAttack.theGameInstance.Content.Load<SoundEffect>("heartHit");
            m_Sprite = new Sprite(frames[0], pPosition);
            m_Sprite.Scale = new Vector2(0.1f, 0.1f);
               // m_Sprite.Centre *= m_Sprite.Scale;
            m_Sprite.Colour = Color.Transparent;

            Vector2 velocity = (new Vector2(HeartAttack.theGameInstance.GraphicsDevice.Viewport.Width / 2,
                HeartAttack.theGameInstance.GraphicsDevice.Viewport.Height / 2) - pPosition);
            velocity.Normalize();
            velocity *= DirtyGlobalHelpers.config.BugSpeed;

            m_Sprite.AddUpdater(new VelocityUpdater(velocity));
        }