public void Update(GameTime gameTime) { Interpolation += gameTime.ElapsedGameTime.Milliseconds / (20f * Math.Max(1, Vector3.Distance(To, From))); while (Interpolation > 1) { Interpolation -= 1; LineParticleSystem.AddParticle(To, From, Color.White); From = To; To = Rand.V3() * ScaleSize / 25f; } Vector3 InterpolatedPosition = Vector3.Lerp(From, To, Interpolation); ParticleManager.CreateParticle(InterpolatedPosition, Vector3.Zero, Color.White, ScaleSize * 0.001f, 1); }
public void Update(GameTime gameTime) { Interpolation += gameTime.ElapsedGameTime.Milliseconds / (2f * Math.Max(1, Vector3.Distance(OldPosition, NewPosition))); while (Interpolation > 1) { OldPosition = NewPosition; NewPosition = Function(); LineParticleSystem.AddParticle(OldPosition, NewPosition, Color.White); Interpolation = 0; } DrawPosition = Vector3.Lerp(OldPosition, NewPosition, Interpolation); ParticleManager.CreateParticle(DrawPosition, Vector3.Zero, Color.White, 10, 1); ParticleManager.CreateParticle(DrawPosition, Vector3.Zero, Color.White * 0.1f, 10, 5); }
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 void Update(GameTime gameTime) { Vector3 OldPosition = Parent.Points[CurrentPosition]; Vector3 NewPosition = CurrentPosition + 1 < Parent.Points.Count ? Parent.Points[CurrentPosition + 1] : Parent.Points[0]; Interpolation += gameTime.ElapsedGameTime.Milliseconds / (20f * Math.Max(1, Vector3.Distance(OldPosition, NewPosition))); while (Interpolation > 1) { OldPosition = Parent.Points[CurrentPosition]; NewPosition = CurrentPosition + 1 < Parent.Points.Count ? Parent.Points[CurrentPosition + 1] : Parent.Points[0]; if (Vector3.Distance(OldPosition, NewPosition) < Parent.Distance) { LineParticleSystem.AddParticle(OldPosition, NewPosition, Color.White); } Interpolation = 0; CurrentPosition++; if (CurrentPosition > Parent.Points.Count - 1) { CurrentPosition = 0; } if (!Parent.BuiltPoints.Contains(Parent.Points[CurrentPosition])) { Parent.BuiltPoints.Add(Parent.Points[CurrentPosition]); } } OldPosition = Parent.Points[CurrentPosition]; NewPosition = CurrentPosition + 1 < Parent.Points.Count ? Parent.Points[CurrentPosition + 1] : Parent.Points[0]; Vector3 InterpolatedPosition = Vector3.Lerp(OldPosition, NewPosition, Interpolation); ParticleManager.CreateParticle(InterpolatedPosition, Vector3.Zero, Color.White, ScaleSize * 0.0005f, 1); ParticleManager.CreateParticle(InterpolatedPosition, Vector3.Zero, Color.White * 0.1f, ScaleSize * 0.0005f, 5); }
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; } }