예제 #1
0
        //public override void VisitMissileGroup(MissileGroup m)
        //{
        //    //Debug.WriteLine("collide: {0}<->{1}", m.GetName(), this.GetName());

        //    //go to the missile object
        //    //check the missile v. "this" UFO
        //    GameObject pGameObject = (GameObject)Iterator.GetChild(m);
        //    ColPair.Collide(pGameObject, this);
        //}

        public override void VisitMissile(Missile m)
        {
            //Debug.WriteLine("         collide:  {0} <-> {1}", m.GetName(), this.GetName());

            //Debug.WriteLine("-------> BOOM!  <--------");

            //add the points here.... because UFO can be removed if it hits a wall
            //this ensures that it was hit by a missile
            PlayerMan.SetP1Score(100);

            ColPair pColPair = ColPairMan.GetActiveColPair();

            //alphabetical ordering
            pColPair.SetCollision(m, this);
            pColPair.NotifyListeners();
        }
예제 #2
0
        public override void Notify()
        {
            // we need to revert lvl1 or lvl2 to original forms
            // because we lost and will need to re-load content

            //ship was hit take a life and subtract from score

            PlayerMan.P1TakeLife();
            PlayerMan.SetP1Score(-250);

            float P1lives = PlayerMan.GetP1Lives();

            SpaceInvaders pGame = GameMan.GetGame();

            //check if they have more lives
            if (P1lives == 0)
            {
                // last life i was stil able to shoot
                Ship pShip = ShipMan.GetShip();

                pShip.SetShootState(ShipMan.ShootState.End);
                pShip.SetMoveState(ShipMan.MoveState.NoMove);

                GameState pState = pGame.GetCurrentState();

                if (pState.GetStateName() == GameMan.State.InGame)
                {
                    InGameState pLvl1 = (InGameState)pState;
                    pLvl1.SetStateToggle(false);

                    TimerMan.Add(TimeEvent.Name.GameStateChange, new GameStateChange(false), 5.0f);
                }

                else if (pState.GetStateName() == GameMan.State.LVL2)
                {
                    InGameStateLV2 pLvl2 = (InGameStateLV2)pState;
                    pLvl2.SetStateToggle(false);

                    TimerMan.Add(TimeEvent.Name.GameStateChange, new GameStateChange(false), 5.0f);
                }
            }

            else
            {
                //do nothing
            }
        }
예제 #3
0
        public override void Notify()
        {
            //remove alien
            //Debug.WriteLine("RemoveAlienObserver: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB);

            //a little tricky ObjA is the missile, we are not alphabetical
            //because of how the missile observer is set up
            this.pAlien = (AlienCategory)this.pSubject.pObjB;
            Debug.Assert(this.pAlien != null);



            if (pAlien.bMarkForDeath == false)
            {
                pAlien.bMarkForDeath = true;

                if (pAlien.GetName() == GameObject.Name.Squid)
                {
                    PlayerMan.SetP1Score(30);
                }

                else if (pAlien.GetName() == GameObject.Name.Crab)
                {
                    PlayerMan.SetP1Score(40);
                }

                else
                {
                    PlayerMan.SetP1Score(50);
                }

                //pass brick reference to manager thats executes/removes objects later
                RemoveAlienObserver pObserver = new RemoveAlienObserver(this);
                DelayedObjectMan.Attach(pObserver);
            }
        }