public override void Destroy() { SoundManager.Play3DSound("MineImpact", new Vector3(Position.X(), Y, Position.Y()), 0.25f, 800, 2f); QuadGrid grid = Parent2DScene.quadGrids.First.Value; float BulletExplosionDistance = 200; for (int i = 0; i < 2; i++) { foreach (Basic2DObject o in grid.Enumerate(Position.get(), new Vector2(BulletExplosionDistance))) { if (o.GetType().IsSubclassOf(typeof(BasicShipGameObject))) { BasicShipGameObject s = (BasicShipGameObject)o; float dist = Vector2.Distance(s.Position.get(), Position.get()) - o.Size.X() / 2; if (dist < BulletExplosionDistance && GetTeam() != s.GetTeam()) { float DistMult = 1; if (dist > 0) { DistMult = (BulletExplosionDistance - dist) / BulletExplosionDistance; } s.Damage(DistMult * 4, DistMult, Vector2.Normalize(s.Position.get() - Position.get()) * 1 * DistMult, this, AttackType.Green); } } } } base.Destroy(); }
public virtual void EMP(BasicShipGameObject Damager, int Level) { SoundManager.Play3DSound("SnapHit", new Vector3(Position.X(), Y, Position.X()), 0.25f, 800, 2); FreezeTime = 5000; StunState = AttackType.Blue; LastDamager = Damager; }
public virtual void Collide(BasicShipGameObject s) { if (!s.IsAlly(ParentUnit)) { if (!BulletCanBounce || !s.BulletBounces(this)) { float Damage = getDamage(s, 1); Damage *= ParentUnit.GetDamageMult(); s.Damage(Damage, PushTime * Damage, Speed * PushVelocityMult, ParentUnit, attackType); } else { BulletHasBounced = true; if (!BounceSound) { SoundManager.Play3DSound("ShieldBounce", new Vector3(Position.X(), Y, Position.Y()), 0.35f, 500, 1); BounceSound = true; } if (s.GetType().IsSubclassOf(typeof(UnitBasic))) { UnitBasic b = (UnitBasic)s; b.ShieldFlash(1); } Speed = Vector2.Reflect(Speed, Vector2.Normalize(s.Position.get() - PreviousPosition)); Position.set(PreviousPosition); return; } } if (TargetHitCount < MaxHits) { if (TargetsHit == null) { TargetsHit = new BasicShipGameObject[MaxHits]; TargetsHit[TargetHitCount++] = s; } else if (!TargetsHit.Contains(s)) { TargetsHit[TargetHitCount++] = s; } else { return; } } else { Destroy(); } }
public override void Destroy() { SoundManager.Play3DSound("FieldCollapse", new Vector3(Position.X(), Y, Position.Y()), 1, 800, 2); if (SoundInstance != null && !SoundInstance.IsDisposed) { SoundInstance.Dispose(); SoundInstance = null; } AllFields.Remove(this); base.Destroy(); }
public override void Damage(float damage, float pushTime, Vector2 pushSpeed, BasicShipGameObject Damager, AttackType attackType) { if ((InvTime < 1 && (FieldStateTime < 1 || fieldState != FieldState.Cloaked)) || attackType == AttackType.Explosion || attackType == AttackType.Melee) { if (CanCloak) { SoundManager.Play3DSound("UnitCloak", new Vector3(Position.X(), Y, Position.Y()), 0.25f, 800, 2); fieldState = FieldState.Cloaked; HasCloaked = true; CanCloak = false; FieldStateTime = GetCloakTime(); } else { if (attackType != AttackType.White) { SummonUnits(); } NoShootTime = MaxNoShootTime; if (attackType == AttackType.White) { ThreatLevel *= 1.5f; } if (!PathFindingManager.CollisionLine(Position.get(), Damager.Position.get())) { AngerTime = MaxAngerTime; CurrentAttackTarget = Damager; } base.Damage(damage, pushTime, pushSpeed, Damager, attackType); if (HullDamage >= HullToughness && Damager.FactionNumber != NeutralManager.NeutralFaction && ScoreToGive > 0) { if (CanDeathSound) { SoundManager.Play3DSound(DeathSound, new Vector3(Position.X(), Y, Position.Y()), DeathVolume * 0.5f, DeathDistance, DeathExponenent * 2); } ScoreToGive = (int)(ScoreToGive * (0.75f + 0.25f * UnitLevel) * (IsHuge ? 1.25f : 1) * (HasCloaked || CanCloak ? 1.5f : 1) * (CanSummon || HasSummoned ? 4 : 1)); TextParticleSystem.AddParticle(new Vector3(Position.X(), Y, Position.Y()), ScoreToGive.ToString(), (byte)Damager.GetTeam()); FactionManager.AddScore(Damager.FactionNumber, ScoreToGive); FactionManager.Factions[Damager.FactionNumber].roundReport.UnitKills++; ScoreToGive = 0; } } } }
public virtual void Fire(float DirectionR) { if (ParentUnit == null) { return; } if (ReloadTime <= 0) { bool CreatedMatrix = false; Matrix RotationMatrix = Matrix.Identity; SoundManager.Play3DSound(FireSound, new Vector3(ParentUnit.Position.X(), ParentUnit.Y, ParentUnit.Position.Y()), FireVolume, FireDistance, FireExponent); if (!CreatedMatrix) { CreatedMatrix = true; RotationMatrix = Matrix.CreateRotationZ(DirectionR); } ROF -= MaxROF; BurstTime = 0; ClipSize--; BurstSize--; if (Ammo > 0) { Ammo--; } for (int i = 0; i < BulletCount; i++) { Bullet b = getBullet(); ParentUnit.ParentLevel.AddObject(b); b.SetShipParent(ParentUnit); b.SetPosition(ParentUnit.Position.get() + Vector2.Transform(getPositionPattern(i), RotationMatrix), false); b.SetSpeed(BulletSpeed * Logic.ToVector2(DirectionR + Accuracy - Rand.F() * Accuracy * 2 + getDirectionPattern(i))); b.SetAttackType(attackType); b.SetStartingPosition(b.getPosition()); b.SetDamage(Damage, PushTime, PushVelocityMult); b.SetModifierFactor(ModifierFactor); b.SetLifeTime(LifeTime); b.SetExplosive(BulletExplosionDistance, BulletExplosionDamage); //b.AddTime(ROF); } } }
public override bool Trigger() { if (RechargeTime > MaxRechargeTime) { DashTime = 0; RechargeTime = 0; Dashing = true; SoundManager.Play3DSound("PlayerDash", new Vector3(ParentShip.Position.X(), ParentShip.Y, ParentShip.Position.Y()), 0.4f, 300, 2); return(true); } return(false); }
public override bool SnapBounce() { if (Bounces > 0) { SoundManager.Play3DSound("ShieldBounce", new Vector3(Position.X(), Y, Position.Y()), 0.5f, 500, 1); ShieldFlash(1); Bounces = 0; return(false); } else { return(true); } }
public override void Update(GameTime gameTime) { if (!Dead) { bool PlaySound = false; SearchTime += gameTime.ElapsedGameTime.Milliseconds; if (SearchTime > MedicSearchTime) { SearchTime -= MedicSearchTime; SearchForNearby(); foreach (UnitTurret t in TurretsInRange) { if (!TurretsIHaveHealed.Contains(t)) { if (t.Dead) { t.Lives = 1; t.HullDamage = 0; t.ShieldDamage = 0; t.Rebuild(); t.IsCrushed = false; if (!IsUpdgraded) { ShouldDeathSound = false; BlowUp(); } if (IsUpdgraded) { TurretsIHaveHealed.AddLast(t); } if (!PlaySound) { PlaySound = true; SoundManager.Play3DSound("MedicRevive", new Vector3(Position.X(), Y, Position.Y()), 0.5f, 1000, 2); } } } } } } base.Update(gameTime); }
public override void Destroy() { if (ShouldDodge && DodgeBullets.Contains(this)) { DodgeBullets.Remove(this); } if (Commited && !NoInstanceCommit) { Commited = false; BulletInstancer.RemoveChild(this); } Destroyed = true; if (Armed && BulletExplosionDamage > 0 && BulletExplosionDistance > 0) { QuadGrid grid = Parent2DScene.quadGrids.First.Value; foreach (Basic2DObject o in grid.Enumerate(Position.get(), new Vector2(BulletExplosionDistance))) { if (o.GetType().IsSubclassOf(typeof(BasicShipGameObject))) { BasicShipGameObject s = (BasicShipGameObject)o; float dist = Vector2.Distance(s.Position.get(), Position.get()) - o.Size.X() / 2; if (dist < BulletExplosionDistance && !ParentUnit.IsAlly(s)) { float DistMult = 1; if (dist > 0) { DistMult = (BulletExplosionDistance - dist) / BulletExplosionDistance; } s.Damage(DistMult * BulletExplosionDamage, DistMult * PushTime, Vector2.Normalize(s.Position.get() - Position.get()) * PushVelocityMult * DistMult, ParentUnit, attackType); } } } } SoundManager.Play3DSound(ImpactString, new Vector3(Position.X(), Y, Position.Y()), ImpactVolume, ImpactDistance, ImpactExponent); base.Destroy(); }
public void SetFieldState(FieldState state, int Time) { if (FieldStateTime < 201) { if ((FieldStateTime < 1 || state != fieldState) && FieldSound) { if (state == FieldState.Cloaked) { SoundManager.Play3DSound("UnitCloak", new Vector3(Position.X(), Y, Position.Y()), 0.25f, 800, 2); } else { SoundManager.Play3DSound("UnitPowerUp", new Vector3(Position.X(), Y, Position.Y()), 0.25f, 800, 2); } FieldSound = false; } this.fieldState = state; this.FieldStateTime = Time; } }
public override void Interact(PlayerShip p) { if (miningPlatform == null && FactionManager.CanBuildMiningPlatform(p.FactionNumber)) { Vector3 P3 = new Vector3(Position.X(), 0, Position.Y()); for (int i = 0; i < 40; i++) { LineParticleSystem.AddParticle(P3, P3 + Rand.V3() * 1000, TeamInfo.GetColor(p.GetTeam())); } MiningPlatform m = FactionManager.GetMiningPlatform(p.FactionNumber); ParentLevel.AddObject(m); m.Position.set(Position.get()); setPlatform(m); SoundManager.Play3DSound("PlayerBuildMiningRing", new Vector3(m.Position.X(), Y, m.Position.Y()), 0.25f, 500, 1); if (p.PlacedStartingMineralRock) { FactionManager.AddCells(p.FactionNumber, -FactionManager.GetMiningPlatformCost(p.FactionNumber)); FactionManager.SetBuildingPlatform(p.FactionNumber, m); } else { FactionManager.GetFaction(p.FactionNumber).MiningPlatformCounter = 0; m.HullToughness *= 2; m.SetAsStarting(); p.PlacedStartingMineralRock = true; p.StartingMineralRock = this; } p.LastPlacedPlatform.AddFirst(m); PathFindingManager.AddMineralRock(m); } base.Interact(p); }
public override void Update(GameTime gameTime) { if (!Dead) { if (ShutDownTime > 0 || VirusTime > 0) { ShutDownTime = 0; VirusTime = 0; } else { SearchTime += gameTime.ElapsedGameTime.Milliseconds; if (SearchTime > PulseSearchTime) { SearchTime -= PulseSearchTime; bool Found = false; QuadGrid quad = Parent2DScene.quadGrids.First.Value; foreach (Basic2DObject o in quad.Enumerate(Position.get(), new Vector2(MaxEngagementDistance * 2))) { if (o.GetType().IsSubclassOf(typeof(UnitShip))) { UnitShip s = (UnitShip)o; if (!s.Dead && !s.IsAlly(this) && Vector2.Distance(Position.get(), o.Position.get()) < MaxEngagementDistance) { if (s.CanBeTargeted() && s.SnapBounce()) { s.ShieldDamage = s.ShieldToughness + 1; s.LastDamager = this; s.FreezeTime = 1000; s.StunState = AttackType.Melee; s.SetSpeed(Vector2.Normalize(s.Position.get() - Position.get()) * 16); } PulseSearchTime += (int)(StartingMaxSearchTime / 100f * (1.5f + s.UnitLevel)); Found = true; } } } if (Found) { SoundManager.Play3DSound("PulseTurretFire", new Vector3(Position.X(), Y, Position.Y()), 0.75f, 800, 2); Vector3 Position3 = new Vector3(Position.X(), 0, Position.Y()); for (int i = 0; i < 30; i++) { ParticleManager.CreateParticle(Position3, Rand.V3() * MaxEngagementDistance / 1000f * 3, ParticleColor, 40, 5); } for (int i = 0; i < 2; i++) { FlareSystem.AddLightingPoint(Position3, new Vector3(0.3f), new Vector3(0, 0, 1), MaxEngagementDistance / 10, 40, 5, 10); ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, MaxEngagementDistance * 6, 5); ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, MaxEngagementDistance * 3, 4); } } } } } base.Update(gameTime); }
public override void Update(GameTime gameTime, BasicController MyController) { if (!Dashing) { RechargeTime += gameTime.ElapsedGameTime.Milliseconds; if (MyController.LeftStick().Length() > 0.1f) { DashVector = Vector2.Normalize(MyController.LeftStick() * new Vector2(1, -1)); } } else { ParentShip.AddPosition(DashVector * DashSpeed * gameTime.ElapsedGameTime.Milliseconds / 1000f * 60f); ParentShip.InvTime = Math.Max(ParentShip.InvTime, 400); DashTime += gameTime.ElapsedGameTime.Milliseconds; if (DashTime > MaxDashTime) { bool PositionClear = true; foreach (Basic2DObject s in ParentShip.Parent2DScene.quadGrids.First.Value.Enumerate( ParentShip.Position.get(), new Vector2(ParentShip.PlayerSize))) { if (s != ParentShip) { if (s.GetType().IsSubclassOf(typeof(BasicShipGameObject))) { if (Vector2.Distance(ParentShip.getPosition(), s.getPosition()) < (ParentShip.PlayerSize + s.getSize().X) / 2) { BasicShipGameObject b = (BasicShipGameObject)s; if (b.Solid) { PositionClear = false; break; } } } else { WallNode n = (WallNode)s; if (n.wallConnector != null) { float MoveAmount = (ParentShip.PlayerSize + s.getSize().X * 0.75f) / 2 - Logic.DistanceLineSegmentToPoint(n.Position.get(), n.wallConnector.PositionNext, ParentShip.Position.get()); if (MoveAmount > 0) { PositionClear = false; break; } } } } } if (PositionClear && Dashing) { SoundManager.Play3DSound("PlayerDashReverse", new Vector3(ParentShip.Position.X(), ParentShip.Y, ParentShip.Position.Y()), 0.2f, 300, 2); Dashing = false; Vector3 Position3 = new Vector3(ParentShip.Position.X(), ParentShip.Y, ParentShip.Position.Y()); ParticleManager.CreateParticle(Position3, Vector3.Zero, PlayerShip.TeleportColor2, ParentShip.Size.X() * 5, 4); for (int i = 0; i < 30; i++) { ParticleManager.CreateParticle(Position3, Rand.V3() * 200, PlayerShip.TeleportColor2, 20, 5); } } } } base.Update(gameTime, MyController); }
public override void Update(GameTime gameTime) { if (!Dead) { if (ShutDownTime > 0 || VirusTime > 0) { ShutDownTime = 0; VirusTime = 0; } else { SearchTime += gameTime.ElapsedGameTime.Milliseconds; if (SearchTime > ProtectionSearchTime) { SearchTime -= ProtectionSearchTime; bool Found = false; QuadGrid quad = Parent2DScene.quadGrids.First.Value; float NewHealingAmount = HealingAmount; NewHealingAmount -= Heal(HealingAmount) / HealingAmount * HealingReduction; foreach (Basic2DObject o in quad.Enumerate(Position.get(), new Vector2(MaxEngagementDistance * 2))) { if (o.GetType().IsSubclassOf(typeof(UnitBuilding))) { UnitBuilding s = (UnitBuilding)o; if (!s.Dead && s.IsAlly(this) && Vector2.Distance(Position.get(), o.Position.get()) < MaxEngagementDistance) { if (s.CanBeTargeted()) { NewHealingAmount -= s.Heal(HealingAmount) / HealingAmount * HealingReduction; } Found = true; } } } if (Found) { HealingAmount = NewHealingAmount; SoundManager.Play3DSound("Healing", new Vector3(Position.X(), Y, Position.Y()), 0.75f, 800, 2); Vector3 Position3 = new Vector3(Position.X(), 0, Position.Y()); for (int i = 0; i < 30; i++) { ParticleManager.CreateParticle(Position3, Rand.V3() * MaxEngagementDistance / 1000f * 3, ParticleColor, 40, 5); } for (int i = 0; i < 2; i++) { ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, MaxEngagementDistance * 2, 5); ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, MaxEngagementDistance * 1, 4); } } } } } base.Update(gameTime); }
public void FireShot(Vector2 StartPosition, Vector2 EndPosition, float LineWidth) { SoundManager.Play3DSound("SiegeLaserFire", new Vector3(Position.X(), Y, Position.Y()), 0.75f, 1000, 1.5f); ParticleManager.CreateParticle(new Vector3(StartPosition.X, 0, StartPosition.Y), Vector3.Zero, LaserColor, 300, 5); ParticleManager.CreateParticle(new Vector3(StartPosition.X, 0, StartPosition.Y), Vector3.Zero, LaserColor, 300, 7); ParticleManager.CreateParticle(new Vector3(StartPosition.X, 0, StartPosition.Y), Vector3.Zero, LaserColor, 300, 4); int c = (int)Vector2.Distance(StartPosition, EndPosition) / 10; for (int i = 0; i < c; i++) { ParticleManager.CreateParticle( new Vector3(StartPosition.X, 0, StartPosition.Y) + (new Vector3(EndPosition.X - StartPosition.X, 0, EndPosition.Y - StartPosition.Y) * i / c), Vector3.Zero, LaserColor, 100, 5); } ParticleManager.CreateParticle(new Vector3(EndPosition.X, 0, EndPosition.Y), Vector3.Zero, LaserColor, 300, 5); ParticleManager.CreateParticle(new Vector3(EndPosition.X, 0, EndPosition.Y), Vector3.Zero, LaserColor, 300, 7); ParticleManager.CreateParticle(new Vector3(EndPosition.X, 0, EndPosition.Y), Vector3.Zero, LaserColor, 300, 4); QuadGrid quadGrid = Parent2DScene.quadGrids.First.Value; Vector2 UpperLeftCorner = Logic.Min(StartPosition, EndPosition) - new Vector2(200); Vector2 LowerRightCorner = Logic.Max(StartPosition, EndPosition) + new Vector2(200); QuadGridXMin = (int)((UpperLeftCorner.X - quadGrid.Min.X) / quadGrid.CellSize.X); QuadGridXMax = (int)((LowerRightCorner.X - quadGrid.Min.X) / quadGrid.CellSize.X); QuadGridYMin = (int)((UpperLeftCorner.Y - quadGrid.Min.Y) / quadGrid.CellSize.Y); QuadGridYMax = (int)((LowerRightCorner.Y - quadGrid.Min.Y) / quadGrid.CellSize.Y); if (QuadGridXMax > quadGrid.CellsX - 1) { QuadGridXMax = quadGrid.CellsX - 1; } if (QuadGridXMin > quadGrid.CellsX - 1) { QuadGridXMin = quadGrid.CellsX - 1; } if (QuadGridYMax > quadGrid.CellsY - 1) { QuadGridYMax = quadGrid.CellsY - 1; } if (QuadGridYMin > quadGrid.CellsY - 1) { QuadGridYMin = quadGrid.CellsY - 1; } if (QuadGridXMax < 0) { QuadGridXMax = 0; } if (QuadGridXMin < 0) { QuadGridXMin = 0; } if (QuadGridYMax < 0) { QuadGridYMax = 0; } if (QuadGridYMin < 0) { QuadGridYMin = 0; } foreach (Basic2DObject g in quadGrid.Enumerate(QuadGridXMin, QuadGridYMin, QuadGridXMax, QuadGridYMax)) { if (g.GetType().IsSubclassOf(typeof(BasicShipGameObject))) { BasicShipGameObject s = (BasicShipGameObject)g; if (!s.IsAlly(this) && CheckCircle(s, StartPosition, EndPosition, LineWidth)) { s = s.ReturnCollision(); s.Damage(LaserDamage * GetDamageMult(), 1, EndPosition - StartPosition, this, AttackType.Red); } } } }
public override void Update(GameTime gameTime) { if (!Dead) { if (ShutDownTime > 0 || VirusTime > 0) { if (ShutDownTime > 0) { ShutDownTime -= gameTime.ElapsedGameTime.Milliseconds * 3; } else { Rotation.set(Rotation.get() + MathHelper.ToRadians(gameTime.ElapsedGameTime.Milliseconds * 20)); } } else { SearchTime += gameTime.ElapsedGameTime.Milliseconds; if (SearchTime > SnapSearchTime) { SearchTime -= SnapSearchTime; bool Found = false; QuadGrid quad = Parent2DScene.quadGrids.First.Value; foreach (Basic2DObject o in quad.Enumerate(Position.get(), new Vector2(MaxEngagementDistance * 2))) { if (o.GetType().IsSubclassOf(typeof(UnitShip))) { UnitShip s = (UnitShip)o; if (!s.Dead && !s.IsAlly(this) && Vector2.Distance(Position.get(), o.Position.get()) < MaxEngagementDistance) { if (s.CanBeTargeted() && s.SnapBounce()) { s.EMP(this, IsUpdgraded ? 1 : 0); } SnapSearchTime += (int)(StartingMaxSearchTime / 20 * (1.5f + s.UnitLevel) / 2f); Found = true; } } } if (Found) { SoundManager.Play3DSound("SnapTurretFire", new Vector3(Position.X(), Y, Position.Y()), 0.75f, 800, 2); Vector3 Position3 = new Vector3(Position.X(), 0, Position.Y()); for (int i = 0; i < 30; i++) { ParticleManager.CreateParticle(Position3, Rand.V3() * MaxEngagementDistance / 1000f * 3, ParticleColor, 40, 5); } for (int i = 0; i < 2; i++) { FlareSystem.AddLightingPoint(Position3, new Vector3(0.3f), new Vector3(0, 0, 1), MaxEngagementDistance / 10, 40, 5, 10); ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, MaxEngagementDistance * 6, 5); ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, MaxEngagementDistance * 3, 4); } } } } } base.Update(gameTime); }
protected virtual void Upgrade() { SoundManager.Play3DSound("PlayerLevelUp", new Vector3(Position.X(), 0, Position.Y()), 0.25f, 1000, 2); }
private void UpdateFieldState(GameTime gameTime) { InvTime -= gameTime.ElapsedGameTime.Milliseconds; if (InvTime < 1) { if (FieldStateTime > 0) { FieldStateTime -= gameTime.ElapsedGameTime.Milliseconds; if (fieldState == FieldState.SpeedBoost) { if (MyColor.R > 64) { MyColor.R = (byte)Math.Max(MyColor.R - gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed * 255, 64); } if (MyColor.G < 255) { MyColor.G = (byte)Math.Min(MyColor.G + gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed * 255, 255); } if (MyColor.B > 64) { MyColor.B = (byte)Math.Max(MyColor.B - gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed * 255, 64); } ParticleManager.CreateParticle(new Vector3(Position.X(), Y, Position.Y()), Vector3.Zero, new Color(0.25f, 1, 0.5f), Size.X() * 10, 1); } if (fieldState == FieldState.DamageBoost) { if (MyColor.R < 255) { MyColor.R = (byte)Math.Max(MyColor.R + gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed * 255, 255); } if (MyColor.G > 64) { MyColor.G = (byte)Math.Min(MyColor.G - gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed * 255, 64); } if (MyColor.B > 64) { MyColor.B = (byte)Math.Max(MyColor.B - gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed * 255, 64); } ParticleManager.CreateParticle(new Vector3(Position.X(), Y, Position.Y()), Vector3.Zero, new Color(1, 0.5f, 0.25f), Size.X() * 10, 1); } if (fieldState == FieldState.Cloaked) { if (CloakAlpha < 1) { if (!CloakCommited && !Dead) { CloakCommited = true; InstanceManager.AddDisplacementChild(this); } CloakAlpha += gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed; if (CloakAlpha > 1) { CloakAlpha = 1; MyColor = new Color(0.25f, 0.25f, 0.25f, 0) * 0; } else { MyColor = new Color(0.25f, 0.25f, 0.25f, 1) * (1 - CloakAlpha); } } if (FieldStateTime < 0) { SoundManager.Play3DSound("UnitUnCloak", new Vector3(Position.X(), Y, Position.Y()), 0.2f, 700, 3); } } } else { if (CloakAlpha > 0) { CloakAlpha -= gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed; if (CloakAlpha < 0) { CloakAlpha = 0; MyColor = new Color(0.25f, 0.25f, 0.25f, 1); if (CloakCommited) { CloakCommited = false; InstanceManager.RemoveDisplacementChild(this); } } else { MyColor = new Color(0.25f, 0.25f, 0.25f, 1) * (1 - CloakAlpha); } } else { //if (IsGhostMode) // ParticleManager.CreateParticle(new Vector3(Position.X(), Y, Position.Y()), Vector3.Zero, new Color(0.5f, 0.25f, 0.5f), Size.X() * 10, 1); int TargetR = 64; int TargetB = 64; if (MyColor.R < TargetR) { MyColor.R = (byte)Math.Min(MyColor.R + gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed * 255, TargetR); } else if (MyColor.R > TargetR) { MyColor.R = (byte)Math.Max(MyColor.R - gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed * 255, TargetR); } if (MyColor.G < 64) { MyColor.G = (byte)Math.Min(MyColor.G + gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed * 255, 64); } else if (MyColor.G > 64) { MyColor.G = (byte)Math.Max(MyColor.G - gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed * 255, 64); } if (MyColor.B < TargetB) { MyColor.B = (byte)Math.Min(MyColor.B + gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed * 255, TargetB); } } } } else { if (MyColor.R < 255) { MyColor.R = (byte)Math.Min(MyColor.R + gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed * 255, 255); } if (MyColor.G < 255) { MyColor.G = (byte)Math.Min(MyColor.G + gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed * 255, 255); } if (MyColor.B < 255) { MyColor.B = (byte)Math.Min(MyColor.B + gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed * 255, 255); } } }
public override void BlowUp() { if (Dead || Lives < 1) { return; } Vector3 P3 = new Vector3(Position.X(), 0, Position.Y()); for (int i = 0; i < 10; i++) { LineParticleSystem.AddParticle(P3, P3 + Rand.V3() * MaxEngagementDistance, TeamInfo.GetColor(GetTeam())); } foreach (Faction f in FactionManager.Factions) { if (MyCard == null) { MyCard = (TurretCard)FactionCard.FactionTurretDeck[0]; } if (f.Team != GetTeam()) { f.roundReport.TurretsKilled++; f.AddEvent(MyCard.Name + " Destroyed", new Color(1, 0.5f, 0.5f), FactionEvent.KillTexture); } else { f.roundReport.TurretsLost++; f.AddEvent(MyCard.Name + " Lost", new Color(1, 0.5f, 0.5f), FactionEvent.LossTexture); } } if (ShouldDeathSound) { SoundManager.Play3DSound(DeathSound, new Vector3(Position.X(), Y, Position.Y()), DeathVolume, 1000, 1); ShouldDeathSound = false; } FreezeMult = 0; VirusTime = 0; DeathParticles(); Lives--; Dead = true; if (MyBustedTurret == null) { MyBustedTurret = new BustedTurret(this); ParentLevel.AddObject(MyBustedTurret); MyBustedTurret.SetPosition(getPosition()); } MyBustedTurret.WorldMatrix = WorldMatrix; MyBustedTurret.Activate(); InstanceManager.RemoveChild(this); RemoveTag(GameObjectTag._2DSolid); RemoveTag(GameObjectTag._2DForward); LinkedList <GameObject> GList = Parent2DScene.GetList(GameObjectTag._2DSolid); if (GList.Contains(this)) { GList.Remove(this); } BuildTimer = 0; float BulletExplosionDistance = 200; float BulletExplosionDamage = 1f; QuadGrid grid = Parent2DScene.quadGrids.First.Value; for (int i = 0; i < 2; i++) { bool ActivateDeathSound = true; foreach (Basic2DObject o in grid.Enumerate(Position.get(), new Vector2(BulletExplosionDistance * 2))) { if (o.GetType().IsSubclassOf(typeof(UnitShip))) { BasicShipGameObject s = (BasicShipGameObject)o; float dist = Vector2.Distance(s.Position.get(), Position.get()) - o.Size.X() / 2; if (dist < BulletExplosionDistance && GetTeam() != s.GetTeam() && s.CanBeTargeted()) { float DistMult = 1; if (dist > 0) { DistMult = (BulletExplosionDistance - dist) / BulletExplosionDistance; } if (s.GetType().IsSubclassOf(typeof(UnitShip))) { UnitShip ship = (UnitShip)s; ship.CanDeathSound = ActivateDeathSound; } s.Damage(DistMult * BulletExplosionDamage, DistMult, Vector2.Normalize(s.Position.get() - Position.get()), this, AttackType.Explosion); if (s.Dead) { ActivateDeathSound = false; } else if (s.GetType().IsSubclassOf(typeof(UnitShip))) { UnitShip ship = (UnitShip)s; ship.CanDeathSound = true; } } } } } if (ShieldAlpha > 0) { ShieldInstancer.Remove(this); ShieldAlpha = -1; } }
public override void Update(GameTime gameTime) { if (!Dead) { MineAddTime += gameTime.ElapsedGameTime.Milliseconds; if (MineAddTime > MaxMineAddTime) { MinesToAdd++; MineAddTime = 0; SearchTime -= MaxSearchTime; QuadGrid quad = Parent2DScene.quadGrids.First.Value; foreach (Basic2DObject o in quad.Enumerate(Position.get(), new Vector2(MaxEngagementDistance * 2))) { if (o.GetType().IsSubclassOf(typeof(UnitBasic))) { UnitBasic s = (UnitBasic)o; float d = Vector2.Distance(Position.get(), o.Position.get()); if (!s.IsAlly(this) && s.CanBeTargeted() && d < MaxEngagementDistance + o.Size.X() / 2) { if (Mines.Count > 0) { float BestDistance = 10000; Mine BestMine = null; foreach (Mine m in Mines) { float MineDist = Vector2.Distance(m.Position.get(), o.Position.get()); if (MineDist < BestDistance) { BestDistance = MineDist; BestMine = m; } } BestMine.SetAttackTarget(s); Mines.Remove(BestMine); SoundManager.Play3DSound("MineFieldTarget", new Vector3(Position.X(), Y, Position.Y()), 0.35f, 1000, 2); } if (d < (Size.X() + o.Size.X())) { MinesToAdd = 0; } break; } } } } if (Mines.Count >= MaxMines) { MinesToAdd = 0; } while (MinesToAdd > 0) { Mine m = new Mine(this, FactionNumber); ParentLevel.AddObject(m); Mines.AddLast(m); Vector2 toPosition = Position.get() + Rand.V2() * Size.X() / 2; m.Position.set(toPosition); MinesToAdd--; } } base.Update(gameTime); }
public virtual void Fire(GameTime gameTime) { if (ReloadTime <= 0) { bool CreatedMatrix = false; Matrix RotationMatrix = Matrix.Identity; ChargeTime += gameTime.ElapsedGameTime.Milliseconds; if (ChargeTime > MaxChargeTime) { while (ROF >= MaxROF && ClipSize > 0 && BurstSize > 0 && (Ammo > 0 || Ammo == -100)) { Vector3 P = Parent != null ? new Vector3(Parent.getParent().Position.X(), 0, Parent.getParent().Position.Y()) : new Vector3(ParentUnit.Position.X(), 0, ParentUnit.Position.Y()); SoundManager.Play3DSound(FireSound, P, FireVolume, FireDistance, FireExponent); ChargeTime = 0; if (!CreatedMatrix) { CreatedMatrix = true; if (Parent != null) { RotationMatrix = Matrix.CreateRotationZ(-Parent.getRotation()); } else if (ParentUnit.Guns != null) { RotationMatrix = Matrix.CreateRotationZ(-ParentUnit.Guns[0].getRotation()); } } ROF -= MaxROF; BurstTime = 0; ClipSize--; BurstSize--; if (Ammo > 0) { Ammo--; } for (int i = 0; i < BulletCount; i++) { Bullet b = getBullet(); if (Parent != null) { if (Parent.getParent().GetType().IsSubclassOf(typeof(UnitShip))) { UnitShip s = (UnitShip)Parent.getParent(); if (s.IsHuge) { b.Big = true; } } Parent.getParent().ParentLevel.AddObject(b); b.SetShipParent(Parent.getParent()); ParentUnit = Parent.getParent(); Vector3 P3 = InstanceManager.GetWeaponPosition(ParentUnit.GetIntType(), new Vector3(ParentUnit.Position.X(), ParentUnit.Y, ParentUnit.Position.Y()), ref ParentUnit.RotationMatrix, ParentUnit.WeaponIndexID++, ParentUnit.Size.X()); Vector2 P2 = getPositionPattern(i); if (P2 != Vector2.Zero) { P2 = Vector2.Transform(P2, RotationMatrix); } b.SetPosition(new Vector2(P3.X, P3.Z) + P2, false); b.Y = P3.Y; Vector2 v = BulletSpeed * Logic.ToVector2(Parent.getRotation() + Accuracy - Rand.F() * Accuracy * 2 + getDirectionPattern(i)); b.SetSpeed(v); } else { ParentUnit.ParentLevel.AddObject(b); if (ParentUnit.GetType().IsSubclassOf(typeof(UnitShip))) { UnitShip s = (UnitShip)ParentUnit; if (s.IsHuge) { b.Big = true; } } b.SetShipParent(ParentUnit); b.SetPosition(ParentUnit.Position.get() + Vector2.Transform(getPositionPattern(i), RotationMatrix), false); b.SetSpeed(BulletSpeed * Logic.ToVector2(ParentUnit.Guns[0].getRotation() + Accuracy - Rand.F() * Accuracy * 2 + getDirectionPattern(i))); } b.SetAttackType(attackType); b.SetStartingPosition(b.getPosition()); b.SetDamage(Damage, PushTime, PushVelocityMult); b.SetModifierFactor(ModifierFactor); b.SetLifeTime(LifeTime); b.SetExplosive(BulletExplosionDistance, BulletExplosionDamage); b.AddTime(ROF); } } } else { CreateChargeParticles(ChargeTime / (float)(MaxChargeTime)); } if (ClipSize <= 0) { ReloadTime += gameTime.ElapsedGameTime.Milliseconds; } } }
public virtual void Collide(GameTime gameTime, BasicShipGameObject Other) { if (Other == null) { return; } if (!Dead && !Other.Dead && !Other.IsAlly(this) && FreezeTime < 0 && Other.GetType().IsSubclassOf(typeof(UnitBasic))) { UnitBasic u = (UnitBasic)Other; if (u.FreezeTime < 0) { Vector3 Position3 = new Vector3((Position.X() + Other.Position.X()) / 2, Y, (Position.Y() + Other.Position.Y()) / 2); if (CollisionSound.Equals("") && u.CollisionSound.Equals("")) { SoundManager.Play3DSound("CollisionImpact", Position3, 0.5f, 300, 2); } else { SoundManager.Play3DSound(CollisionSound.Equals("") ? u.CollisionSound : CollisionSound, Position3, 0.5f, 300, 2); } Damage(Other.fieldState != FieldState.SpeedBoost || Other.FieldStateTime < 1 ? Other.CollisionDamage : Other.CollisionDamage * 1.25f , 5, Position.get() - Other.Position.get(), Other, AttackType.Melee); Other.Damage(fieldState != FieldState.SpeedBoost || FieldStateTime < 1 ? CollisionDamage : CollisionDamage * 1.25f , 5, Other.Position.get() - Position.get(), this, AttackType.Melee); if (!GetType().IsSubclassOf(typeof(UnitBuilding))) { FreezeTime = Math.Max(FreezeTime, Other.CollisionFreezeTime); StunState = AttackType.Melee; } if (!u.GetType().IsSubclassOf(typeof(UnitBuilding))) { u.FreezeTime = Math.Max(u.FreezeTime, CollisionFreezeTime); u.StunState = AttackType.Melee; } } } float MoveAmount = (Size.X() + Other.getSize().X) / 2 - Vector2.Distance(Other.Position.get(), Position.get()); if (Other.Moveable) { CollisionIteration++; if (CollisionIteration > 10000) { CollisionIteration = 0; } UnitBasic u = (UnitBasic)Other; if (Vector2.Distance(u.Position.get(), Position.get()) > 0.1f) { u.Push(u.Position.get() + Vector2.Normalize(Other.Position.get() - Position.get()) * MoveAmount / 2, 0); Push(Position.get() + Vector2.Normalize(Position.get() - Other.Position.get()) * MoveAmount / 2, 0); } else { u.Push(u.Position.get() + Vector2.One * MoveAmount, 0); Push(Position.get() - Vector2.One * MoveAmount, 0); } } else { if (Vector2.Distance(Other.Position.get(), Position.get()) > 0.1f) { Push(Position.get() + Vector2.Normalize(Position.get() - Other.Position.get()) * MoveAmount, MoveAmount); } else { Push(Position.get() + Vector2.One * MoveAmount * 2, MoveAmount * 2); } } }
public override void Damage(float damage, float pushTime, Vector2 pushSpeed, BasicShipGameObject Damager, AttackType attackType) { if (damage < 0) { return; } if (Resistence == attackType) { damage /= 3f; } if (Damager != this && Damager != null) { LastDamager = Damager; } if (Moveable && Resistence != attackType) { if (Weakness != attackType) { float NewFreezeTime = StunTime; if (attackType != AttackType.Melee) { NewFreezeTime /= Mass; } if (FreezeTime < NewFreezeTime) { FreezeTime = NewFreezeTime; } } else { float NewFreezeTime = WeaknessStunTime; if (attackType != AttackType.Melee) { NewFreezeTime /= Mass; } if (FreezeTime < NewFreezeTime) { StunState = attackType; FreezeTime = NewFreezeTime; damage *= 2; } } float l = pushSpeed.Length(); if (l > 0.1f) { SetSpeed(Vector2.Normalize(pushSpeed) * (attackType != AttackType.Melee ? 8 : 8 / Mass)); } } if (ShieldToughness > 0 && ShieldDamage < ShieldToughness) { if (attackType != AttackType.Blue && BuzzTime > MaxBuzzTime) { SoundManager.Play3DSound("ShieldFlare", new Vector3(Position.X(), Y, Position.Y()), 0.35f, 500, 1); BuzzTime = 0; } ShieldFlash(1); } base.Damage(damage, pushTime, pushSpeed, Damager, attackType); }