Beispiel #1
0
    private void CollectableGained(CollectableType _collectableType)
    {
        switch (_collectableType)
        {
        case CollectableType.Gold:
            if (coinSoundLevel == 0)
            {
                PlayCoinSound(coinCollectLowSound);
                coinSoundLevel++;
            }
            else if (coinSoundLevel == 1)
            {
                PlayCoinSound(coinCollectMidSound);
                coinSoundLevel++;
            }
            else if (coinSoundLevel == 2)
            {
                PlayCoinSound(coinCollectHighSound);
            }
            CoinCollected();
            break;

        case CollectableType.Charge:
            // Debug.Log("got Charge");
            PlaySound(powerUpSound);
            particleManager.CreateParticles(ParticleType.UnlimitedCharge, character.MyTransform.position);
            powerUpsManager.ActivatePowerUp(_collectableType);
            break;

        case CollectableType.Shield:
            // Debug.Log("got shield");
            PlaySound(powerUpSound);
            particleManager.CreateParticles(ParticleType.Shield, character.MyTransform.position);
            powerUpsManager.ActivatePowerUp(_collectableType);
            break;

        case CollectableType.MegaCoin:
            // Debug.Log("got mega coin");
            PlaySound(powerUpSound);
            MegaCoinCollected();
            particleManager.CreateParticles(ParticleType.Diamond, character.MyTransform.position);
            break;

        case CollectableType.Stamina:
            // Debug.Log("got stamina");
            PlaySound(staminaSound);
            particleManager.CreateParticles(ParticleType.RhinoSnax, character.MyTransform.position);
            powerUpsManager.ActivatePowerUp(_collectableType);
            break;

        default:
            Debug.LogError("Unknown Collectable");
            break;
        }
    }
        public SubMenuScene(GraphicsDevice graphicsDevice)
            : base(graphicsDevice)
        {
            particleManager = new ParticleManager(10000);

            AddActor(new Starfield());
            AddActor(new Grid());
            AddActor(particleManager);

            particleManager.CreateParticles();

            AddPostprocess(new Bloom(new SpriteBatch(graphicsDevice), graphicsDevice));

            random = new Random();
        }
        public SubMenuScene(GraphicsDevice graphicsDevice)
            : base(graphicsDevice)
        {
            particleManager = new ParticleManager(10000);

            AddActor(new Starfield());
            AddActor(new Grid());
            AddActor(particleManager);

            particleManager.CreateParticles();

            AddPostprocess(new Bloom(new SpriteBatch(graphicsDevice), graphicsDevice));

            random = new Random();
        }
        public MainMenuScene(GraphicsDevice graphicsDevice, AudioManager audioManager)
            : base(graphicsDevice)
        {
            particleEffectDelay = 0;

            particleManager = new ParticleManager(10000);
            this.audioManager = audioManager;

            AddActor(new Starfield());
            AddActor(new Grid());
            AddActor(particleManager);
            AddActor(audioManager);

            particleManager.CreateParticles();

            AddPostprocess(new Bloom(new SpriteBatch(graphicsDevice), graphicsDevice));

            random = new Random();
        }
Beispiel #5
0
        public MainMenuScene(GraphicsDevice graphicsDevice, AudioManager audioManager)
            : base(graphicsDevice)
        {
            particleEffectDelay = 0;

            particleManager   = new ParticleManager(10000);
            this.audioManager = audioManager;

            AddActor(new Starfield());
            AddActor(new Grid());
            AddActor(particleManager);
            AddActor(audioManager);

            particleManager.CreateParticles();

            AddPostprocess(new Bloom(new SpriteBatch(graphicsDevice), graphicsDevice));

            random = new Random();
        }
        public GameplayScene(GraphicsDevice graphicsDevice, AudioManager audioManager)
            : base(graphicsDevice)
        {
            EndScene = false;

            ShipManager = new ShipManager(10);
            BulletManager = new BulletManager(100);
            EnemyManager = new EnemyManager(50);
            MultiplierManager = new MultiplierManager(100);
            ParticleManager = new ParticleManager(10000);
            Hud = new HUD(graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height);
            AudioManager = audioManager;

            postgameTimer = TimeSpan.FromSeconds(3);
            gameOver = false;

            AddActor(new Starfield());
            AddActor(new Grid());
            AddActor(ShipManager);
            AddActor(BulletManager);
            AddActor(EnemyManager);
            AddActor(MultiplierManager);
            AddActor(ParticleManager);
            AddActor(Hud);
            AddActor(audioManager);

            ShipManager.CreateShips();
            BulletManager.CreateBullets();
            EnemyManager.CreateEnemies();
            MultiplierManager.CreateMultipliers();
            ParticleManager.CreateParticles();

            AddPostprocess(new Bloom(new SpriteBatch(graphicsDevice), graphicsDevice));

            ShipManager.ActivateShip(true);
            Camera.TargetActor = ShipManager.PlayerShip;
            Hud.PlayerShip = ShipManager.PlayerShip;

            AudioManager.TargetListener = ShipManager.PlayerShip;
            AudioManager.Stop();
        }
        public GameplayScene(GraphicsDevice graphicsDevice, AudioManager audioManager) : base(graphicsDevice)
        {
            EndScene = false;

            ShipManager       = new ShipManager(10);
            BulletManager     = new BulletManager(100);
            EnemyManager      = new EnemyManager(50);
            MultiplierManager = new MultiplierManager(100);
            ParticleManager   = new ParticleManager(10000);
            Hud          = new HUD(graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height);
            AudioManager = audioManager;

            postgameTimer = TimeSpan.FromSeconds(3);
            gameOver      = false;

            AddActor(new Starfield());
            AddActor(new Grid());
            AddActor(ShipManager);
            AddActor(BulletManager);
            AddActor(EnemyManager);
            AddActor(MultiplierManager);
            AddActor(ParticleManager);
            AddActor(Hud);
            AddActor(audioManager);

            ShipManager.CreateShips();
            BulletManager.CreateBullets();
            EnemyManager.CreateEnemies();
            MultiplierManager.CreateMultipliers();
            ParticleManager.CreateParticles();

            AddPostprocess(new Bloom(new SpriteBatch(graphicsDevice), graphicsDevice));

            ShipManager.ActivateShip(true);
            Camera.TargetActor = ShipManager.PlayerShip;
            Hud.PlayerShip     = ShipManager.PlayerShip;

            AudioManager.TargetListener = ShipManager.PlayerShip;
            AudioManager.Stop();
        }
