Exemple #1
0
        ///// <summary>
        ///// Update checks for collisions and rotates the collectable gun on the spot using Animate(evt)
        ///// </summary>
        public override void Update(FrameEvent evt)
        {
            Animate(evt);

            if (IsCollidingWith("Player"))  //collision detection with the player

            {
                toRemove = true;

                (gun.GameNode.Parent).RemoveChild(gun.GameNode.Name); //detach the gun model from the current node

                playerArmoury.AddGun(gun);                            //add it to the player sub-scene-graph

                Physics.RemovePhysObj(PhysObj);
                Dispose();  //dispose of the pickup as it has been collected
            }
        }
        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);
        }
Exemple #3
0
        public override void Update(FrameEvent evt)
        {
            Animate(evt);
            //Here goes the collision detection with the player
            // (ignore until week 8) ...

            // Remove = true
            remove = IsCollidingWith("Player");
            if (remove == true)
            {
                (gun.GameNode.Parent).RemoveChild(gun.GameNode.Name);
                playerArmoury.AddGun(gun);
                gun.GameNode.Dispose();
                Dispose();
                // detach the gun model from current node and add it to player sub-scene-graph
                // Call Dispose before break
            }

            base.Update(evt);
        }