Exemplo n.º 1
0
        public static StraightMissile activateMissile()
        {
            ShipManager shipMan = ShipManager.getSingleton();

            Debug.Assert(shipMan != null);

            GameObjectNode gon     = GameObjectNodeManager.findGameObjectNode(GameObject.GameObjectName.MissileRoot);
            PCSTree        pcsTree = gon.getPCSTree();
            GameObject     gameObj = gon.getGameObject();

            Debug.Assert(pcsTree != null);
            Debug.Assert(gameObj != null);

            // StraightMissile missile = new StraightMissile(GameObject.GameObjectName.StraightMissile, Sprite.SpriteName.Straight, 1, 400, 100f,Missile.MissileType.Straight);

            ///to do
            StraightMissile missile = (StraightMissile)FactoryManager.getMissileFactry().createMissile(Missile.MissileType.StraightMissile, GameObject.GameObjectName.StraightMissile, 1, 300, 200);

            //StraightMissile missile = (StraightMissile)GhostManager.find(GameObject.GameObjectName.StraightMissile);
            //if(missile==null)
            //{
            //   missile = (StraightMissile)FactoryManager.getMissileFactry().createMissile(Missile.MissileType.StraightMissile, GameObject.GameObjectName.StraightMissile, 1, 300, 200);
            //}
            //StraightMissile missile = (StraightMissile)GhostManager.find(GameObject.GameObjectName.StraightMissile);

            shipMan.missile = missile;

            //  SpriteBatch missileBatch = SpriteBatchManager.find(SpriteBatch.SpriteBatchName.Missiles);
            //  SpriteBatch boxBatch = SpriteBatchManager.find(SpriteBatch.SpriteBatchName.Boxes);

            //  Debug.Assert(missileBatch != null);
            //  Debug.Assert(boxBatch != null);

            // missile.addSpriteToBatch(missileBatch);
            //  missile.addCollisionToBatch(boxBatch);
            GameObject pMissileRoot = GameObjectNodeManager.find(GameObject.GameObjectName.MissileRoot);

            Debug.Assert(pMissileRoot != null);
            ///////////////////////////Not sure
            // pcsTree.Insert(missile, pMissileRoot);
            // pcsTree.GetRoot.
            pMissileRoot.update();

            return(missile);
        }
