Exemplo n.º 1
0
        public Ship createShip(Ship.ShipType mShipType, GameObject.GameObjectName gameName, int index = 0, float mX = 0.0f, float mY = 0.0f)
        {
            Ship ship = null;

            switch (mShipType)
            {
            case Ship.ShipType.ShipRoot:
                ship = new ShipRoot(gameName, Sprite.SpriteName.NullObject, index, mX, mY);
                GameObjectNodeManager.add(ship, cPCSTree);
                break;

            case Ship.ShipType.CannonShip:
                ship = new CannonShip(gameName, Sprite.SpriteName.CannonShip, index, mX, mY);

                //   ship = cannonShip;
                break;

            case Ship.ShipType.Uninitilized:
                Debug.WriteLine("Missile Type is Uninitilized");
                break;
            }

            this.cPCSTree.Insert(ship, this.cParent);

            // cSpriteBatch.addToBatch(ship.getProxySprite());
            // cSpriteBatch.addToBatch(ship.getCollisionObj().cSpriteBox);
            ship.addSpriteToBatch(this.cSpriteBatch);
            ship.addCollisionToBatch(SpriteBatchManager.find(SpriteBatch.SpriteBatchName.Boxes));
            return(ship);
        }
        public override void notify()
        {
            Debug.WriteLine("BombShipCollideObserver");
            Bomb       bomb = (Bomb)this.colSubject.gameObjA;
            CannonShip ship = (CannonShip)this.colSubject.gameObjB;

            Debug.Assert(bomb != null);
            Debug.Assert(ship != null);

            //    bomb.reset();



            ship.setShipState(ShipManager.ShipStateType.End);

            ship.explode(Sprite.SpriteName.ShipExplosion);

            // ActivateBombSprite abs = new ActivateBombSprite(bomb);
            //  TimerManager.sortedAdd(TimerEvent.TimerEventName.ActivateBomb, abs, 0);
            ship.removeFromGameManager();
            ShipRemove objRemove = new ShipRemove(ship);

            TimerManager.sortedAdd(TimerEvent.TimerEventName.ShipRemove, objRemove, Unit.shipDeathAnimationTime);
            //reduce ship count
            PlayerManager.reduceShipCount();

            ActivateShip actiavteShip = new ActivateShip();

            TimerManager.sortedAdd(TimerEvent.TimerEventName.ShipRemove, actiavteShip, Unit.shipDeathAnimationTime + 0.1f);
        }
Exemplo n.º 3
0
 private ShipManager()
 {
     this.shipReadyState         = new ShipReadyState();
     this.shipMissileFlyingState = new ShipMissileFlyingState();
     this.shipEndState           = new ShipEndState();
     this.cannonShip             = null;
     this.missile = null;
 }
        public override void notify()
        {
            CannonShip ship = ShipManager.getShip();

            Debug.Assert(ship != null);

            ship.moveRight();
        }
Exemplo n.º 5
0
        public static void setShip(CannonShip ship)
        {
            ShipManager shipMan = ShipManager.getSingleton();

            Debug.Assert(shipMan != null);

            Debug.WriteLine(ship != null);
            shipMan.cannonShip = ship;
        }
Exemplo n.º 6
0
        public override void visitCannonShip(CannonShip s)
        {
            Debug.WriteLine("FlippingBomb CannonShip");
            Debug.WriteLine("Both tress finished to roots");

            CollisionPair currColPair = CollisionPairManager.getCurrentColPair();

            Debug.Assert(currColPair != null);
            currColPair.setSubject(this, s);
            currColPair.notifyObserver();
        }
Exemplo n.º 7
0
        public override void execute(float deltaTime)
        {
            int shipCount = PlayerManager.getShipCount();

            if (shipCount > 0)
            {
                ShipFactory shipFac = FactoryManager.getShipFactry();
                CannonShip  ship    = (CannonShip)shipFac.cPCSTree.GetRoot().pChild;
                //CannonShip ship = (CannonShip)GameObjectNodeManager.find(GameObject.GameObjectName.CannonShip);
                ship.x = Unit.shipPosX;
                ship.y = Unit.shipPosY;

                ShipManager.setShip(ship);
                ShipManager.getShip().setShipState(ShipManager.ShipStateType.Ready);
            }
        }
Exemplo n.º 8
0
        public override void shoot(CannonShip ship)
        {
            // Debug.WriteLine("ShipReadyState shoot");
            StraightMissile missile = ShipManager.activateMissile();

            Debug.Assert(missile != null);

            missile.x = ship.x;
            missile.y = ship.y;
            missile.launchMissile();

            IrrKlang.ISoundEngine sndEngine = FactoryManager.getSoundEngine();
            IrrKlang.ISound       music     = sndEngine.Play2D("shoot.wav");
            music.Volume = 0.2f;

            this.handle(ship);
        }
