예제 #1
0
        public override void Resume(Game pGame)
        {
            Ship pShip = ShipManager.GetShip();

            pShip.SetState(ShipStateEnum.Ready);
            this.Handle(pGame, GameStateEnum.Active);
        }
        public override void ShootMissile(Ship pShip)
        {
            ShipManager.LaunchMissile();


            pShip.SetState(ShipManager.State.StopLeftMissileFlying);
        }
        public override void Notify()
        {
            WallCategory pWall = (WallCategory)this.pSubject.pObjB;
            //Debug.WriteLine("Ship hits " + pWall.name);

            Ship pShip = ShipMan.GetShip();

            if (pWall.name == GameObject.Name.WallRight)
            {
                pShip.SetState(ShipMan.State.NotMovingRight);
            }
            else if (pWall.name == GameObject.Name.WallLeft)
            {
                pShip.SetState(ShipMan.State.NotMovingLeft);
            }
        }
        //command pattern for delayed manager
        public override void Execute()
        {
            // Let the gameObject deal with this...
            this.pShip.pProxySprite.Set(GameSprite.Name.ShipExplosion);
            Ship pShipCopy = (Ship)this.pShip;

            pShipCopy.SetState(ShipManager.State.Dead);

            SwapShipExplosionEvent pSwapEvent  = new SwapShipExplosionEvent(Image.Name.ShipExplosionA); //move to ship manager?
            SwapShipExplosionEvent pSwapEvent2 = new SwapShipExplosionEvent(Image.Name.ShipExplosionB); //move to ship manager?


            TimerManager.Add(TimeEvent.Name.SwapShipExplosion, pSwapEvent2, 0.2f);
            TimerManager.Add(TimeEvent.Name.SwapShipExplosion, pSwapEvent, 0.4f);
            TimerManager.Add(TimeEvent.Name.SwapShipExplosion, pSwapEvent2, 0.6f);
            TimerManager.Add(TimeEvent.Name.SwapShipExplosion, pSwapEvent, 0.8f);
            TimerManager.Add(TimeEvent.Name.SwapShipExplosion, pSwapEvent2, 1.0f);
            TimerManager.Add(TimeEvent.Name.SwapShipExplosion, pSwapEvent, 1.2f);



            ResetShipEvent pEvent = new ResetShipEvent();//move to ship manager?

            TimerManager.Add(TimeEvent.Name.RemoveShip, pEvent, 1.4f);
        }
        public override void ShootMissile(Ship pShip)
        {
            ShipManager.LaunchMissile();

            // switch states
            //this.Handle(pShip);
            pShip.SetState(ShipManager.State.StopRightMissileFlying);
        }
        public override void Notify()
        {
            Ship pShip = ShipManager.GetShip();

            // Correction... only method that changes state is Handle
            // So correct this....

            if (pShip.CurrentStateName == ShipManager.State.Ready)
            {
                pShip.SetState(ShipManager.State.StopRight);
            }
            else if (pShip.CurrentStateName == ShipManager.State.MissileFlying)
            {
                pShip.SetState(ShipManager.State.StopRightMissileFlying);
            }
            //pShip.Handle();
        }
예제 #7
0
        public override void Update()
        {
            Ship pShip = ShipManager.GetShip();

            pShip.SetState(ShipStateEnum.Ready);
            Missile pMissile = ShipManager.GetMissile();

            pMissile.SetActive(false);
        }
예제 #8
0
        public static Ship CreateShip()
        {
            if (instance == null)
            {
                instance = new ShipMan();
            }

            Debug.Assert(instance != null);

            Ship pShip = ActivateShip();

            pShip.SetState(ShipMan.State.Ready);
            return(pShip);
        }
        public static void Create()
        {
            // make sure its the first time
            Debug.Assert(instance == null);

            // Do the initialization
            if (instance == null)
            {
                instance = new ShipManager();
            }

            Debug.Assert(instance != null);

            // Stuff to initialize after the instance was created
            pShip = CreateShip();
            pShip.SetState(ShipManager.State.Ready);

            pMissile = CreateMissile();
        }
