Esempio n. 1
0
        public override async Task LoadContent()
        {
            await base.LoadContent();

            meterRenderer = new MeterRenderer(Content, "MeterShader.fx");

            var timerRect = new Rectangle(0, 0, 128, 128);

            CountdownClock = new TimerMeter(QuestionTime, Content, "TimerBackground.png", "TimerMeter.png", "TimerGradient.png", timerRect)
            {
                NearEndTime = QuestionTime * 0.5f,
            };

            //add the meter screen
            TimerScreen = new MeterScreen(CountdownClock,
                                          new Point((int)Resolution.TitleSafeArea.Left, (int)Resolution.TitleSafeArea.Top),
                                          TransitionWipeType.PopLeft,
                                          Content,
                                          VerticalAlignment.Top,
                                          HorizontalAlignment.Left);

            //make the player stare at this screen for 2 seconds before they can quit
            AutoQuit.Start(QuestionTime);
            CountdownClock.Reset();

            await ScreenManager.AddScreen(TimerScreen);

            //add the speech button for the question word
            AddListenButton(QuestionScreen.QuestionWordLabel, QuestionScreen.QuestionWordSoundEffect);

            //Add the speech button for each menuentry
            foreach (var entry in QuestionScreen.Entries)
            {
                AddListenButton(entry.QuestionLabel, entry.SoundEffect);
            }
        }
Esempio n. 2
0
        public void Draw(float currentHealth, IMeterRenderer meterRenderer, SpriteBatch spritebatch, bool flip = false)
        {
            if (!IsVisible)
            {
                return;
            }

            CurrentHP = currentHealth;

            meterRenderer.DrawBorder(this, spritebatch, Position, Vector2.One, Vector2.Zero, Color.White, flip);

            if (HealTimer.HasTimeRemaining)
            {
                //If the character is being healed, draw in heal mode

                //how much health bar to draw?
                var healingHealthBar = PreHealAmount + ((CurrentHP - PreHealAmount) * (1f - HealTimer.Lerp));
                var healingAlpha     = ConvertToAlpha(0, MaxHP, healingHealthBar);

                //how much pulsate to add to hp bar?
                var pulsate = PulsateScale(HealTimer.CurrentTime * HealPulsateSpeed, HealScaleAmount, Position);

                //what is the alpha of the current HP?
                var currentAlpha = ConvertToAlpha(0, MaxHP, CurrentHP);

                //draw the empty part of the bar
                meterRenderer.DrawMeter(this, spritebatch, Position, 0f, 1f, Vector2.One, Vector2.Zero, DepletedHealthColor, flip);

                //draw the healing part of the bar
                meterRenderer.DrawMeter(this, spritebatch, Position, healingAlpha, currentAlpha, Vector2.One, Vector2.Zero, GetHealingColor(), flip);

                //draw the health bar
                meterRenderer.DrawMeter(this, spritebatch, Position, 0f, healingAlpha, Vector2.One, Vector2.Zero, GetHealColor(), flip);
                meterRenderer.DrawMeter(this, spritebatch, Position, 0f, healingAlpha, pulsate, Vector2.Zero, GetHealColor(), flip);
            }
            else if (HitTimer.HasTimeRemaining)
            {
                //else if the character is being hit, draw in hit mode

                //how much pulsate to add to hp bar?
                var healthPulsate = PulsateScale(HitTimer.CurrentTime * HitShakeSpeed, HitHealthScaleAmount, Position);

                //how much offset to add to health bar?
                var healthOffset = OffsetVector(HitTimer.CurrentTime * HitShakeSpeed, HitHealthOffsetAmount);

                //what is the alpha of the current HP?
                var currentAlpha = ConvertToAlpha(0, MaxHP, CurrentHP);

                //what is the alpha of the current HP?
                var damageAlpha = ConvertToAlpha(0, MaxHP, PreDamageAmount);

                //how much pulsate to add to damage bar?
                var damagePulsate = PulsateScale(HitTimer.CurrentTime * HitShakeSpeed, HitDepletedHealthScaleAmount, Position);

                //how much offset to add to health bar?
                var damageOffset = OffsetVector(HitTimer.CurrentTime * HitShakeSpeed, HitDepletedHealthOffsetAmount);

                //draw the empty part of the bar
                meterRenderer.DrawMeter(this, spritebatch, Position, currentAlpha, 1f, Vector2.One, healthOffset, DepletedHealthColor, flip);

                //draw the damage bar
                meterRenderer.DrawMeter(this, spritebatch, Position, currentAlpha, damageAlpha, damagePulsate, damageOffset, GetHitDepletedHealthColor(), flip);

                //draw the health bar
                meterRenderer.DrawMeter(this, spritebatch, Position, 0f, currentAlpha, healthPulsate, healthOffset, GetHitHealthColor(), flip);
            }
            else if (!NearDeathClock.Paused)
            {
                //else if the character is near-death, draw in near-death mode

                //what is the alpha of the current HP?
                var currentAlpha = ConvertToAlpha(0, MaxHP, CurrentHP);

                //draw the empty part of the bar
                meterRenderer.DrawMeter(this, spritebatch, Position, currentAlpha, 1f, Vector2.One, Vector2.Zero, DepletedHealthColor, flip);

                //draw the health bar
                meterRenderer.DrawMeter(this, spritebatch, Position, 0f, currentAlpha, Vector2.One, Vector2.Zero, GetNearDeathColor(), flip);
            }
            else
            {
                //otherwise draw the health bar normal

                //what is the alpha of the current HP?
                var currentAlpha = ConvertToAlpha(0, MaxHP, CurrentHP);

                //draw the empty part of the bar
                meterRenderer.DrawMeter(this, spritebatch, Position, currentAlpha, 1f, Vector2.One, Vector2.Zero, DepletedHealthColor, flip);

                //draw the health bar
                meterRenderer.DrawMeter(this, spritebatch, Position, 0f, currentAlpha, Vector2.One, Vector2.Zero, GetHealthColor(), flip);
            }
        }
