void TakeLifePoints(Player[] targetPlayers) { foreach (Player p in targetPlayers) { if (p != null) { if (p.Alive && p.LifePoints > 0) { if (p.LifePoints - LifeDmg <= 0) { p.LifePoints = 0; p.Alive = false; CurrentGame.gameState = GameState.GameOver; ParentMap.creatureCue = CurrentGame.soundBank.GetCue("loppukumi"); ParentMap.creatureCue.Play(); } else { p.LifePoints -= LifeDmg; } BugInfoBox bugBox = HUD.BugBoxes.Find(bb => bb.Target == this); if (bugBox != null) { bugBox.locked = false; CurrentGame.HUD.bugHoverCounter = HUD.bugHoverFade; } Alive = false; ParentMap.AliveCreatures.Remove(this); } } } }
//internal bool AbovePoint; public GroupInfoBox(Vector2 pos, SpawnGroup spg, bool aboveSpawnPoint) : base(pos) { Group = spg; SmallBugTex = spg.InfoTexture; TexOrigin = spg.infoTexOrigin; //AbovePoint = aboveSpawnPoint; //TexOrigin.X += 0.5f; Bounds = new Rectangle((int)pos.X, (int)pos.Y, boxWidth, boxHeight); //(int)(CurrentGame.font.LineSpacing * textScale) + boxWidth); //TextPos = new Vector2(Bounds.X + Padding, Bounds.Y + YPadding); if (aboveSpawnPoint) { PosY -= 2; BugBox = new BugInfoBox(new Vector2(Bounds.Center.X - DefaultWidth * 0.5f, Bounds.Top - DefaultHeight), Group.ExampleCreature, false, aboveSpawnPoint, this); } else { PosY += 1; BugBox = new BugInfoBox(new Vector2(Bounds.Center.X - DefaultWidth * 0.5f, Bounds.Bottom), Group.ExampleCreature, false, aboveSpawnPoint, this); } }
public void TakeAHit(Bullet bullet) { if (Alive) { float hpLoss; if (ElemArmors.HasAny) { GeneType bulletPrimarySpec = bullet.ElemSpecs.GetPrimaryElem(); GeneType creaturePrimaryArmor = ElemArmors.GetPrimaryElem(); float bStr = bullet.ElemSpecs.GetPrimaryElemStrength(); float cArm = ElemArmors.GetPrimaryElemStrength(); float armorReducedNormalDmg = (bullet.dmg * (1 - bStr)) * (1 - cArm); // normal vs armor = (dmg * (1-spec)) * (1-armor) float penetratingDmg = bullet.dmg * bStr; //----------------------- penetration = dmg * specialization if (bulletPrimarySpec == creaturePrimaryArmor) // match { hpLoss = penetratingDmg + armorReducedNormalDmg; } else // uncompatible bullet { hpLoss = armorReducedNormalDmg; } } else if (bullet.ElemSpecs.HasAny) // if just the bullet has specialization { float bStr = bullet.ElemSpecs.GetPrimaryElemStrength(); hpLoss = bullet.dmg * (1 - bStr); } else { hpLoss = bullet.dmg; } if (hp - hpLoss <= 0) { hp = 0; Alive = false; ParentMap.Players[0].GenePoints[0] += (int)Math.Round(ElemArmors[GeneType.Red] * 10); ParentMap.Players[0].GenePoints[1] += (int)Math.Round(ElemArmors[GeneType.Green] * 10); ParentMap.Players[0].GenePoints[2] += (int)Math.Round(ElemArmors[GeneType.Blue] * 10); CurrentGame.HUD.UpdateGeneBars(); ParentMap.Players[0].EnergyPoints += EnergyBounty; ParentMap.AliveCreatures.Remove(this); BugInfoBox bugBox = HUD.BugBoxes.Find(bb => bb.Target == this); if (bugBox != null) { bugBox.locked = false; CurrentGame.HUD.bugHoverCounter = HUD.bugHoverFade; } Splatter.IsActive = true; Splatter.Location = Location; Splatter.EmitterAngle = Vector2.Normalize(Location - bullet.originPoint); ParentMap.creatureCue = CurrentGame.soundBank.GetCue("narsk"); ParentMap.creatureCue.Play(); } else { hp -= hpLoss; if (bullet.slow[0] > 0) //if bullet has a slow percentage { if (!isSlowed) { //Speed *= bullet.slow[0] * 0.01f; // DONE IN UPDATE TO SMOOTH DOWN THE CHANGE CurrentSlowEffect = bullet.slow; slowedCounter = (int)bullet.slow[1]; isSlowed = true; justGotSlowed = true; } else { if (bullet.slow[0] > CurrentSlowEffect[0]) { CurrentSlowEffect = bullet.slow; } //else // if already slowed more... ? slowedCounter = (int)bullet.slow[1]; justGotSlowed = false; } } } } }