Exemple #1
0
        /// <summary>
        ///		Add the given root as the root of collision checking on behalf of all aliens
        /// </summary>
        /// <param name="newRoot"></param>
        private void AddAlienRootToCollisionSystem(AlienCoordinator newRoot)
        {
            CollisionPairEvaluator collisonPair = null;

            // Alien collisions =================

            // Wall Vs Alien
            collisonPair = CollisonPairManager.Active.Find(CollisionPairEvaluator.Name.Wall_vs_Alien);
            collisonPair.SetSecondCollisonRoot(newRoot);

            // PlayerLaser vs Alien
            collisonPair = CollisonPairManager.Active.Find(CollisionPairEvaluator.Name.PlayerLaser_vs_Alien);
            collisonPair.SetSecondCollisonRoot(newRoot);

            // Player vs Alien
            collisonPair = CollisonPairManager.Active.Find(CollisionPairEvaluator.Name.Player_vs_Alien);
            collisonPair.SetSecondCollisonRoot(newRoot);

            // Alien vs Shield
            collisonPair = CollisonPairManager.Active.Find(CollisionPairEvaluator.Name.Alien_vs_Shield);
            collisonPair.SetFirstCollisonRoot(newRoot);


            // AlienLaser collisions ==============

            GameObject alienLaserRoot = newRoot.AlienLaserRoot;

            // PlayerLaser vs AlienLaser
            collisonPair = CollisonPairManager.Active.Find(CollisionPairEvaluator.Name.PlayerLaser_vs_AlienLaser);
            collisonPair.SetSecondCollisonRoot(alienLaserRoot);

            // Player vs AlienLaser
            collisonPair = CollisonPairManager.Active.Find(CollisionPairEvaluator.Name.Player_vs_AlienLaser);
            collisonPair.SetSecondCollisonRoot(alienLaserRoot);

            // AlienLaser vs Shields
            collisonPair = CollisonPairManager.Active.Find(CollisionPairEvaluator.Name.AlienLaser_vs_Shield);
            collisonPair.SetFirstCollisonRoot(alienLaserRoot);

            // AlienLaser vs WallBottom
            collisonPair = CollisonPairManager.Active.Find(CollisionPairEvaluator.Name.AlienLaser_vs_WallBottom);
            collisonPair.SetFirstCollisonRoot(alienLaserRoot);
        }
Exemple #2
0
        /// <summary>
        ///		Setup the collision pairs for the player
        /// </summary>
        private void SetupCollisionHierarchy()
        {
            CollisionPairEvaluator collisionPair = null;

            // Create the collision root for player laser
            EmptyObject playerLaserRoot = new EmptyObject();

            playerLaserRoot.SetPosition(-10f, -10f);                    // Throw to a bottom corner
            GameObjectManager.Active.Attach(playerLaserRoot);

            // Set the root of this collision
            this.sceneRef.SetPlayerLaserRoot(playerLaserRoot);


            // Find all collision pairs the laser is a part of
            collisionPair = CollisonPairManager.Active.Find(CollisionPairEvaluator.Name.PlayerLaser_vs_WallTop);
            collisionPair.SetFirstCollisonRoot(playerLaserRoot);
            collisionPair = CollisonPairManager.Active.Find(CollisionPairEvaluator.Name.PlayerLaser_vs_Alien);
            collisionPair.SetFirstCollisonRoot(playerLaserRoot);
            collisionPair = CollisonPairManager.Active.Find(CollisionPairEvaluator.Name.PlayerLaser_vs_Shield);
            collisionPair.SetFirstCollisonRoot(playerLaserRoot);
            collisionPair = CollisonPairManager.Active.Find(CollisionPairEvaluator.Name.PlayerLaser_vs_UFO);
            collisionPair.SetFirstCollisonRoot(playerLaserRoot);
            collisionPair = CollisonPairManager.Active.Find(CollisionPairEvaluator.Name.PlayerLaser_vs_AlienLaser);
            collisionPair.SetFirstCollisonRoot(playerLaserRoot);



            //////////////////////////////////////////////



            // Create the collision root for the player
            EmptyObject playerRoot = new EmptyObject();

            playerRoot.SetPosition(this.InitX, this.InitY);
            GameObjectManager.Active.Attach(playerRoot);

            // Set the root of this collision
            this.sceneRef.SetPlayerRoot(playerRoot);



            // Find all the collision pairs the player is a part of

            // Wall vs Player
            collisionPair = CollisonPairManager.Active.Find(CollisionPairEvaluator.Name.Wall_vs_Player);
            collisionPair.SetSecondCollisonRoot(playerRoot);

            // Player vs Alien
            collisionPair = CollisonPairManager.Active.Find(CollisionPairEvaluator.Name.Player_vs_Alien);
            collisionPair.SetFirstCollisonRoot(playerRoot);

            // Player vs AlienLaser
            collisionPair = CollisonPairManager.Active.Find(CollisionPairEvaluator.Name.Player_vs_AlienLaser);
            collisionPair.SetFirstCollisonRoot(playerRoot);


            // Don't need the reference anymore
            this.sceneRef = null;
        }