Esempio n. 3
0
        public override async Task LoadContent()
        {
            await base.LoadContent();

            //create the meter rectangles
            var lifebarRect = new Rectangle(
                (int)Resolution.TitleSafeArea.Left,
                (int)Resolution.TitleSafeArea.Top,
                512, 128);

            var superBarRect = new Rectangle(
                (int)Resolution.TitleSafeArea.Left,
                lifebarRect.Bottom,
                512, 128);

            var manaBarRect = new Rectangle(
                (int)Resolution.TitleSafeArea.Left,
                superBarRect.Bottom,
                1024, 256);

            var timerRect = new Rectangle(600,
                                          (int)Resolution.TitleSafeArea.Top,
                                          128, 128);

            //create the lifebar
            lifeBar       = new LifeBar(maxHP, Content, "lifebarborder.png", "lifebar.png", "lifebarGradient.png", lifebarRect);
            timer         = new TimerMeter(maxTime, Content, "TimerBackground.png", "TimerMeter.png", "TimerGradient.png", timerRect);
            manaBar       = new ManaBar(maxMana, Content, "energybackground.png", "energymeter.png", "energygradient.png", manaBarRect);
            superBar      = new SuperBar(maxSuper, Content, "EnergyMeter1.png", "EnergyMeterMask1.png", "EnergyMeterGradient1.png", superBarRect);
            meterRenderer = new MeterRenderer(Content, "MeterShader.fx");

            //add a stack of buttons for interacting with stuff
            var lifeButtonStack = new StackLayout(StackAlignment.Bottom)
            {
                Position   = new Point(Resolution.TitleSafeArea.Right, Resolution.TitleSafeArea.Bottom),
                Horizontal = HorizontalAlignment.Right,
                Vertical   = VerticalAlignment.Top
            };
            var hitButton = AddButton("Add Damage");

            hitButton.OnClick += HitButton_OnClick;
            lifeButtonStack.AddItem(hitButton);

            var healButton = AddButton("Heal");

            healButton.OnClick += HealButton_OnClick;
            lifeButtonStack.AddItem(healButton);

            var addSuperButton = AddButton("Add Energy");

            addSuperButton.OnClick += AddSuperButton_OnClick;
            lifeButtonStack.AddItem(addSuperButton);

            var spendSuperButton = AddButton("Use Super");

            spendSuperButton.OnClick += SpendSuperButton_OnClick;
            lifeButtonStack.AddItem(spendSuperButton);

            var addManaButton = AddButton("Add Mana");

            addManaButton.OnClick += AddManaButton_OnClick;
            lifeButtonStack.AddItem(addManaButton);

            var spendManaButton = AddButton("Use Mana");

            spendManaButton.OnClick += SpendManaButton_OnClick;
            lifeButtonStack.AddItem(spendManaButton);

            var nopeButton = AddButton("Super Nope");

            nopeButton.OnClick += NopeButton_OnClick;
            lifeButtonStack.AddItem(nopeButton);

            var resetTime = AddButton("ResetTime");

            resetTime.OnClick += ResetTime_OnClick;
            lifeButtonStack.AddItem(resetTime);

            AddItem(lifeButtonStack);

            Reset();
        }
