Exemplo n.º 1
0
        //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;
            }
        }
Exemplo n.º 2
0
 //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();
     }
 }
Exemplo n.º 3
0
 //updates gravity effects on parameter ship
 public void UpdateGravity(Ship ship)
 {
     foreach (Well well in StableWells.Concat(UnstableWells))
     {
         double deltaX = well.Xcoor - ship.Xcoor;
         double deltaY = well.Ycoor - ship.Ycoor;
         double dist   = Math.Max(0.01, Math.Pow(deltaX * deltaX + deltaY * deltaY, 0.5));
         double force  = well.Strength / Math.Max(200, Math.Pow(dist, 1.5));
         ship.SpeedX += deltaX / dist * force;
         ship.SpeedY += deltaY / dist * force;
     }
 }
Exemplo n.º 4
0
        //This method usually spawns a well. It sometimes not spawning a well has 2 reasons:
        //#1: To add a little bit of randomness to the game.
        //#2: So the game screen doesn't get too cluttered. (If it doesn't find an empty space, it doesn't spawn)
        public void SpawnWell()
        {
            double xc = Random.NextDouble() * 5000.0;
            double yc = Random.NextDouble() * 5000.0;

            if (!NearOtherObject(xc, yc))
            {
                Well well = new Well(xc, yc);
                well.TicksLeft = WellDestabFreq + Random.Next(1001);
                StableWells.Add(well);
                GameObjects.Add(well);
            }
        }
Exemplo n.º 5
0
        //This method usually spawns a well. It sometimes not spawning a well has 2 reasons:
        //#1: To add a little bit of randomness to the game.
        //#2: So the game screen doesn't get too cluttered. (If it doesn't find an empty space, it doesn't spawn)
        public void SpawnWell()
        {
            double xc = Random.NextDouble() * 5000.0;
            double yc = Random.NextDouble() * 5000.0;

            if (!NearOtherObject(xc, yc))
            {
                Well well = new Well(xc, yc);
                well.TicksLeft = WellDestabFreq + Random.Next(1001);
                StableWells.Add(well);
                GameObjects.Add(well);
                UpdateAnimationEvent(this, new AnimationEventArgs(false, AnimationType.Stable, StableWells.Count, 0, 0));
                well.ShockWave = new Shockwave(this, well);
            }
        }
Exemplo n.º 6
0
        //This method updates the player's position and what orbs it has.
        public void UpdatePlayer(Ship Player)
        {
            UpdateGravity(Player);
            Player.Move();
            Well well = Player.WellOver();

            if (well != null)
            {
                int originalColor = well.Orbs;
                if (!well.IsStable)
                {
                    if (!Player.IsImmune)
                    {
                        Player.Die();
                    }
                }
                else if (Player.DepositOrbs(well))
                {
                    StableWells.Remove(well);
                    GameObjects.Remove(well);
                    Player.GamePowerup.AddNew();
                    Player.Points += 100;
                }
            }
            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();
                }
            }
            if (Player.ImmuneTicksLeft > 0)
            {
                --Player.ImmuneTicksLeft;
            }
            if (Player.ImmuneTicksLeft == 0)
            {
                Player.IsImmune = false;
            }
        }
Exemplo n.º 7
0
 // 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);
         }
     }
 }
Exemplo n.º 8
0
 //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)
         {
             if (!well.IsStable)
             {
                 if (well.IsTrap)
                 {
                     well.PlayerWhoSetTrap.Points += 200;
                 }
                 AIShips.Remove(aI);
                 GameObjects.Remove(aI);
             }
             else if (aI.DepositOrbs(well) && !well.IsGhost)
             {
                 StableWells.Remove(well);
                 GameObjects.Remove(well);
                 aI.GamePowerup.AddNew();
                 aI.SetTargetPos();
             }
         }
         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();
     }
 }
Exemplo n.º 9
0
 // This method updates all the wells in the game.
 public void UpdateWells()
 {
     foreach (Well well in StableWells.ToList())
     {
         well.TicksLeft--;
         if (well.TicksLeft == 0)
         {
             well.TicksLeft = 3000;
             well.IsStable  = false;
             well.Strength  = 900;
             UnstableWells.Add(well);
             StableWells.Remove(well);
         }
     }
     foreach (Well well in UnstableWells.ToList())
     {
         if (well.TicksLeft == 0)
         {
             // any explosions or something????
             UnstableWells.Remove(well);
             GameObjects.Remove(well);
         }
     }
 }