//--------Constructors------------------------------ public Tower(char symbol, string name, Point mapCoord, float range, float firerate, Texture2D[] textures, GeneSpecs geneSpecs, Texture2D bulletTexture, float bulletSpeed, short dmg, DmgType dmgType, int splashRange, float[] slow, int cost, int buildTime, bool isExample) { ParentMap = CurrentGame.currentMap; Name = name; Symbol = symbol; MapCoord = mapCoord; //ScreenLocation = map.ToScreenLocation(mapCoord); /*this.screenLocation = new Vector2((float)(mapLocation[0] * map.stackedWidth + map.drawPos.X), * (float)(mapLocation[1] * map.TileHeight + mapLocation[0] % 2 * (map.TileHeight / 2)) + map.drawPos.Y);*/ Range = range; InitRange = range; FireRate = firerate; BulletSpeed = bulletSpeed; radiusTextures = new Texture2D[2]; //this.radiusTextures[0] = radiusTexture; MakeRadiusCircle(); ShowRadius = false; Textures = textures; //this.angleOffset = angleOffset; //angle = (float)Math.PI * 1.5f; texOrigin = new Vector2(textures[0].Width / 2, textures[0].Height / 2); this.bulletTexture = bulletTexture; Dmg = dmg; DmgType = dmgType; this.slow = slow; Cost = cost; BuildTime = buildTime; buildTimer = buildTime; IsExample = isExample; if (!IsExample) { buildFinishedCounter = buildFinishedInit; //---------------------------ist dies der rihl leif? } Built = false; Bullets = new List <Bullet>(10); towerTypeIdx = Array.IndexOf(TowerSymbols, symbol); towerBranch = towerTypeIdx % 6; SplashRange = splashRange; CreaturesInRange = new List <Creature>(); ColoredInRange = new List <Creature>(); PossibleTargets = new List <Creature>(); GeneSpecs = geneSpecs; GeneSpecs.BaseTiers[Math.Max((int)GeneSpecs.GetPrimaryElem() - 1, 0)] = (int)(GeneSpecs.GetPrimaryElemStrength() * 100) / GeneSpecs.TierSize; FireRateSec = 1000 / (firerate * (float)ParentMap.ParentGame.TargetElapsedTime.TotalMilliseconds); DPS = dmg * FireRateSec; }
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; } } } } }