Exemplo n.º 1
0
        public override void UpdateLifeRegen()
        {/*
          * if (Spellsmith.instance.abilityInterface.CurrentState == null)
          * {
          *     if (player.HeldItem.modItem is SpellBlaster)
          *     {
          *         Spellsmith.instance.ShowAbilityUI();
          *     }
          * }
          * else if (!(player.HeldItem.modItem is SpellBlaster))
          * {
          *     Spellsmith.instance.HideAbilityUI();
          * }
          */
            if (activeBlaster != null)
            {
                for (int i = 0; i < activeEffects.Count; i++)
                {
                    if (i < activeEffects.Count)
                    {
                        SpellEffect effect = activeEffects[i];
                        Main.NewText(effect);
                        if (effect.OnCooldown)
                        {
                            bool success = effect.ReduceCooldown();
                            if (success)
                            {
                                activeEffects.Remove(effect);
                            }
                        }
                        else if (effect.CanRunSpell(player, activeBlaster))
                        {
                            Vector2 velocity     = Vector2.Normalize(Main.MouseWorld - player.Center) * activeBlaster.shootSpeed;
                            Vector2 castPosition = player.Center + (Vector2.Normalize(Main.MouseWorld - player.Center) * (activeBlaster.width + 12));

                            switch (effect.Style)
                            {
                            case SpellStyle.Default:
                            {
                                RunSpell(effect, velocity, castPosition);
                                activeEffects.RemoveAt(i);
                                break;
                            }

                            case SpellStyle.HoldRelease:
                            {
                                effect.Charge(player);
                                effect.DoChargeVisuals(player, castPosition, activeBlaster);
                                if (!player.channel)
                                {
                                    RunSpell(effect, velocity, castPosition);
                                }
                                break;
                            }

                            case SpellStyle.Charge:
                            {
                                effect.DoChargeVisuals(player, castPosition, activeBlaster);
                                bool success = effect.Charge(player);
                                if (success || !player.channel)
                                {
                                    RunSpell(effect, velocity, castPosition);
                                }
                                break;
                            }

                            case SpellStyle.ChargeRelease:
                            {
                                effect.DoChargeVisuals(player, castPosition, activeBlaster);
                                effect.Charge(player);
                                if (!player.channel)
                                {
                                    RunSpell(effect, velocity, castPosition);
                                }
                                break;
                            }
                            }
                        }
                    }
                }
            }
        }