Esempio n. 4
0
        public void Draw(float currentTime, IMeterRenderer meterRenderer, SpriteBatch spritebatch)
        {
            if (!IsVisible)
            {
                return;
            }

            CurrentTime = currentTime;

            var correctedPosition = GetShakyRectangle();

            if (IsNearEndMode)
            {
                //else if the character is near-death, draw in near-death mode

                //what is the alpha of the current HP?
                var currentAlpha = ConvertToAlpha(0, MaxTime, CurrentTime);

                //how much pulsate to add to hp bar?
                var pulsate = PulsateScale(TimeClock.CurrentTime * NearEndPulsateSpeed, NearEndPulsateAmount, correctedPosition);

                //draw the border
                meterRenderer.DrawBorder(this, spritebatch, correctedPosition, pulsate, Vector2.Zero, Color.White);

                //draw the empty part of the bar
                meterRenderer.DrawMeter(this, spritebatch, correctedPosition, 0f, currentAlpha, pulsate, Vector2.Zero, DepletedTimeColor);

                //draw the health bar
                meterRenderer.DrawMeter(this, spritebatch, correctedPosition, currentAlpha, 1f, pulsate, Vector2.Zero, GetNearEndTimeColor());
            }
            else if (CurrentTime <= 0f)
            {
                //otherwise draw the health bar normal

                //what is the alpha of the current HP?
                var currentAlpha = ConvertToAlpha(0, MaxTime, CurrentTime);

                //how much pulsate to add to hp bar?
                var pulsate = PulsateScale(TimeClock.CurrentTime * NearEndPulsateSpeed, NearEndPulsateAmount * 0.5f, correctedPosition);

                //draw the border
                meterRenderer.DrawBorder(this, spritebatch, correctedPosition, Vector2.One, Vector2.Zero, Color.White);

                //draw the health bar
                meterRenderer.DrawMeter(this, spritebatch, correctedPosition, 0f, 1f, pulsate, Vector2.Zero, GetTimeOutColor());
            }
            else
            {
                //otherwise draw the health bar normal

                //what is the alpha of the current HP?
                var currentAlpha = ConvertToAlpha(0, MaxTime, CurrentTime);

                //draw the border
                meterRenderer.DrawBorder(this, spritebatch, correctedPosition, Vector2.One, Vector2.Zero, Color.White);

                //draw the empty part of the bar
                meterRenderer.DrawMeter(this, spritebatch, correctedPosition, 0f, currentAlpha, Vector2.One, Vector2.Zero, DepletedTimeColor);

                //draw the health bar
                meterRenderer.DrawMeter(this, spritebatch, correctedPosition, currentAlpha, 1f, Vector2.One, Vector2.Zero, GetTimeColor());
            }
        }
