Example #1
0
 private void AddRacket(GameObject obj)
 {
     // remove the previous racket from this.allObjects and this.staticObjects
     RemoveRacket();
     this.playerRacket = obj as Racket;
     this.AddStaticObject(obj);
 }
Example #2
0
 private void AddRacket(GameObject obj)
 {
     //TODO: we should remove the previous racket from this.allObjects
     //the solution is above, in AddObject()
     this.playerRacket = obj as Racket;
     this.AddStaticObject(obj);
 }
Example #3
0
 /* Search for a "TODO" in the Engine class, regarding the AddRacket method. Solve the problem mentioned there.
  * There should always be only one Racket. Note: comment in TODO not completely correct*/
 private void AddRacket(GameObject obj)
 {
     //TODO: we should remove the previous racket from this.allObjects
     RemovePreviousRacket();
     this.playerRacket = obj as Racket;
     this.AddStaticObject(obj);
 }
Example #4
0
        private void AddRacket(GameObject obj)
        {
            this.allObjects.RemoveAll(item => item is Racket); // [Task 3]
            this.staticObjects.RemoveAll(item => item is Racket); // [Task 3]

            this.playerRacket = obj as Racket;
            this.AddStaticObject(obj);
        }
Example #5
0
 private void AddRacket(GameObject obj)
 {
     //all previous Rackets removed
     this.allObjects.RemoveAll(x => x is Racket);
     this.staticObjects.RemoveAll(x => x is Racket);
     this.playerRacket = obj as Racket;
     this.AddStaticObject(obj);
 }
 private void AddRacket(GameObject obj)
 {
     //TODO: we should remove the previous racket from this.allObjects
     this.playerRacket = obj as Racket;
     this.allObjects.RemoveAll(ob => ob is Racket);
     this.staticObjects.RemoveAll(ob => ob is Racket);
     this.AddStaticObject(obj);
 }
Example #7
0
 public override void AddObject(GameObject obj)
 {
     var as_racket = obj as ShootingRacket;
     if (as_racket != null) {
         racket = as_racket;
     }
     base.AddObject(obj);
 }
Example #8
0
 public void AddTrailingObject(GameObject obj)
 {
     if (obj is TrailObject)
     {
         allObjects.Add(obj as TrailObject);
         staticObjects.Add(obj as TrailObject);
     }
 }
 //overriding of this method is important for task 13 in order to get access to the fields of the current racket
 public override void AddObject(GameObject obj)
 {
     if (obj is ShootingRacket)
     {
         ShootingRacket newRacket = obj as ShootingRacket;
         this.playerRacket = newRacket;
     }
     base.AddObject(obj);
 }
Example #10
0
        private void AddRacket(GameObject obj)
        {
            //TODO: we should remove the previous racket from this.allObjects
            // 3. Removing the rackets from allObjects and staticObjects

            this.playerRacket = obj as Racket;
            this.allObjects.RemoveAll(item => item is Racket); // this line should be as comment if we use multiple rackets
            this.staticObjects.RemoveAll(item => item is Racket);
            this.AddStaticObject(obj);
        }
Example #11
0
        private void AddRacket(GameObject obj)
        {
            //TODO: we should remove the previous racket from this.allObjects
            //Task 3: Implementing Removing of all elements of Type Racket from allObjects
            var toRemove = this.allObjects.OfType<Racket>().ToList();
            foreach (var item in toRemove)
                this.allObjects.Remove(item);

            this.playerRacket = obj as Racket;
            this.AddStaticObject(obj);
        }
Example #12
0
        private void AddRacket(GameObject obj)
        {
            //TODO: we should remove the previous racket from this.allObjects

            // 03. Removing the old Racket using Lambda
            // We can also search the whole list of objects and remove the object that is Racket
            this.allObjects.RemoveAll(item => item is Racket);
            this.staticObjects.RemoveAll(item => item is Racket);

            this.playerRacket = obj as Racket;
            this.AddStaticObject(obj);
        }
 private void AddRacket(GameObject obj)
 {
     for(int i = 0; i < allObjects.Count; i++) {
       if(allObjects[i] is Racket) {
         allObjects.RemoveAt(i);
         break;
       }
     }
     //TODO: we should remove the previous racket from this.allObjects
     this.playerRacket = obj as Racket;
     this.AddStaticObject(obj);
 }
Example #14
0
 // Add some object in depending his type
 public virtual void AddObject(GameObject obj)
 {
     if (obj is MovingObject)
     {
         this.AddMovingObject(obj as MovingObject);
     }
     else
     {
         if (obj is Racket) AddRacket(obj);
         else this.AddStaticObject(obj);
     }
 }
        private void AddRacket(GameObject obj)
        {
            //TODO: we should remove the previous racket from this.allObjects
           /* 03. Search for a "TODO" in the Engine class, regarding the AddRacket method. 
            * Solve the problem mentioned there. There should always be only one Racket. 
            * Note: comment in TODO not completely correct
            */

            this.playerRacket = obj as Racket;
            this.allObjects.RemoveAll(x => x is Racket); // should be always one racket
            this.AddStaticObject(obj);
        }
Example #16
0
 // Task 3 - I have decided that, since it was mentioned that the comment in the code was not completely correct and
 // that the only condition is to have one racket, to keep the original racket. The method checks whether we have
 // a Racket object in the list of all objects and then, if not, to add the racket.5
 protected virtual void AddRacket(GameObject obj)
 {
     bool check=true;
     foreach (var c in this.allObjects)
     {
         if (c is Racket)
             check = false;
     }
     if (check)
     {
         this.playerRacket = obj as Racket;
         this.AddStaticObject(obj);
     }
 }
 private void AddRacket(GameObject obj)
 {
     //3.Search for TODO and remove racket. There should always be only one racket.
     //TODO: we should remove the previous racket from this.allObjects
     this.playerRacket = obj as Racket;
     for (int i = 0; i < allObjects.Count; i++)
     {
         if (allObjects[i] is Racket)
         {
             allObjects.RemoveAt(i);
             break;
         }
     }
     this.AddStaticObject(obj);
     
 }
