private void Alien_Collision() { #region Alien Lasers with Bunkers // Alien lasers with bunkers for (int i = 0; i < Bunker_List.Count; i++) { for (int ii = 0; ii < Bunker_List[i].Bunker_Column.Count; ii++) for (int jj = 0; jj < Bunker_List[i].Bunker_Column[ii].Count; jj++) for (int j = 0; j < Alien_Laser_List.Count; j++) { if (Bunker_List[i].Bunker_Column[ii][jj].Check_Collision(Alien_Laser_List[j].myBoundingSphere)) { //Animation_List.Add(new Animation_2D(new Vector2(Bunker_List[i].Bunker_Column[ii][jj].Position.X, // Bunker_List[i].Bunker_Column[ii][jj].Position.Y), // 4, // 4, // Texture_List[0])); Bunker_List[i].Bunker_Column[ii].RemoveAt(jj); Alien_Laser_List.RemoveAt(j); return; } } } #endregion #region Alien Lasers with Cannon for (int i = 0; i < players; i++) { if (Player_List[i].Lives > 0) for (int j = 0; j < Alien_Laser_List.Count; j++) { if (Alien_Laser_List[j].myBoundingSphere.Intersects(Player_List[i].myBoundingSphere)) { SoundEffect_List[2].Play(); Player_List[i].Lives--; Alien_Laser_List.RemoveAt(j); for (int _value = 0; _value < Player_List.Count; _value++) { if (Player_List[_value].Lives > 0) { myLevel_State = Level_State.Continue; return; } } return; } } } #endregion #region Alien with Player Cannon if (Bunker_List.Count == 0) // No need to check if the aliens havent made it past the bunkers for (int i = 0; i < Alien_Column.Count; i++) for (int j = 0; j < Alien_Column[i].Count; j++) { for (int k = 0; k < Player_List.Count; k++) if (Alien_Column[i][j].myBoundingSphere.Intersects(Player_List[k].myBoundingSphere)) { myLevel_State = Level_State.Failed; return; } } #endregion }
private void Update_Alien_Position() { float yValue = 0; // Inverty speed and change vertical speed if needed // NOTE: SHOULD BE ABLE TO ONLY CHECK THE FIRST ALIEN OF EACH COLUMN //Update_Alien_Speed(); if (alien_Speed < 0) alien_Speed = -(((float)level + (float)aliens_Killed) / interval); else if (alien_Speed > 0) alien_Speed = (((float)level + (float)aliens_Killed) / interval); if (Alien_Column.Count > 0) if (Alien_Column[Alien_Column.Count - 1][0].Position.X > (float)Game_Boundries.RightHandSide) { alien_Speed = -(Math.Abs(((float)level + (float)aliens_Killed) / interval)); yValue = -0.5f; } else if (Alien_Column[0][0].Position.X < (float)Game_Boundries.LeftHandSide) { alien_Speed = Math.Abs(((float)level + (float)aliens_Killed) / interval); yValue = -0.5f; } for (int i = 0; i < Mystery_Ship_List.Count; i++) { Mystery_Ship_List[i].update_Positon(Mystery_Ship_List[i].Velocity); } for (int i = 0; i < Alien_Column.Count; i++) { for (int j = 0; j < Alien_Column[i].Count; j++) { if (Alien_Column[i][j].Position.Y < (int)Game_Boundries.Bottom + 15) { myLevel_State = Level_State.Failed; return; } Alien_Column[i][j].update_Positon(new Vector3(alien_Speed, yValue, 0)); } } }
//game update functions public int Update_Level(GameTime gameTime) { Update_Timers(gameTime); Alien_Collision(); Player_Collision(); Update_Laser_Position(); Update_Alien_Position(); Update_Alien_Shooting(); Reset_Flags(); if (myLevel_State == Level_State.Failed) return (int)myLevel_State; for (int _value = 0; _value < Player_List.Count; _value++) { myLevel_State = Level_State.Failed; if (Player_List[_value].Lives > 0) { myLevel_State = Level_State.Continue; break; //return (int)myLevel_State; } } if (aliens_Killed == 55) { myLevel_State = Level_State.Complete; //return (int)myLevel_State; } /* int values * 0 = continue * 1 = failed * 2 = complete - create next level with all points and crap */ return (int)myLevel_State; }