Esempio n. 1
0
 public void getHit(Bullet b, Mission m)
 {
     if (invincibleTimer > 0)
         return;
     //RAW DAMAGE//
     int dmg = b.Strength;
     //////////////
     gotHit = true;
     health = Math.Max(health - dmg, 0);
     m.dmgIn += dmg;
     invincibleTimer = Constants.PLAYER_BULLET_INVINCIBILITY;
     hitDelay = maxHitDelay;
 }
Esempio n. 2
0
File: NPC.cs Progetto: kayorga/3DSP
        public void getHit(Bullet b, Mission m)
        {
            if (!isDead && b.fromPlayer)
            {
                int dmg = b.Strength;

                Random ran = new Random();

                dmg = (byte) (ran.Next(9*dmg, 11*dmg) * 0.1f);

                float dmgModifier = 1;

                //apply weakness and resistance
                if (b.Element != Constants.ELM_NIL && b.Element == elWeakness) dmgModifier *= 1.5f;
                else if (b.Element != Constants.ELM_NIL && b.Element == element) dmgModifier /= 1.5f;

                if (b.Type != Constants.TYP_NIL && b.Type == typeWeakness) dmgModifier *= 1.5f;
                else if (b.Type != Constants.TYP_NIL && b.Type == typeResistance) dmgModifier /= 1.5f;

                dmg = (int)(dmg * dmgModifier);

                //apply crit chance and play hit sound
                bool crit = false;
                if (ran.Next(100) < 8)
                {
                    crit = true;
                    dmg *= 2;
                    audio.playCrit();
                }
                else audio.playNPCHit(dmgModifier);

                //cap damage between 1 and health
                dmg = Math.Max(dmg, 1);
                dmg = Math.Min(dmg, health);

                //apply damage and add to dmg out
                health -= dmg;
                m.dmgOut += dmg;

                //knockback effect
                Vector3 push = b.Direction;
                push.Normalize();
                this.position += push * 0.5f;
                moving = false;
                //isHit = true;

                //add new dmg number for new dmg
                sbyte dx = (sbyte)(ran.Next(41) - 20);
                sbyte dy = (sbyte)(ran.Next(21) - 10);
                dmgNumbers.Add(new DmgNumber(dmg, crit, dx, dy));
            }
        }