Beispiel #8
0
    void Update()
    {
        // don't update the creep row
        if (Y == 0)
        {
            return;
        }

        if (changeState)
        {
            State = BlockState.Falling;

            changeState = false;
        }

        switch (State)
        {
        case BlockState.Idle:
            // we may have to fall
            if (grid.StateAt(X, Y - 1) == GridElement.ElementState.Empty)
            {
                StartFalling();
            }
            break;

        case BlockState.Falling:
            FallElapsed += Time.deltaTime;

            if (FallElapsed >= FallDuration)
            {
                if (grid.StateAt(X, Y - 1) == GridElement.ElementState.Empty)
                {
                    // shift our grid position down to the next row
                    Y--;
                    FallElapsed = 0.0f;

                    grid.Remove(X, Y + 1, this);
                    grid.AddBlock(X, Y, this, GridElement.ElementState.Falling);
                }
                else
                {
                    // we've landed

                    // change our state
                    State = BlockState.Idle;

                    // update the grid
                    grid.ChangeState(X, Y, this, GridElement.ElementState.Block);

                    // register for elimination checking
                    grid.RequestMatchCheck(this);
                }
            }
            break;

        case BlockState.Dying:
            DieElapsed += Time.deltaTime;

            if (DieElapsed >= DieDuration)
            {
                // change the game state
                blockManager.DyingBlockCount--;

                // update the grid
                grid.Remove(X, Y, this);

                // tell our upward neighbor to fall
                if (Y < Grid.PlayHeight - 1)
                {
                    if (grid.StateAt(X, Y + 1) == GridElement.ElementState.Block)
                    {
                        grid.BlockAt(X, Y + 1).StartFalling(Chain);
                    }
                }

                Chain.DecrementInvolvement();

                ParticleManager particleManager = FindObjectOfType <ParticleManager>();
                particleManager.CreateParticles(X, Y, Chain.Magnitude, Type);

                blockManager.DeleteBlock(this);
            }
            break;
        }
    }
Beispiel #9
0
        public override void Update()
        {
            float time = (float)GlobalTime.ElapsedGameMilliseconds / 1000;

            if (GameInput.IsButtonDown(NESInput.Up))
            {
                pos.Y -= VELOCITY * time;
                if (pos.Y < 0)
                {
                    pos.Y = 0;
                }
            }
            if (GameInput.IsButtonDown(NESInput.Down))
            {
                pos.Y += VELOCITY * time;
                if (pos.Y + sprite.rectangle.Height > 240)
                {
                    pos.Y = 240 - sprite.rectangle.Height;
                }
            }
            if (GameInput.IsButtonDown(NESInput.Left))
            {
                pos.X -= VELOCITY * time;
                if (pos.X < 0)
                {
                    pos.X = 0;
                }
            }
            if (GameInput.IsButtonDown(NESInput.Right))
            {
                pos.X += VELOCITY * time;
                if (pos.X + sprite.rectangle.Width > 256)
                {
                    pos.X = 256 - sprite.rectangle.Width;
                }
            }
            if (GameInput.IsButtonDown(NESInput.A))
            {
                if (shootDelay >= BULLET_SHOOT_DELAY)
                {
                    ShootBullet();
                }
            }
            if (particleDelay >= PARTICLE_SPAWN_DELAY)
            {
                ParticleManager.CreateParticles(ContentIndex.Pixel, new Vector2(pos.X + random.Next(6, 10), pos.Y + 14), PARTICLE_AMOUNT, new Vector2(0, 1), spread: 0, minSpeed: 10, maxSpeed: 20, Color.CornflowerBlue, colorHueShift: 1, 1);
                particleDelay -= PARTICLE_SPAWN_DELAY;
            }

            if (speed > 0)
            {
                GlobalTime.ChangeSpeed(Easing.ApplyEasingFromOne(1 - speed, EasingMode.CubicIn));
                speed -= (time * 5);
            }
            else
            {
                speed = 0;
            }

            if (shootDelay < BULLET_SHOOT_DELAY)
            {
                shootDelay += time;
            }
            if (particleDelay < PARTICLE_SPAWN_DELAY)
            {
                particleDelay += time;
            }

            bbox.X = (int)pos.X;
            bbox.Y = (int)pos.Y;

            base.Update();
        }
Beispiel #10
0
    public void CreateParticles(ParticleSystem prefab, Vector3 position, bool force = false)
    {
        ParticleManager particleManager = this.GetParticleManager(prefab);

        particleManager.CreateParticles(position, force);
    }