Example #18
0
 public virtual void AddObject(GameObject obj)
 {
     if (obj is MovingObject)
     {
         this.AddMovingObject(obj as MovingObject);
     }
     else
     {
         if (obj is Racket)
         {
             // TASK 3
             this.allObjects.RemoveAll(gameObject => gameObject is Racket);
             AddRacket(obj);
         }
         else
         {
             this.AddStaticObject(obj);
         }
     }
 }
Example #19
0
 public virtual void AddObject(GameObject obj)
 {
     if (obj is MovingObject)
     {
         this.AddMovingObject(obj as MovingObject);
     }
     else
     {
         if (obj is Racket)
         {
             //03.Search for a "TODO" in the Engine class, regarding the AddRacket method. Solve the problem mentioned there. 
             //There should always be only one Racket. Note: comment in TODO not completely correct
             this.allObjects.RemoveAll(allObj => allObj is Racket);
             //END 03
             AddRacket(obj);
         }
         else
         {
             this.AddStaticObject(obj);
         }
     }
 }
Example #20
0
 protected override void AddRacket(GameObject obj)
 {
     bool check = true, secondCheck=true;
     ShootingRacket l;
     foreach (var c in this.allObjects)
     {
         if ((c is Racket) && !(c is ShootingRacket))
             check = false;
         else if (c is ShootingRacket)
             secondCheck = false;
     }
     if (check)
     {
         this.playerRacket = obj as Racket;
         this.AddStaticObject(obj);
     }
     else if (!secondCheck)
     {
         this.playerRacket = obj as ShootingRacket;
         this.AddStaticObject(obj);
     }
 }
Example #21
0
        public virtual void AddObject(GameObject obj)
        {
            if (obj is MovingObject)
            {
                this.AddMovingObject(obj as MovingObject);

                if (obj is Ball)
                {
                    this.ball = obj as Ball;
                }
            }
            else
            {
                if (obj is Racket)
                {
                    AddRacket(obj);

                }
                else
                {
                    this.AddStaticObject(obj);
                }
            }
        }
Example #22
0
        private void AddRacket(GameObject obj)
        {
            //03. Search for a "TODO" in the Engine class, regarding the AddRacket method. Solve the problem mentioned
            //    there. There should always be only one Racket. Note: comment in TODO not completely correct
            // TODO: we should remove the previous racket from this.allObjects
            //================================================================================================== Task 03>
            // obj is added to staticObjects AND allObjects (AddStaticObject(obj)), which means it should be removed from both
            this.allObjects.RemoveAll(x => x is Racket);
            this.staticObjects.RemoveAll(x => x is Racket);
            //================================================================================================== >Task 03

            this.playerRacket = obj as Racket;
            this.AddStaticObject(obj);
        }
Example #23
0
 private void AddRacket(GameObject obj)
 {
     foreach (var item in allObjects)
     {
         if (item is Racket)
         {
             allObjects.Remove(item);
             break;
         }
     }
     foreach (var item in staticObjects)
     {
         if (item is Racket)
         {
             staticObjects.Remove(item);
             break;
         }
     }
     this.playerRacket = obj as Racket;
     this.AddStaticObject(obj);
 }
Example #24
0
 private void RemoveRacket(GameObject obj)
 {
     this.playerRacket = obj as Racket;
     this.allObjects.RemoveAll(racketObject => racketObject is Racket);
 }
Example #25
0
 private void AddRacket(GameObject obj)
 {
     this.RemoveRacket(playerRacket);
     this.playerRacket = obj as Racket;
     this.AddStaticObject(obj);
 }
Example #26
0
 private void AddRacket(GameObject obj)
 {
     //TODO: we should remove the previous racket from this.allObjects
     //Removing previous rackets form staticObjects and allObjects
     for (int index = 0; index < allObjects.Count; index++)
     {
         if (allObjects[index].GetType().Name == typeof(Racket).Name)
         {
             this.allObjects.RemoveAt(index);
             break;
         }
     }
     for (int index = 0; index < staticObjects.Count; index++)
     {
         if (staticObjects[index].GetType().Name == typeof(Racket).Name)
         {
             this.staticObjects.RemoveAt(index);
             break;
         }
     }
     this.playerRacket = obj as Racket;
     this.AddStaticObject(obj);
 }
Example #27
0
 private void AddRacket(GameObject obj)
 {
     this.playerRacket = obj as Racket;
     //Task 3
     //Find and the remove from all the object the previous racket
     this.allObjects.RemoveAll((pos) => pos is Racket);
     //End of Task 3
     this.AddStaticObject(obj);
 }
Example #28
0
 private void AddStaticObject(GameObject obj)
 {
     this.staticObjects.Add(obj);
     this.allObjects.Add(obj);
 }
Example #29
0
 private void AddRacket(GameObject obj)
 {
     this.playerRacket = obj as Racket;
     this.allObjects.RemoveAll(x => x is Racket);
     this.AddStaticObject(obj);
 }
Example #30
0
 private void AddRacket(GameObject obj)
 {
     //TODO: we should remove the previous racket from this.allObjects
     this.playerRacket = obj as Racket;
     staticObjects.Add(playerRacket);
 }