Exemplo n.º 9
0
        public void loadShip()
        {
            ShipFactory shipFactory = FactoryManager.getShipFactry();
            Ship        shipRoot    = shipFactory.createShip(Ship.ShipType.ShipRoot, GameObject.GameObjectName.ShipRoot, 0);

            shipFactory.setParent(shipRoot);

            CannonShip cannonShip = (CannonShip)shipFactory.createShip(Ship.ShipType.CannonShip, GameObject.GameObjectName.CannonShip, 1, 40, 30);

            ShipManager.setShip(cannonShip);

            cannonShip = (CannonShip)shipFactory.createShip(Ship.ShipType.CannonShip, GameObject.GameObjectName.CannonShip, 1, 110, 30);
            ShipManager.setShip(cannonShip);

            cannonShip = (CannonShip)shipFactory.createShip(Ship.ShipType.CannonShip, GameObject.GameObjectName.CannonShip, 1, Unit.shipPosX, Unit.shipPosY);
            ShipManager.setShip(cannonShip);
            ShipManager.getShip().setShipState(ShipManager.ShipStateType.Ready);
        }
Exemplo n.º 10
0
        // change the state of ship to ready now that its hit
        public override void notify()
        {
            CannonShip cannonShip = ShipManager.getShip();

            cannonShip.setShipState(ShipManager.ShipStateType.Ready);
        }
 public override void moveLeft(CannonShip ship)
 {
     // Debug.WriteLine("ShipState moveLeft");
     ship.x -= ship.delta;
 }
Exemplo n.º 12
0
 public override void handle(CannonShip ship)
 {
     ship.setShipState(ShipManager.ShipStateType.MissileFlying);
 }
Exemplo n.º 13
0
 public override void visitCannonShip(CannonShip s)
 {
     // Debug.WriteLine("WallRoot CannonShip");
     CollisionPair.detectCollision(s, (GameObject)this.pChild);
 }
Exemplo n.º 14
0
 public override void moveRight(CannonShip ship)
 {
     //  Debug.WriteLine("ShipReadyState moveRight");
     ship.x += ship.delta;
 }
Exemplo n.º 15
0
 public abstract void handle(CannonShip ship);
