//This method updates the player's position and what orbs it has. public void UpdatePlayer() { if (!IsCheat) { UpdateGravity(Player); } Player.Move(HorizontalInput, VerticalInput); Well well = Player.WellOver(); if (well != null) { int originalColor = well.Orbs; if (!well.IsStable) { if (!IsCheat && !Player.IsImmune) { IsOver = true; Timer.Stop(); } } else if (Player.DepositOrbs(well)) { int objIndex = StableWells.FindIndex(item => item.Equals(well)); UpdateAnimationEvent(this, new AnimationEventArgs(false, AnimationType.Stable, objIndex, 12, 0)); StableWells.Remove(well); GameObjects.Remove(well); Player.GamePowerup.AddNew(); Points += 100; } else if (well.Orbs != originalColor) { GameInvokeSoundEvent(this, SoundEffect.OrbDrop); int objIndex = StableWells.FindIndex(item => item.Equals(well)); UpdateAnimationEvent(this, new AnimationEventArgs(true, AnimationType.Stable, objIndex, well.Orbs, 6 + well.Orbs)); } } Orb orb = Player.OrbOver(); if (orb != null) { if (Player.Orbs.Count < 5) { Orbs.Remove(orb); GameObjects.Remove(orb); Player.Orbs.Add(orb.Color); Player.Orbs.Sort(); GameInvokeSoundEvent(this, SoundEffect.OrbGrab); } } if (Player.ImmuneTicksLeft > 0) { --Player.ImmuneTicksLeft; } if (Player.ImmuneTicksLeft == 0) { Player.IsImmune = false; } }
//Updates AI position and collected orbs public void UpdateAI() { foreach (AIShip aI in AIShips.ToList()) { UpdateGravity(aI); aI.AIMove(); Well well = aI.WellOver(); if (well != null) { int originalColor = well.Orbs; if (!well.IsStable) { if (well.IsTrap && well.Owner == Player) { Points += 200; } int objIndex = AIShips.FindIndex(item => item.Equals(aI)); UpdateAnimationEvent(this, new AnimationEventArgs(false, AnimationType.AI, objIndex, 8, 0)); AIShips.Remove(aI); GameObjects.Remove(aI); } else if (aI.DepositOrbs(well)) { int objIndex = StableWells.FindIndex(item => item.Equals(well)); UpdateAnimationEvent(this, new AnimationEventArgs(false, AnimationType.Stable, objIndex, 12, 0)); StableWells.Remove(well); GameObjects.Remove(well); aI.GamePowerup.AddNew(); aI.SetTargetPos(); } else if (well.Orbs != originalColor) { int objIndex = StableWells.FindIndex(item => item.Equals(well)); UpdateAnimationEvent(this, new AnimationEventArgs(true, AnimationType.Stable, objIndex, well.Orbs, 6 + well.Orbs)); } } Orb orb = aI.OrbOver(); if (orb != null) { if (aI.Orbs.Count < 5) { Orbs.Remove(orb); GameObjects.Remove(orb); aI.Orbs.Add(orb.Color); aI.Orbs.Sort(); aI.SetTargetPos(); } } aI.UseNeutralize(); aI.UseDestabilize(); aI.UseGhost(); } }
// This method updates all the wells in the game. public void UpdateWells() { foreach (Well well in StableWells.ToList()) { well.TicksLeft--; if (well.TicksLeft == 0) { int objIndex = StableWells.FindIndex(item => item.Equals(well)); UpdateAnimationEvent(this, new AnimationEventArgs(false, AnimationType.Stable, objIndex, 12, 0)); well.TicksLeft = 3000; well.IsStable = false; well.Strength = 900; UnstableWells.Add(well); UpdateAnimationEvent(this, new AnimationEventArgs(false, AnimationType.Unstable, UnstableWells.Count, 0, 0)); StableWells.Remove(well); GameInvokeSoundEvent(this, SoundEffect.Destabilize); } } foreach (Well well in UnstableWells.ToList()) { well.TicksLeft--; if (well.TicksLeft % 100 == 0) { if (well.ShockWave.TicksLeft == 0) { well.ShockWave.TicksLeft = 80; } } if (well.ShockWave == null) { well.ShockWave = new Shockwave(this, well); } well.ShockWave.Pulse(); if (well.TicksLeft == 0) { int objIndex = UnstableWells.FindIndex(item => item.Equals(well)); UpdateAnimationEvent(this, new AnimationEventArgs(false, AnimationType.Unstable, objIndex, 24, 0)); GameInvokeSoundEvent(this, SoundEffect.Collapse); UnstableWells.Remove(well); GameObjects.Remove(well); } } }