Exemplo n.º 1
0
        public static void ChangeSceneInternal(GameObject pGameObject)
        {
            ForwardIterator pFor = new ForwardIterator(pGameObject);

            Component pNode = pFor.First();

            pFor.Next();
            if (pFor.IsDone())
            {
                GameObject pUFORoot = GameObjectMan.Find(GameObject.Name.UFORoot);
                UFO        pUFO     = (UFO)Iterator.GetChild(pUFORoot);
                pUFO.StopSound();

                int mode      = SceneStateGame.GetPlayMode();
                int currLevel = SceneStateGame.GetCurrLevel();

                String pScore1 = Int32.Parse(FontMan.Find(Font.Name.Score1).GetMessage()).ToString().PadLeft(4, '0');
                SceneStateGame.SetScore1(pScore1);

                String pScore2 = Int32.Parse(FontMan.Find(Font.Name.Score2).GetMessage()).ToString().PadLeft(4, '0');
                SceneStateGame.SetScore2(pScore2);

                String pScoreHigh = Int32.Parse(FontMan.Find(Font.Name.ScoreHigh).GetMessage()).ToString().PadLeft(4, '0');
                SceneStateGame.SetScoreHigh(pScoreHigh);

                SceneStateGame.SetStay(true);

                int currPlayer = SceneStateGame.GetCurrPlayer();

                if (currLevel == 1)
                {
                    SceneStateGame.SetPlayerLevel(currPlayer, 2);
                    SceneStateGame.SetBaseY(450.0f);
                    SceneStateGame.SetMoveRate(1.0f);
                }
                else
                {
                    SceneStateGame.SetPlayerLevel(currPlayer, 1);
                    SceneStateGame.SetBaseY(600.0f);
                    SceneStateGame.SetMoveRate(1.5f);
                    //no need to change to the next player, when finish level 2, same player, back to level 1
                    //SceneStateGame.SetCurrPlayer(currPlayer == mode ? 1 : 2);
                }

                //currLevel = SceneStateGame.GetCurrLevel();
                //if (currLevel == 1)
                //{
                //    SceneStateGame.SetBaseY(600.0f);
                //    SceneStateGame.SetMoveRate(1.5f);
                //}
                //else
                //{
                //    SceneStateGame.SetBaseY(450.0f);
                //    SceneStateGame.SetMoveRate(1.0f);
                //}

                Scene pScene = SceneMan.GetScene();
                pScene.Unload();
            }
        }
Exemplo n.º 2
0
        private void Reset()
        {
            SceneStateGame.SetScore1("0000");
            SceneStateGame.SetScore2("0000");

            SceneStateGame.SetBaseY(600.0f);
            SceneStateGame.SetPlayerLevel(1, 1);
            SceneStateGame.SetPlayerLevel(2, 1);

            SceneStateGame.SetMoveRate(1.5f);

            AlienGroup.ResetDirection();
        }
Exemplo n.º 3
0
        public override void Notify()
        {
            this.pShip = (Ship)this.pSubject.pObjB;

            int mode = SceneStateGame.GetPlayMode();

            if (mode == 1)
            {
                int lifeLeft = SceneStateGame.GetPlayerLife(1);
                SceneStateGame.SetPlayerLife(1, lifeLeft - 1);
                lifeLeft = SceneStateGame.GetPlayerLife(1);
                if (lifeLeft == 0)
                {
                    this.state = false;
                    CreateShipObserver pCreateShipObserver = new CreateShipObserver(this);

                    ChangeScene pChangeScene = new ChangeScene(pCreateShipObserver);

                    TimerMan.Add(TimerEvent.Name.AnimShip, pChangeScene, 0.2f, false);

                    this.pShip.SetState(ShipMan.State.End);
                    //DelayedObjectMan.Attach(pCreateShipObserver);
                }
                else
                {
                    ShipMan.Create(new SndObserver(this.pSndEngine, SndObserver.Name.ShootMissile));
                }
            }
            else if (mode == 2)
            {
                int player   = SceneStateGame.GetCurrPlayer();
                int lifeLeft = SceneStateGame.GetPlayerLife(player);
                SceneStateGame.SetPlayerLife(player, lifeLeft - 1);

                int currPlayerLifeLeft = SceneStateGame.GetPlayerLife(player);
                int nextPlayerLifeLeft = SceneStateGame.GetPlayerLife(2 - player / 2);

                if (nextPlayerLifeLeft == 0 && currPlayerLifeLeft == 0)
                {
                    this.state = false;
                    CreateShipObserver pCreateShipObserver = new CreateShipObserver(this);
                    ChangeScene        pChangeScene        = new ChangeScene(pCreateShipObserver);

                    TimerMan.Add(TimerEvent.Name.AnimShip, pChangeScene, 0.2f, false);
                    this.pShip.SetState(ShipMan.State.End);
                    //DelayedObjectMan.Attach(pCreateShipObserver);
                }
                else if (nextPlayerLifeLeft == 0 && currPlayerLifeLeft != 0)
                {
                    ShipMan.Create(new SndObserver(this.pSndEngine, SndObserver.Name.ShootMissile));
                }
                else if (nextPlayerLifeLeft != 0)
                {
                    this.state = true;
                    SceneStateGame.SetCurrPlayer(2 - player / 2);
                    CreateShipObserver pCreateShipObserver = new CreateShipObserver(this);
                    ChangeScene        pChangeScene        = new ChangeScene(pCreateShipObserver);

                    TimerMan.Add(TimerEvent.Name.AnimShip, pChangeScene, 0.2f, false);
                    this.pShip.SetState(ShipMan.State.End);
                    //DelayedObjectMan.Attach(pCreateShipObserver);
                }
                else
                {
                    Debug.Assert(false);
                }

                int currLevel = SceneStateGame.GetCurrLevel();
                if (currLevel == 1)
                {
                    SceneStateGame.SetBaseY(600.0f);
                    SceneStateGame.SetMoveRate(1.5f);
                }
                else
                {
                    SceneStateGame.SetBaseY(450.0f);
                    SceneStateGame.SetMoveRate(1.0f);
                }
            }
            else
            {
                Debug.Assert(false);
            }
        }