Exemplo n.º 16
0
        public override void load()
        {
            Unit.level1();
            AlienFactory alienFactory = FactoryManager.getAlienFactry();
            AlienGrid    alienGrid    = (AlienGrid)alienFactory.cPCSTree.getRoot();

            alienGrid.updateDelta();
            PCSTree     pcsTree      = FactoryManager.getAlienFactry().cPCSTree;
            SpriteBatch cSpriteBatch = alienFactory.cSpriteBatch;

            for (int i = 0; i < 6; i++)
            {
                FactoryManager.getAlienFactry().setParent(alienGrid);
                Alien pColumn = (Alien)GhostManager.find(GameObject.GameObjectName.Column);
                GhostManager.remove(pColumn);

                pColumn.set(Sprite.SpriteName.NullObject, i + 1, 0, 0);
                alienFactory.activate(pColumn);
                alienFactory.setParent(pColumn);

                float x = Unit.alienPosX;
                float y = Unit.alienPosY;

                Alien alien = (Alien)GhostManager.find(GameObject.GameObjectName.Crab);
                GhostManager.remove(alien);
                alien.set(Sprite.SpriteName.Crab, i + 2, x + i * 60.0f, y);
                alienFactory.activate(alien);

                Alien alien2 = (Alien)GhostManager.find(GameObject.GameObjectName.Squid);
                GhostManager.remove(alien2);
                alien2.set(Sprite.SpriteName.Squid, i + 2, x + i * 60.0f, y - 60);
                alienFactory.activate(alien2);

                Alien alien3 = (Alien)GhostManager.find(GameObject.GameObjectName.Squid);
                GhostManager.remove(alien3);
                alien3.set(Sprite.SpriteName.Squid, i + 2, x + i * 60.0f, y - 120);
                alienFactory.activate(alien3);

                Alien alien4 = (Alien)GhostManager.find(GameObject.GameObjectName.Octopus);
                GhostManager.remove(alien4);
                alien4.set(Sprite.SpriteName.Octopus, i + 2, x + i * 60.0f, y - 180);
                alienFactory.activate(alien4);

                Alien alien5 = (Alien)GhostManager.find(GameObject.GameObjectName.Octopus);
                GhostManager.remove(alien5);
                alien5.set(Sprite.SpriteName.Octopus, i + 6, x + i * 60.0f, y - 240);
                alienFactory.activate(alien5);
            }


            ShipFactory shipFactory = FactoryManager.getShipFactry();
            ShipRoot    shipGrid    = (ShipRoot)shipFactory.cPCSTree.getRoot();

            CannonShip Ship =
                Ship = (CannonShip)GhostManager.find(GameObject.GameObjectName.CannonShip);

            GhostManager.remove(Ship);
            shipFactory.activate(Ship);
            Ship.x = Unit.shipPosX;
            Ship.y = Unit.shipPosY;

            Ship = (CannonShip)GhostManager.find(GameObject.GameObjectName.CannonShip);
            GhostManager.remove(Ship);
            shipFactory.activate(Ship);
            Ship.x = 40;
            Ship.y = 30;

            Ship = (CannonShip)GhostManager.find(GameObject.GameObjectName.CannonShip);
            GhostManager.remove(Ship);
            shipFactory.activate(Ship);
            Ship.x = 110;
            Ship.y = 30;


            //42 brics
            //7 col
            //4 bricks
            ShieldFactory shieldFactory = FactoryManager.getShieldFactry();
            ShieldGrid    shieldGrid    = (ShieldGrid)shieldFactory.cPCSTree.getRoot();

            shieldFactory.setParent(shieldGrid);
            for (int x = 0; x < 8; x = x + 2)
            {
                shieldFactory.setParent(shieldGrid);
                Shield shieldUnit = shieldFactory.createShield(Shield.ShieldType.ShieldUnit, GameObject.GameObjectName.ShieldUnit);
                shieldFactory.setParent(shieldUnit);

                Shield pColumn;
                pColumn = shieldFactory.createShield(Shield.ShieldType.ShieldColumn, GameObject.GameObjectName.ShieldColumn, 0);
                shieldFactory.setParent(pColumn);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (60 + (x * 100)), 150);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (60 + (x * 100)), 140);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (60 + (x * 100)), 130);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (60 + (x * 100)), 120);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (60 + (x * 100)), 110);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (60 + (x * 100)), 100);

                shieldFactory.setParent(shieldUnit);
                pColumn = shieldFactory.createShield(Shield.ShieldType.ShieldColumn, GameObject.GameObjectName.Column, 0);
                shieldFactory.setParent(pColumn);

                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (70 + (x * 100)), 160);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (70 + (x * 100)), 150);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (70 + (x * 100)), 140);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (70 + (x * 100)), 130);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (70 + (x * 100)), 120);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (70 + (x * 100)), 110);

                shieldFactory.setParent(shieldUnit);
                pColumn = shieldFactory.createShield(Shield.ShieldType.ShieldColumn, GameObject.GameObjectName.Column, 0);
                shieldFactory.setParent(pColumn);

                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (80 + (x * 100)), 170);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (80 + (x * 100)), 160);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (80 + (x * 100)), 150);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (80 + (x * 100)), 140);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (80 + (x * 100)), 130);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (80 + (x * 100)), 120);


                shieldFactory.setParent(shieldUnit);
                pColumn = shieldFactory.createShield(Shield.ShieldType.ShieldColumn, GameObject.GameObjectName.Column, 0);
                shieldFactory.setParent(pColumn);

                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (90 + (x * 100)), 170);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (90 + (x * 100)), 160);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (90 + (x * 100)), 150);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (90 + (x * 100)), 140);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (90 + (x * 100)), 130);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (90 + (x * 100)), 120);

                shieldFactory.setParent(shieldUnit);
                pColumn = shieldFactory.createShield(Shield.ShieldType.ShieldColumn, GameObject.GameObjectName.Column, 0);
                shieldFactory.setParent(pColumn);

                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (100 + (x * 100)), 170);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (100 + (x * 100)), 160);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (100 + (x * 100)), 150);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (100 + (x * 100)), 140);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (100 + (x * 100)), 130);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (100 + (x * 100)), 120);

                shieldFactory.setParent(shieldUnit);
                pColumn = shieldFactory.createShield(Shield.ShieldType.ShieldColumn, GameObject.GameObjectName.Column, 0);
                shieldFactory.setParent(pColumn);

                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (110 + (x * 100)), 160);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (110 + (x * 100)), 150);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (110 + (x * 100)), 140);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (110 + (x * 100)), 130);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (110 + (x * 100)), 120);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (110 + (x * 100)), 110);

                shieldFactory.setParent(shieldUnit);
                pColumn = shieldFactory.createShield(Shield.ShieldType.ShieldColumn, GameObject.GameObjectName.ShieldColumn, 0);
                shieldFactory.setParent(pColumn);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (120 + (x * 100)), 150);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (120 + (x * 100)), 140);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (120 + (x * 100)), 130);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (120 + (x * 100)), 120);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (120 + (x * 100)), 110);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (120 + (x * 100)), 100);
            }
        }
Exemplo n.º 17
0
 public abstract void moveRight(CannonShip ship);
 public override void handle(CannonShip ship)
 {
     //  Debug.WriteLine("ShipState handle");
 }
 public override void shoot(CannonShip ship)
 {
     //Debug.WriteLine("ShipState shoot");
 }
Exemplo n.º 20
0
 public abstract void shoot(CannonShip ship);
Exemplo n.º 21
0
 public abstract void moveLeft(CannonShip ship);
 public virtual void visitCannonShip(CannonShip s)
 {
 }