Esempio n. 1
0
        public static SoundUtility getInstance()
        {
            if (privInstance == null)
            {
                privInstance = new SoundUtility();
            }

            return(privInstance);
        }
Esempio n. 2
0
        public override void Notify()
        {
            // If there's a missile flying, we don't want to do anything
            if (!ProjectileTracker.MissileFlying)
            {
                // Adjust missile position
                this.pMissileProxy.x = this.pShipProxy.x;
                this.pMissileProxy.y = this.pShipProxy.y;

                //Debug.Print("Shoot");

                SoundUtility.getInstance().shoot();
                pMissileProxy.Shoot();
            }
        }
Esempio n. 3
0
        public override void Execute(float deltaTime)
        {
            this.privGameObject.CompositeMove();
            //Debug.Print("(" + this.privGameObject.pProxy.x.ToString() + ", " + this.privGameObject.pProxy.y.ToString() + ")");

            SoundUtility.getInstance().Advancing();

            int alienShoot;

            if (GlobalPlayerStats.isPlayer1Playing)
            {
                alienShoot = 55 - GlobalPlayerStats.Player1.alienLeft;
            }
            else
            {
                alienShoot = 55 - GlobalPlayerStats.Player2.alienLeft;
            }


            TimerManager.getInstance().Add(TimerEvent.Name.SwapImageAnimation, this, this.deltaTime - 0.005f * alienShoot);
        }
Esempio n. 4
0
        // Visitor logic
        // TODO: can be simplified using strategy
        public override void Accept(Visitor v)
        {
            if (this.category == Category.Wall)
            {
                if (this.mGameSprtName == GameSprite.Name.LeftWall)
                {
                    v.VisitLeftWall();
                }
                else if (this.mGameSprtName == GameSprite.Name.RightWall)
                {
                    v.VisitRightWall();
                }
                else
                {
                    v.VisitWall();
                }
            }
            else if (this.category == Category.Alien)
            {
                v.VisitAlien();
            }
            else if (this.category == Category.Shield)
            {
                v.VisitShield();
            }
            else if (this.category == Category.Missile)
            {
                if (ProjectileTracker.MissileFlying)
                {
                    v.VisitMissile();

                    // Reset location
                    this.pProxy.x = 0f;
                    this.pProxy.y = -10f;
                    this.pProxy.Update();
                    // Flip Missile Handle
                    ProjectileTracker.MissileHandle();
                }
            }
            else if (this.category == Category.Ship)
            {
                v.VisitShip();
            }

            // If hit by missile, start self-destruction process
            if (((GameObject)v).category == Category.Missile || (((GameObject)v).category == Category.Bomb && this.category != Category.Missile))
            {
                // Play explosion animation
                Debug.Print(this.category + " hit by" + ((GameObject)v).category);

                // If ship, trigger next round
                if (this.category == Category.Ship)
                {
                    SoundUtility.getInstance().playExplosion();
                    SpaceInvaders.currentState.Handle();
                    return;
                }

                // If Alien, incremente score
                if (this.mGameSprtName == GameSprite.Name.Octopus)
                {
                    GlobalPlayerStats.incrementScore(10);
                }
                else if (this.mGameSprtName == GameSprite.Name.Crab)
                {
                    GlobalPlayerStats.incrementScore(20);
                }
                else if (this.mGameSprtName == GameSprite.Name.Squid)
                {
                    GlobalPlayerStats.incrementScore(20);
                }

                // set itself as not collidable, if it's not wall
                if (this.category != Category.Wall)
                {
                    if (this.category == Category.Alien)
                    {
                        SoundUtility.getInstance().killed();
                        this.mGameSprite.ShowExplosion();
                    }
                    else if (this.category == Category.UFO)
                    {
                        SoundUtility.getInstance().killed();
                        ((UFOProxy)this.pProxy).reset();
                        GlobalPlayerStats.incrementScore(300);
                        return;
                    }
                    else
                    {
                        SoundUtility.getInstance().playExplosion();
                    }



                    this.collidable = false;
                    // Remove itself from active
                    GameObjectManager.getInstance().Remove(this);
                }
            }
        }