Esempio n. 5
0
        public void Draw(float currentHealth, IMeterRenderer meterRenderer, SpriteBatch spritebatch, bool flip = false)
        {
            if (!IsVisible)
            {
                return;
            }

            CurrentMP = currentHealth;

            meterRenderer.DrawBorder(this, spritebatch, Position, Vector2.One, Vector2.Zero, Color.White, flip);

            if (UseManaTimer.HasTimeRemaining)
            {
                //else if the character is being hit, draw in hit mode

                //how much pulsate to add to hp bar?
                var healthPulsate = PulsateScale(UseManaTimer.CurrentTime * InUseShakeSpeed, InUseManaScaleAmount, Position);

                //how much offset to add to health bar?
                var healthOffset = OffsetVector(UseManaTimer.CurrentTime * InUseShakeSpeed, InUseManaOffsetAmount);

                //what is the alpha of the current HP?
                var currentAlpha = ConvertToAlpha(0, MaxMP, CurrentMP);

                //what is the alpha of the current HP?
                var damageAlpha = ConvertToAlpha(0, MaxMP, PreUseManaAmount);

                //how much pulsate to add to damage bar?
                var damagePulsate = PulsateScale(UseManaTimer.CurrentTime * InUseShakeSpeed, InUseDepletedManaScaleAmount, Position);

                //how much offset to add to health bar?
                var damageOffset = OffsetVector(UseManaTimer.CurrentTime * InUseShakeSpeed, InUseDepletedManaOffsetAmount);

                //draw the empty part of the bar
                meterRenderer.DrawMeter(this, spritebatch, Position, currentAlpha, 1f, Vector2.One, healthOffset, EmptyManaColor, flip);

                //draw the damage bar
                meterRenderer.DrawMeter(this, spritebatch, Position, currentAlpha, damageAlpha, damagePulsate, damageOffset, GetInUseManaDepletedColor(), flip);

                //draw the health bar
                meterRenderer.DrawMeter(this, spritebatch, Position, 0f, currentAlpha, healthPulsate, healthOffset, GetInUseManaColor(), flip);
            }
            else if (!ManaFullClock.Paused)
            {
                //else if the energy is full, draw in FullEnergy mode

                //how much pulsate to add to hp bar?
                var pulsate = PulsateScale(ManaFullClock.CurrentTime * ManaFullPulsateSpeed, ManaFullScaleAmount, Position);

                //draw the health bar
                meterRenderer.DrawMeter(this, spritebatch, Position, 0f, 1f, pulsate, Vector2.Zero, GetManaFullColor(), flip);
            }
            else
            {
                //otherwise draw the health bar normal

                //what is the alpha of the current HP?
                var currentAlpha = ConvertToAlpha(0, MaxMP, CurrentMP);

                //draw the empty part of the bar
                meterRenderer.DrawMeter(this, spritebatch, Position, currentAlpha, 1f, Vector2.One, Vector2.Zero, EmptyManaColor, flip);

                //draw the health bar
                meterRenderer.DrawMeter(this, spritebatch, Position, 0f, currentAlpha, Vector2.One, Vector2.Zero, GetManaColor(), flip);
            }
        }
