Exemplo n.º 1
0
        public void Damage(cDynamic_Projectile projectile, Creature victim)
        {
            if (victim != null)
            {
                // Attack victim with damage
                victim.Health -= projectile.nDamage;

                // Knock victim back
                float tx = victim.px - projectile.px;
                float ty = victim.py - projectile.py;
                float d  = (float)Math.Sqrt(tx * tx + ty * ty);
                if (d < 1)
                {
                    d = 1.0f;
                }

                // After a hit, they object experiences knock back, where it is temporarily
                // under system control. This delivers two functions, the first being
                // a visual indicator to the player that something has happened, and the second
                // it stops the ability to spam attacks on a single creature
                victim.KnockBack(tx / d, ty / d, 0.2f);

                if (victim != m_pPlayer)
                {
                    victim.OnInteract(m_pPlayer);
                }
                else
                {
                    // We must ensure the player is never pushed out of bounds by the physics engine. This
                    // is a bit of a hack, but it allows knockbacks to occur providing there is an exit
                    // point for the player to be knocked back into. If the player is "mobbed" then they
                    // become trapped, and must fight their way out
                    victim.SolidVsDynamic = true;
                }


                if (projectile.bOneHit)
                {
                    projectile.Redundant = true;
                }
            }
        }
Exemplo n.º 2
0
        public override bool OnUse(DynamicObj myobject)
        {
            // When weapons are used, they are used on the object that owns the weapon, i.e.
            // the attacker. However this does not imply the attacker attacks themselves

            // Get direction of attacker
            Creature aggressor = (Creature)myobject;

            // Determine attack origin
            float x = 0, y = 0, vx = 0, vy = 0;

            if (aggressor.GetFacingDirection() == 0) // South
            {
                x  = aggressor.px;
                y  = aggressor.py + 1.0f;
                vx = 0.0f; vy = 1.0f;
            }

            if (aggressor.GetFacingDirection() == 1) // East
            {
                x  = aggressor.px - 1.0f;
                y  = aggressor.py;
                vx = -1.0f; vy = 0.0f;
            }

            if (aggressor.GetFacingDirection() == 2) // North
            {
                x  = aggressor.px;
                y  = aggressor.py - 1.0f;
                vx = 0.0f; vy = -1.0f;
            }

            if (aggressor.GetFacingDirection() == 3) // West
            {
                x  = aggressor.px + 1.0f;
                y  = aggressor.py;
                vx = 1.0f; vy = 0.0f;
            }

            if (aggressor.Health == aggressor.MaxHealth)
            {
                // Beam sword
                cDynamic_Projectile pLaser = new cDynamic_Projectile(x, y, aggressor.Friendly, vx * 15.0f, vy * 15.0f, 1.0f, Assets.Instance.GetSprite("sword"), (aggressor.GetFacingDirection() + 3) % 4 + 1, 1.0f);
                pLaser.SolidVsMap     = true;
                pLaser.SolidVsDynamic = false;
                pLaser.nDamage        = 5;
                pLaser.bOneHit        = false;
                g_engine.AddProjectile(pLaser);
            }

            cDynamic_Projectile p = new cDynamic_Projectile(x, y, aggressor.Friendly, aggressor.vx, aggressor.vy, 0.1f, Assets.Instance.GetSprite("sword"), (aggressor.GetFacingDirection() + 3) % 4 + 1, 0.0f);

            p.SolidVsMap     = false;
            p.SolidVsDynamic = false;
            p.nDamage        = 5;
            p.bOneHit        = true;

            g_engine.AddProjectile(p);

            return(false);
        }
Exemplo n.º 3
0
 public void AddProjectile(cDynamic_Projectile proj)
 {
     m_vecProjectiles.Add(proj);
 }