コード例 #1
0
        public void AddGun(Gun gun)
        {
            //set a local bool variable named add to true
            bool add = true;

            //   ChangeGun(gun);
            //and then for each gun g in the collectedGuns list check whether add is true and whether the type of gun you are passing
            //is in the collected gun list (g.GetType()==gun.GetType()),
            for (int g = 0; g < collectedGuns.Count; g++) // Loop through List with for
            {
                if (g.GetType() == gun.GetType() && add)
                {
                    //if they are both true then it calls the reloadAmmo mehtod for g,
                    //call the ChangeGun method passing g to it and then set add to false.
                    collectedGuns[g].ReloadAmmo();
                    ChangeGun(collectedGuns[g]);
                    add = false;
                }
            }
            //Once the for each loop finished check the add variable, if true then call CangeGun method and pass gun to
            //it else call the Dispose method from gun.
            if (add)
            {
                ChangeGun(gun);
            }
            else
            {
                gun.Dispose();
            }
        }
コード例 #2
0
        public void AddGun(Gun gun)
        {
            bool add = true;

            foreach (Gun g in collectedGuns)
            {
                // Check if add is true? and whether the type of gun you are passing is in collected gun list
                //(g.GetType() == gun.GetType());
                //if they are both true then it calls reloadAmmo method for g
                // Call the changegun method passing g to it and then set add to false
                if (add == true && (g.GetType() == gun.GetType()))
                {
                    g.ReloadAmmo();
                    ChangeGun(g);
                    add = false;
                }
            }

            if (add == true)
            {
                ChangeGun(gun);
                collectedGuns.Add(gun);
            }
            else
            {
                gun.Dispose();
            }

            // once foreach loop finished, check the add variable, if true then Call ChangeGun method, pass gun to it
            // and add the gun to the collectedGun list, else call the Dispose method from gun
        }
コード例 #3
0
 /// <summary>
 /// Disposes of all gun objects in armoury
 /// </summary>
 public void Dispose()
 {
     foreach (Gun gun in collectedGuns)
     {
         gun.Dispose();
     }
     if (activeGun != null)
     {
         activeGun.Dispose();
     }
 }
コード例 #4
0
ファイル: Armoury.cs プロジェクト: Jcweeden/Mogre-Game
        /// <summary>
        // Disposes of the physObj and gamenode for each gun in the armoury
        /// </summary>
        public void Dispose()
        {
            foreach (Gun g in collectedGuns)    //dispose of each gun in the collectedGuns list
            {
                g.Dispose();
            }

            if (activeGun != null)  //and if the activeGun is not null disposes of it
            {
                activeGun.Dispose();
            }
        }
コード例 #5
0
        // Dispose of each gun in the collectedGuns list
        // and if the activeGun is not null dispose of it as well
        public void Dispose()
        {
            // Go thourgh all the guns which have been collected and delete them.
            foreach (Gun gun in collectedGuns)
            {
                gun.Dispose();
            }

            if (activeGun != null)
            {
                activeGun.Dispose();
            }
        }
コード例 #6
0
 //Implement a public void Dispose method which dispose of each gun in the collectedGuns list and if the activeGun is not null disposes of it as well.
 public void Dispose()
 {
     for (int i = 0; i < collectedGuns.Count; i++) // Loop through List with for
     {
         collectedGuns[i].Dispose();
         if (collectedGuns[i] == activeGun)
         {
             if (activeGun != null)
             {
                 activeGun.Dispose();
             }
         }
     }
 }
コード例 #7
0
        protected bool isCollidingWith(string objName)
        {
            bool isColliding = false;

            foreach (Contacts c in physObj.CollisionList)
            {
                if (c.colliderObj.ID == objName || c.collidingObj.ID == objName)
                {
                    isColliding = true;
                    (gun.modelNode.Parent).RemoveChild(gun.modelNode.Name);

                    playerArmoury.AddGun(gun);
                    //                 Dispose();
                    gun.Dispose();
                    break;
                }
            }
            return(isColliding);
        }
コード例 #8
0
ファイル: Armoury.cs プロジェクト: Jcweeden/Mogre-Game
        //Finally implement a public void AddGun method which takes a Gun object named gun as parameter
        /// <summary>
        // Adds the gun to the armoury, and equips it
        /// </summary>
        public void AddGun(Gun gun)
        {
            bool add = true;    //set a local bool variable named add to true

            foreach (Gun g in collectedGuns)
            {   //for each gun g in the collectedGuns list check add is true and the type of gun passing is in the collected gun list (g.GetType()==gun.GetType())
                if (add == true && g.GetType() == gun.GetType())
                {
                    g.ReloadAmmo(); //if they are both true then it calls the reloadAmmo method for g
                    ChangeGun(g);   //call the ChangeGun method passing g to it
                    add = false;    //set add to false.
                }
            }
            if (add == true)            //Once the for each loop finished check the add variable
            {
                ChangeGun(gun);         //if true then call ChangeGun method, pass gun to it
                collectedGuns.Add(gun); //and add the gun to the collectedGun list
            }
            else
            {
                gun.Dispose();      //else call the Dispose method from gun
            }
        }
コード例 #9
0
        /// <summary>
        /// This method adds a new gun to the armoury collection
        /// </summary>
        /// <param name="gun"></param>
        public void AddGun(Gun gun)
        {
            bool add = new bool();

            add = true;
            foreach (Gun g in collectedGuns)
            {
                if (add && g.GetType() == gun.GetType())
                {
                    g.ReloadAmmo();
                    ChangeGun(g);
                    add = false;
                }
            }
            if (add)
            {
                ChangeGun(gun);
                collectedGuns.Add(gun);
            }
            else
            {
                gun.Dispose();
            }
        }