public override void execute(float deltaTime)
        {
            this.remainTime -= deltaTime;

            if (this.remainTime > 0)
            {
                // get next image
                ImageHolder pImageHolder = (ImageHolder)this.pCurrImage.pNext;

                // if at the end of the list, set first image back
                if (pImageHolder == null)
                {
                    pImageHolder = (ImageHolder)this.poFirstImage;
                }

                this.pCurrImage = pImageHolder;

                // change image
                this.pGameObject.getProxySprite().getGameSprite().swapImage(pImageHolder.getImage());

                // Add itself back to TimerMan
                TimerMan.Add(TimeEvent.Name.ExplosionEvent, this, deltaTime);
            }
            else
            {
                Ship pShip = (Ship)this.pGameObject;
                pShip.reduceLife();
                if (pShip.getLife() < 0)
                {
                    pShip.remove();
                    Scene pScene = SceneMan.GetScene();
                    pScene.unLoadContent();
                    pScene.setState(SceneMan.State.GameOverScene);
                    pScene.loadContent();
                }
                else
                {
                    pShip.setState(ShipMan.State.Ready);
                    pShip.setPositionState(ShipMan.State.Normal);
                    pShip.bMarkForDeath = false;
                    pShip.getProxySprite().setGameSprite(GameSpriteMan.Find(GameSprite.Name.Ship));
                }
            }
        }
Example #2
0
        //----------------------------------------------------------------------
        // Override Abstract methods
        //----------------------------------------------------------------------
        public override void execute(float deltaTime)
        {
            // get next image
            ImageHolder pImageHolder = (ImageHolder)this.pCurrImage.pNext;
            SoundHolder pSoundHolder = (SoundHolder)this.pCurrSound.pNext;

            // if at the end of the list, set first image back
            if (pImageHolder == null)
            {
                pImageHolder = (ImageHolder)this.poFirstImage;
            }

            if (pSoundHolder == null)
            {
                pSoundHolder = (SoundHolder)this.poFirstSound;
            }

            this.pCurrImage = pImageHolder;
            this.pCurrSound = pSoundHolder;

            // change image
            this.pGameSprite.swapImage(pImageHolder.getImage());
            SoundMan.Play(pSoundHolder.getSound());

            // Add itself back to TimerMan
            if (this.pGameSprite.getName() == GameSprite.Name.Squid)
            {
                TimerMan.Add(TimeEvent.Name.SquidAnimation, this, deltaTime);
            }
            else if (this.pGameSprite.getName() == GameSprite.Name.Crab)
            {
                TimerMan.Add(TimeEvent.Name.CrabAnimation, this, deltaTime);
            }
            else if (this.pGameSprite.getName() == GameSprite.Name.Octopus)
            {
                TimerMan.Add(TimeEvent.Name.OctopusAnimation, this, deltaTime);
            }
        }