Exemplo n.º 2
0
        public void activateCollisions()
        {
            IrrKlang.ISoundEngine sndEngine = FactoryManager.getSoundEngine();
            CollisionPair         Bomb_Ship = CollisionPairManager.add(CollisionPair.CollisionPairName.Bomb_Ship, GameObjectNodeManager.find(GameObject.GameObjectName.BombRoot), GameObjectNodeManager.find(GameObject.GameObjectName.ShipRoot));

            Bomb_Ship.attach(new GameEndObserver());
            Bomb_Ship.attach(new ShipDeathFreezeObserver(Unit.gameFreezeTime));
            Bomb_Ship.attach(new SoundObserver(sndEngine, "Explosion.wav"));
            Bomb_Ship.attach(new BombCollideObserver());
            Bomb_Ship.attach(new BombShipCollideObserver());

            CollisionPair Alien_Missile = CollisionPairManager.add(CollisionPair.CollisionPairName.Alien_Missile, GameObjectNodeManager.find(GameObject.GameObjectName.AlienGrid), GameObjectNodeManager.find(GameObject.GameObjectName.MissileRoot));

            Alien_Missile.attach(new AlienMissileObserver());
            Alien_Missile.attach(new SoundObserver(sndEngine, "invaderkilled.wav"));
            Alien_Missile.attach(new ShipReadyObserver());

            CollisionPair Alien_Wall = CollisionPairManager.add(CollisionPair.CollisionPairName.Alien_Wall, GameObjectNodeManager.find(GameObject.GameObjectName.AlienGrid), GameObjectNodeManager.find(GameObject.GameObjectName.WallRoot));

            Alien_Wall.attach(new AlienWallObserver());
            // Alien_Wall.attach(new SoundObserver(sndEngine, "Explosion.wav"));

            CollisionPair Alien_Shield = CollisionPairManager.add(CollisionPair.CollisionPairName.Alien_Shield, GameObjectNodeManager.find(GameObject.GameObjectName.AlienGrid), GameObjectNodeManager.find(GameObject.GameObjectName.ShieldGrid));

            Alien_Shield.attach(new ShieldHitObserver());


            CollisionPair Alien_Ship = CollisionPairManager.add(CollisionPair.CollisionPairName.Alien_Ship, GameObjectNodeManager.find(GameObject.GameObjectName.AlienGrid), GameObjectNodeManager.find(GameObject.GameObjectName.ShipRoot));

            Alien_Ship.attach(new SoundObserver(sndEngine, "invaderkilled.wav"));
            Alien_Ship.attach(new GameOverObserver());
            Alien_Ship.attach(new GameEndObserver());

            CollisionPair Missile_Wall = CollisionPairManager.add(CollisionPair.CollisionPairName.Missile_Wall, GameObjectNodeManager.find(GameObject.GameObjectName.MissileRoot), GameObjectNodeManager.find(GameObject.GameObjectName.WallRoot));

            Missile_Wall.attach(new ShipReadyObserver());
            //   Missile_Wall.attach(new SoundObserver(sndEngine, "invaderkilled.wav"));
            Missile_Wall.attach(new MissileRemoveObserver());

            CollisionPair Missile_Shield = CollisionPairManager.add(CollisionPair.CollisionPairName.Missile_Shield, GameObjectNodeManager.find(GameObject.GameObjectName.MissileRoot), GameObjectNodeManager.find(GameObject.GameObjectName.ShieldGrid));

            Missile_Shield.attach(new SoundObserver(sndEngine, "invaderkilled.wav"));
            Missile_Shield.attach(new ShieldHitObserver());
            Missile_Shield.attach(new ShieldMissileObserver());
            Missile_Shield.attach(new ShipReadyObserver());

            CollisionPair Ship_Wall = CollisionPairManager.add(CollisionPair.CollisionPairName.Ship_Wall, GameObjectNodeManager.find(GameObject.GameObjectName.ShipRoot), GameObjectNodeManager.find(GameObject.GameObjectName.WallRoot));

            //   Ship_Wall.attach(new SoundObserver(sndEngine, "invaderkilled.wav"));
            Ship_Wall.attach(new ShipWallObserver());

            CollisionPair Bomb_Wall = CollisionPairManager.add(CollisionPair.CollisionPairName.Bomb_Wall, GameObjectNodeManager.find(GameObject.GameObjectName.BombRoot), GameObjectNodeManager.find(GameObject.GameObjectName.WallRoot));

            //  Bomb_Wall.attach(new SoundObserver(sndEngine, "invaderkilled.wav"));
            Bomb_Wall.attach(new BombCollideObserver());

            CollisionPair Bomb_Missile = CollisionPairManager.add(CollisionPair.CollisionPairName.Bomb_Missile, GameObjectNodeManager.find(GameObject.GameObjectName.BombRoot), GameObjectNodeManager.find(GameObject.GameObjectName.MissileRoot));

            Bomb_Missile.attach(new BombCollideObserver());
            //  Bomb_Missile.attach(new SoundObserver(sndEngine, "invaderkilled.wav"));
            Bomb_Missile.attach(new ShipReadyObserver());
            Bomb_Missile.attach(new MissileRemoveObserver());

            CollisionPair Bomb_Shield = CollisionPairManager.add(CollisionPair.CollisionPairName.Bomb_Shield, GameObjectNodeManager.find(GameObject.GameObjectName.BombRoot), GameObjectNodeManager.find(GameObject.GameObjectName.ShieldGrid));

            Bomb_Shield.attach(new BombCollideObserver());
            //   Bomb_Shield.attach(new SoundObserver(sndEngine, "invaderkilled.wav"));
            Bomb_Shield.attach(new ShieldHitObserver());

            CollisionPair Misisle_UFO = CollisionPairManager.add(CollisionPair.CollisionPairName.Misisle_UFO, GameObjectNodeManager.find(GameObject.GameObjectName.MissileRoot), GameObjectNodeManager.find(GameObject.GameObjectName.UFORoot));

            Misisle_UFO.attach(new UFOMissileObserver());
            Misisle_UFO.attach(new ShipReadyObserver());
            Misisle_UFO.attach(new SoundObserver(sndEngine, "ufo_highpitch.wav"));
            // Misisle_UFO.attach(new UFOLaunchObserver());

            CollisionPair UFO_Wall = CollisionPairManager.add(CollisionPair.CollisionPairName.UFO_Wall, GameObjectNodeManager.find(GameObject.GameObjectName.UFORoot), GameObjectNodeManager.find(GameObject.GameObjectName.WallRoot));

            UFO_Wall.attach(new UFOLaunchObserver());
        }