예제 #10
0
        public static void GetNextShip()
        {
            //get the instance of the ship manager;
            ShipManager pShipMan = ShipManager.privInstance();

            Debug.Assert(pShipMan != null);

            Ship nextShip = null;

            //if there's another ship, get and prepare it
            if (pShipMan.privHasAnotherShip())
            {
                nextShip = (Ship)pShipMan.pCurrentShip.pChild;
                Debug.Assert(nextShip != null);

                //set the coordinates to starting position
                nextShip.x = pShipMan.startShip_PosX;
                nextShip.y = pShipMan.startShip_PosY;
                nextShip.SetState(State.Ready);
                //update the positioning;
                nextShip.pProxySprite.Update();
                nextShip.Update();

                //remove rendering of current ship (off screen);
                //todo FIX THIS - Cheap Hack to just render the old ships WAYY off screen!
                pShipMan.pCurrentShip.x = -1000.0f;
                pShipMan.pCurrentShip.y = -1000.0f;
                pShipMan.pCurrentShip.SetState(State.End);
                pShipMan.pCurrentShip.pProxySprite.Update();

                ////define an override remove inside of Ship class
                //pShipMan.pCurrentShip.Remove();

                pShipMan.pCurrentShip = nextShip;
                pShipMan.pCurrentShip.Update();

                Debug.Assert(pShipMan.pCurrentShip != null);

                //remove the current ship;
            }

            //return nextShip;
        }
예제 #11
0
        public static Ship CreateInactiveShip(int xPos, int yPos)
        {
            ShipMan pShipMan = ShipMan.PrivInstance();

            Debug.Assert(pShipMan != null);

            // copy over safe copy
            Ship pShip = new Ship(GameObject.Name.ShipInactive, GameSprite.Name.ShipInactive, xPos, yPos);

            pShip.SetState(ShipMan.State.Inactive);

            // Attach the sprite to the correct sprite batch
            SpriteBatch pSB_Aliens = SpriteBatchMan.Find(SpriteBatch.Name.Aliens);

            pSB_Aliens.Attach(pShip.pProxySprite);

            GameObject pShipRoot = GameObjectMan.Find(GameObject.Name.ShipRoot);

            Debug.Assert(pShipRoot != null);

            pShipRoot.Add(pShip);
            GameObjectMan.Attach(pShip);
            return(pShip);
        }
 //----------------------------------------------------------------------------------
 // Handle
 //----------------------------------------------------------------------------------
 public override void Handle(Ship pShip)
 {
     pShip.SetState(ShipMan.State.MoveLeftRight);
 }
예제 #13
0
        public override void Update()
        {
            Ship pShip = ShipManager.GetShip();

            pShip.SetState(ShipStateEnum.End);
        }
 public override void MoveRight(Ship pShip)
 {
     pShip.x += pShip.shipSpeed;
     //this.Handle(pShip);
     pShip.SetState(ShipManager.State.MissileFlying);
 }
예제 #15
0
        public void PrepareNewShip(Ship pShip)
        {
            Debug.Assert(pShip != null);

            pShip.SetState(State.Ready);
        }
예제 #16
0
 //----------------------------------------------------------------------------------
 // Handle
 //----------------------------------------------------------------------------------
 public override void Handle(Ship pShip)
 {
     pShip.SetState(ShipMan.State.MissileFlying);
 }
        public override void Notify()
        {
            Ship pShip = ShipMan.GetShip();

            pShip.SetState(ShipMan.State.End);
        }
예제 #18
0
        public override void Notify()
        {
            Ship pShip = ShipManager.GetCurrentShip();

            pShip.SetState(ShipManager.State.Ready);
        }
 public override void Handle(Ship pShip)
 {
     pShip.SetState(ShipManager.State.Ready);
 }
예제 #20
0
 public override void Handle(Ship pShip)
 {
     pShip.SetState(ShipStateEnum.MissileFlying);
 }