Esempio n. 1
0
        //Spawns an AIShip object in a random position
        public void SpawnAI()
        {
            double xc = Random.NextDouble() * 5000.0;
            double yc = Random.NextDouble() * 5000.0;

            if (!NearOtherObject(xc, yc))
            {
                AIShip aI = new AIShip(xc, yc, this);
                AIShips.Add(aI);
                GameObjects.Add(aI);
            }
        }
Esempio 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();
     }
 }
Esempio n. 3
0
        //Spawns an AIShip object in a random position
        public void SpawnAI()
        {
            double xc = Random.NextDouble() * 5000.0;
            double yc = Random.NextDouble() * 5000.0;

            if (!NearOtherObject(xc, yc))
            {
                AIShip aI = new AIShip(xc, yc, this);
                AIShips.Add(aI);
                GameObjects.Add(aI);
                UpdateAnimationEvent(this, new AnimationEventArgs(false, AnimationType.AI, AIShips.Count, 0, 0));
            }
        }
Esempio n. 4
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();
     }
 }