public Slash(GraphicsDevice device, int minLength)
        {
            //_vertexBuffer = new VertexBuffer(device, typeof(VertexPositionNormalTexture), _vertices.Length, BufferUsage.None);

            m_attack = new AttackComponent(0.6f, 0.1f);
            m_attack.Unlock();
            m_attack.Enable();

            _minLength = minLength;

            m_sliceCollider = new LineCollider(m_attack);
            _slashStart = new Transform();
            _slashEnd = new Transform();
            _slashStart.Scale = new Vector2(5, 5);
            _slashEnd.Scale = new Vector2(10, 10);

            _device = device;

            InitMatrices();
            InitVertices();

            World.UL_Global.Add(this, 0);

            m_effect = new BasicEffect(device);
            m_effect.LightingEnabled = false;
            m_effect.VertexColorEnabled = false;

            m_effect.World = _world;
            m_effect.View = _view;
            m_effect.Projection = _projection;
        }
        public Slash(GraphicsDevice device, int minLength)
        {
            //_vertexBuffer = new VertexBuffer(device, typeof(VertexPositionNormalTexture), _vertices.Length, BufferUsage.None);

            m_attack = new AttackComponent(0.6f, 0.1f);
            m_attack.Unlock();
            m_attack.Enable();

            _minLength = minLength;

            m_sliceCollider   = new LineCollider(m_attack);
            _slashStart       = new Transform();
            _slashEnd         = new Transform();
            _slashStart.Scale = new Vector2(5, 5);
            _slashEnd.Scale   = new Vector2(10, 10);

            _device = device;

            InitMatrices();
            InitVertices();

            World.UL_Global.Add(this, 0);

            m_effect = new BasicEffect(device);
            m_effect.LightingEnabled    = false;
            m_effect.VertexColorEnabled = false;

            m_effect.World      = _world;
            m_effect.View       = _view;
            m_effect.Projection = _projection;
        }
Esempio n. 3
0
        public Shuriken() : base()
        {
            m_attack          = new AttackComponent(1.0f, 0.1f);
            m_sprite          = new Sprite(Globals.TheGame, TextureLibrary.GetSpriteSheet("atk_shuriken", 1, 5), m_transform);
            m_sprite.Origin   = new Vector2(0.5f, 0.0f);
            m_transform.Scale = new Vector2(3.0f, 3.0f);
            m_animation       = new SpriteSheetAnimation(m_sprite, 0, 4, 0.1f, 1);
            m_pointCollider   = new PointCollider(m_attack, Transform);

            World.UL_Global.Add(this, 0);
            World.DL_Foreground.Add(this, 0);
        }
        public Shuriken()
            : base()
        {
            m_attack = new AttackComponent(1.0f, 0.1f);
            m_sprite = new Sprite(Globals.TheGame, TextureLibrary.GetSpriteSheet("atk_shuriken", 1, 5), m_transform);
            m_sprite.Origin = new Vector2(0.5f, 0.0f);
            m_transform.Scale = new Vector2(3.0f, 3.0f);
            m_animation = new SpriteSheetAnimation(m_sprite, 0, 4, 0.1f, 1);
            m_pointCollider = new PointCollider(m_attack, Transform);

            World.UL_Global.Add(this, 0);
            World.DL_Foreground.Add(this, 0);
        }
        public void DealDamage(AttackComponent attack)
        {
            //int prevHP = _hpMax;
            float prevHP = _hpCurrent;

            _hpCurrent = Math.Max(0, _hpCurrent - attack.Damage);

            if (m_healthEvents != null)
            {
                List <HealthEvent> selectedEvents = new List <HealthEvent>();

                //Fills the selectedEvents list from lowest to highest hpThreshold
                for (int j = 0; j < m_healthEvents.Count; ++j)
                {
                    if (m_healthEvents[j].healthThreshold >= _hpCurrent &&
                        m_healthEvents[j].healthThreshold < prevHP)
                    {
                        selectedEvents.Add(m_healthEvents[j]);
                    }
                }

                if (selectedEvents.Count == 0)
                {
                    return;
                }

                //Checks each element to see if it can be played (not the last one)
                for (int i = selectedEvents.Count - 1; i > 0; --i)
                {
                    if (selectedEvents[i].allowSkip)
                    {
                        selectedEvents[i].action.Start();
                    }
                }

                //Last event (lowest hp threshold) is always played
                selectedEvents[0].action.Start();
            }
        }
        public void DealDamage(AttackComponent attack)
        {
            //int prevHP = _hpMax;
            float prevHP = _hpCurrent;
            _hpCurrent = Math.Max(0, _hpCurrent - attack.Damage);

            if (m_healthEvents != null)
            {
                List<HealthEvent> selectedEvents = new List<HealthEvent>();

                //Fills the selectedEvents list from lowest to highest hpThreshold
                for (int j = 0; j < m_healthEvents.Count; ++j)
                {
                    if (m_healthEvents[j].healthThreshold >= _hpCurrent
                        && m_healthEvents[j].healthThreshold < prevHP)
                        selectedEvents.Add(m_healthEvents[j]);
                }

                if (selectedEvents.Count == 0)
                    return;

                //Checks each element to see if it can be played (not the last one)
                for (int i = selectedEvents.Count - 1; i > 0; --i)
                    if (selectedEvents[i].allowSkip)
                        selectedEvents[i].action.Start();

                //Last event (lowest hp threshold) is always played
                selectedEvents[0].action.Start();
            }
        }
        public void BaseHit(Collider other)
        {
            AttackComponent attack = (AttackComponent)other.Owner;

            DealDamage(attack);
        }