Beispiel #1
0
        private SpriteSequence GetSpriteSequence()
        {
            SpriteSequence seq = null;

            if (Math.Abs(m_move.LastDirection.X) > Math.Abs(m_move.LastDirection.Y))
            {
                if (m_move.LastDirection.X > 0)
                {
                    seq = m_walkRightSequence;
                }
                else if (m_move.LastDirection.X < 0)
                {
                    seq = m_walkLeftSequence;
                }
            }
            else
            {
                if (m_move.LastDirection.Y > 0)
                {
                    seq = m_walkBackSequence;
                }
                else if (m_move.LastDirection.Y < 0)
                {
                    seq = m_walkFrontSequence;
                }
            }

            if (seq == null)
            {
                seq = m_walkFrontSequence;
            }

            return(seq);
        }
Beispiel #2
0
        public Player()
        {
            m_location  = new LocationComponent(this);
            m_rigidBody = new RigidBodyComponent(this, m_location);
            m_move      = new MoveComponent(this, m_location);
            m_life      = new LifeComponent(this, 100);
            m_box       = new Vector2(32, 32);
            m_weapons   = new Dictionary <string, Weapon>();

            m_renderer = new SpriteRenderer(PlayerSprites.Instance);
            m_sprite   = m_renderer.AddSprite(PlayerSprites.Instance.Front1);

            m_walkRightSequence = new SpriteSequence(
                PlayerSprites.Instance.Right1,
                PlayerSprites.Instance.Right2,
                PlayerSprites.Instance.Right3
                );

            m_walkLeftSequence = new SpriteSequence(
                PlayerSprites.Instance.Left1,
                PlayerSprites.Instance.Left2,
                PlayerSprites.Instance.Left3
                );

            m_walkFrontSequence = new SpriteSequence(
                PlayerSprites.Instance.Front1,
                PlayerSprites.Instance.Front2,
                PlayerSprites.Instance.Front3
                );

            m_walkBackSequence = new SpriteSequence(
                PlayerSprites.Instance.Back1,
                PlayerSprites.Instance.Back2,
                PlayerSprites.Instance.Back3
                );
        }
Beispiel #3
0
        public void Update(TimeSpan elapsed)
        {
            if (m_life.IsAlive)
            {
                m_move.Update(elapsed);

                //if (NeedMove)
                //{
                //    m_location.SetPosition(m_move.NewLocation);
                //    NeedMove = false;
                //}

                var sequence = GetSpriteSequence();

                if (sequence != m_currentSequence)
                {
                    m_currentSequence = sequence;
                    m_currentSequence.Reset();
                }

                m_currentSequence.Update(elapsed);

                if (m_weapon != null)
                {
                    m_weapon.Update(elapsed);
                }
            }
            else if (m_blood == null)
            {
                m_blood = new Blood3();
                m_blood.SetPosition(m_location.Position);
                m_blood.SetColor(new Color4ub(255, 0, 50, 255));
                m_blood.NeverDie = true;
                BloodManager.Instance.AddBlood(m_blood);
            }
        }
Beispiel #4
0
        public Player()
        {
            m_location = new LocationComponent(this);
            m_rigidBody = new RigidBodyComponent(this, m_location);
            m_move = new MoveComponent(this, m_location);
            m_life = new LifeComponent(this, 100);
            m_box = new Vector2(32, 32);
            m_weapons = new Dictionary<string, Weapon>();

            m_renderer = new SpriteRenderer(PlayerSprites.Instance);
            m_sprite = m_renderer.AddSprite(PlayerSprites.Instance.Front1);

            m_walkRightSequence = new SpriteSequence(
                PlayerSprites.Instance.Right1,
                PlayerSprites.Instance.Right2,
                PlayerSprites.Instance.Right3
            );

            m_walkLeftSequence = new SpriteSequence(
               PlayerSprites.Instance.Left1,
               PlayerSprites.Instance.Left2,
               PlayerSprites.Instance.Left3
               );

               m_walkFrontSequence = new SpriteSequence(
               PlayerSprites.Instance.Front1,
               PlayerSprites.Instance.Front2,
               PlayerSprites.Instance.Front3
               );

               m_walkBackSequence = new SpriteSequence(
               PlayerSprites.Instance.Back1,
               PlayerSprites.Instance.Back2,
               PlayerSprites.Instance.Back3
               );
        }
Beispiel #5
0
        public void Update(TimeSpan elapsed)
        {
            if (m_life.IsAlive)
            {
                m_move.Update(elapsed);

                //if (NeedMove)
                //{
                //    m_location.SetPosition(m_move.NewLocation);
                //    NeedMove = false;
                //}

                var sequence = GetSpriteSequence();

                if (sequence != m_currentSequence)
                {
                    m_currentSequence = sequence;
                    m_currentSequence.Reset();
                }

                m_currentSequence.Update(elapsed);

                if (m_weapon != null)
                {
                    m_weapon.Update(elapsed);
                }
            }
            else if(m_blood == null)
            {
                m_blood = new Blood3();
                m_blood.SetPosition(m_location.Position);
                m_blood.SetColor(new Color4ub(255, 0, 50, 255));
                m_blood.NeverDie = true;
                BloodManager.Instance.AddBlood(m_blood);
            }
        }