Esempio n. 6
0
        public void Draw(float currentEnergy, IMeterRenderer meterRenderer, SpriteBatch spritebatch)
        {
            if (!IsVisible)
            {
                return;
            }

            CurrentEnergy = currentEnergy;

            var correctedPosition = GetNopedRectangle();

            //how much offset to add to energy bar?
            Vector2 offset = Vector2.Zero;

            if (UseEnergyTimer.HasTimeRemaining)
            {
                offset = OffsetVector(UseEnergyTimer.CurrentTime * UseEnergyShakeSpeed, UseEnergyShakeAmount);
            }

            meterRenderer.DrawBorder(this, spritebatch, correctedPosition, Vector2.One, offset, Color.White);

            if (UseEnergyTimer.HasTimeRemaining)
            {
                var spentEnergy      = MaxEnergy * UseEnergyTimer.Lerp;
                var spentEnergyAlpha = ConvertToAlpha(0, MaxEnergy, spentEnergy);

                //draw the depleted bar
                meterRenderer.DrawMeter(this, spritebatch, correctedPosition, spentEnergyAlpha, 1f, Vector2.One, offset, GetUseEnergyDepletedColor());

                //draw the energy bar
                meterRenderer.DrawMeter(this, spritebatch, correctedPosition, 0f, spentEnergyAlpha, Vector2.One, offset, GetUseEnergyColor());
            }
            else if (AddEnergyTimer.HasTimeRemaining)
            {
                //how much health bar to draw?
                var healingHealthBar = PreAddAmount + ((CurrentEnergy - PreAddAmount) * (1f - AddEnergyTimer.Lerp));
                var healingAlpha     = ConvertToAlpha(0, MaxEnergy, healingHealthBar);

                //how much pulsate to add to hp bar?
                var pulsate = PulsateScale(AddEnergyTimer.CurrentTime * AddEnergyPulsateSpeed, AddEnergyScaleAmount, correctedPosition);

                //what is the alpha of the current HP?
                var currentAlpha = ConvertToAlpha(0, MaxEnergy, CurrentEnergy);

                //draw the empty part of the bar
                meterRenderer.DrawMeter(this, spritebatch, correctedPosition, 0f, 1f, Vector2.One, Vector2.Zero, EmptyEnergyColor);

                //draw the healing part of the bar
                meterRenderer.DrawMeter(this, spritebatch, correctedPosition, healingAlpha, currentAlpha, Vector2.One, Vector2.Zero, GetAddingEnergyColor());

                //draw the health bar
                meterRenderer.DrawMeter(this, spritebatch, correctedPosition, 0f, healingAlpha, Vector2.One, Vector2.Zero, GetAddEnergyColor());
                meterRenderer.DrawMeter(this, spritebatch, correctedPosition, 0f, healingAlpha, pulsate, Vector2.Zero, GetAddEnergyColor());
            }
            else if (!EnergyFullClock.Paused)
            {
                //else if the energy is full, draw in FullEnergy mode

                //how much pulsate to add to hp bar?
                var pulsate = PulsateScale(EnergyFullClock.CurrentTime * EnergyFullPulsateSpeed, EnergyFullScaleAmount, correctedPosition);

                //draw the health bar
                meterRenderer.DrawMeter(this, spritebatch, correctedPosition, 0f, 1f, pulsate, Vector2.Zero, GetEnergyFullColor());
            }
            else
            {
                //otherwise draw the health bar normal

                //what is the alpha of the current HP?
                var currentAlpha = ConvertToAlpha(0, MaxEnergy, CurrentEnergy);

                //draw the empty part of the bar
                meterRenderer.DrawMeter(this, spritebatch, correctedPosition, currentAlpha, 1f, Vector2.One, Vector2.Zero, EmptyEnergyColor);

                //draw the health bar
                meterRenderer.DrawMeter(this, spritebatch, correctedPosition, 0f, currentAlpha, Vector2.One, Vector2.Zero, GetEnergyColor());
            }

            //draw the shadow if time is left
            if (UseEnergyShadowTimer.HasTimeRemaining)
            {
                var scale = LerpScale(UseEnergyShadowTimer, UseEnergyShadowTargetScale, correctedPosition);
                var color = GetUseEnergyShadowColor();
                meterRenderer.DrawMeter(this, spritebatch, correctedPosition, 0f, 1f, scale, Vector2.Zero, color);
            }
        }