Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class SpellList : MonoBehaviour
- {
- public int preppedSpellLimit;
- public Dictionary<string, string> spellList = new Dictionary<string, string>();
- public Dictionary<string, string> spellComboList = new Dictionary<string, string>();
- List<string> level1Spells = new List<string>();
- List<string> level2Spells = new List<string>();
- List<string> homingSpells = new List<string>();
- List<string> areaSpells = new List<string>();
- [HideInInspector] public List<string> preparedSpells = new List<string>();
- AudioSource source;
- public AudioClip spellPrepAudio;
- public AudioClip badSpell;
- DrawSpellLine drawSpellLine;
- public PreparedSpellsPanel spellsPanel;
- [SerializeField] SpellCasting spellCasting;
- [HideInInspector] public float preparedSpellCost = 0;
- private void Start()
- {
- spellCasting = GetComponentInParent<SpellCasting>();
- drawSpellLine = GetComponent<DrawSpellLine>();
- source = GetComponentInParent<AudioSource>();
- //quick spells
- spellList.Add("1.1.1.", "lightningBolt");
- spellList.Add("2.2.2.", "windVortex");
- spellList.Add("3.3.3.", "iceSpike");
- spellList.Add("4.4.4.", "fireball");
- //spellList.Add("4.1.2.", "earthSpike");
- //spellList.Add("2.4.2.", "windDash");
- //spellList.Add("3.3.3.", "murderIce");
- //complex spells
- spellList.Add("3.4.1.2.3.", "heal");
- spellList.Add("3.1.4.2.1.", "windJump");
- spellList.Add("1.2.4.3.", "lightningBoltComplex");
- spellList.Add("2.4.3.1.", "windVortexComplex");
- spellList.Add("3.1.4.1.", "iceSpikeComplex");
- spellList.Add("4.2.3.2.", "fireballComplex");
- //spell modifiers
- spellList.Add("4.3.1.3.2.", "homing");
- spellList.Add("1.4.2.4.3.", "burst");
- spellList.Add("3.2.1.4.3.", "area");
- //non readied spells
- spellList.Add("1.4.3.1.2.3.", "superArmor");
- //-------------------------------------------------------------------------------------------
- //-------------------------------------------------------------------------------------------
- spellComboList.Add("lightningBolticeSpikeComplex", "IceElecCombo");
- spellComboList.Add("lightningBolt_Level2iceSpikeComplex", "IceElecCombo");
- spellComboList.Add("iceSpikelightningBoltComplex", "IceElecCombo");
- spellComboList.Add("iceSpike_Level2lightningBoltComplex", "IceElecCombo");
- spellComboList.Add("windVortexlightningBoltComplex", "WindElecCombo");
- spellComboList.Add("windVortex_Level2lightningBoltComplex", "WindElecCombo");
- spellComboList.Add("lightningBoltwindVortexComplex", "WindElecCombo");
- spellComboList.Add("lightningBolt_Level2windVortexComplex", "WindElecCombo");
- spellComboList.Add("lightningBoltlightningBolt", "lightningBolt_Level2");
- spellComboList.Add("lightningBoltlightningBoltComplex", "lightningBolt_Level2");
- spellComboList.Add("windVortexwindVortex", "windVortex_Level2");
- spellComboList.Add("windVortexwindVortexComplex", "windVortex_Level2");
- spellComboList.Add("iceSpikeiceSpike", "iceSpike_Level2");
- spellComboList.Add("iceSpikeiceSpikeComplex", "iceSpike_Level2");
- spellComboList.Add("fireballfireball", "fireball_Level2");
- spellComboList.Add("fireballfireballComplex", "fireball_Level2");
- //spell combo mod keys
- spellComboList.Add("fireballhoming", "HomingFire");
- spellComboList.Add("homingfireball", "HomingFire");
- spellComboList.Add("fireball_Level2homing", "HomingFire");
- spellComboList.Add("iceSpikehoming", "murderIce");
- spellComboList.Add("homingiceSpike", "murderIce");
- spellComboList.Add("iceSpike_Level2homing", "murderIce");
- spellComboList.Add("windVortexhoming", "HomingWind");
- spellComboList.Add("homingwindVortex", "HomingWind");
- spellComboList.Add("windVortex_Level2homing", "HomingWind");
- spellComboList.Add("lightningBolthoming", "HomingLightning");
- spellComboList.Add("hominglightningBolt", "HomingLightning");
- spellComboList.Add("lightningBolt_Level2homing", "HomingLightning");
- //------------------------------------------------------------------------------
- // Mana cost tiers
- //------------------------------------------------------------------------------
- level1Spells.Add("lightningBolt");
- level1Spells.Add("windVortex");
- level1Spells.Add("iceSpike");
- level1Spells.Add("fireball");
- level2Spells.Add("lightningBolt_Level2");
- level2Spells.Add("windVortex_Level2");
- level2Spells.Add("iceSpike_Level2");
- level2Spells.Add("fireball_Level2");
- homingSpells.Add("HomingFire");
- homingSpells.Add("murderIce");
- homingSpells.Add("HomingWind");
- homingSpells.Add("HomingLightning");
- }
- public bool CompareInput(ref string spellInput)
- {
- bool goodParse = false;
- foreach (string spellKey in spellList.Keys)
- {
- if (spellKey.StartsWith(spellInput))
- goodParse = true;
- else
- goodParse = false;
- if (goodParse)
- break;
- }
- if (!goodParse) //if the current input doesn't lead to any successful spells, end the casting as a failure
- {
- //drawSpellLine.RejectedSpell(); // change this to some new effect for a rejected spell
- GameMaster.i.player.CastFail();
- return true;
- }
- if (spellList.ContainsKey(spellInput)) //if the current input matches with a spell, do the success animation with the line and push the spell into the prepared list
- {
- if (preparedSpells.Count > 0 && spellComboList.ContainsKey(preparedSpells[0] + spellList[spellInput]))
- {
- CombineSpells(preparedSpells[0], spellList[spellInput]);
- }
- else
- PrepareSpell(spellList[spellInput]); //passing the value for the key in []
- //drawSpellLine.AcceptedSpell(); // new animation for accepted spell
- return true;
- }
- else
- {
- return false;
- }
- }
- public void PrepareSpell(string spell)
- {
- string mod = default;
- switch (spell) //if a complex spell is entered with no spells in queue, change to level 2
- {
- case "lightningBoltComplex":
- spell = "lightningBolt_Level2";
- preparedSpellCost = 0.32f;
- break;
- case "windVortexComplex":
- spell = "windVortex_Level2";
- preparedSpellCost = 0.32f;
- break;
- case "iceSpikeComplex":
- spell = "iceSpike_Level2";
- preparedSpellCost = 0.32f;
- break;
- case "fireballComplex":
- spell = "fireball_Level2";
- preparedSpellCost = 0.32f;
- break;
- default:
- preparedSpellCost = 0.2f;
- break;
- }
- switch (spell)
- {
- case level2Spells.Contains(spell):
- default:
- break;
- }
- preparedSpells.Add(spell);
- source.PlayOneShot(spellPrepAudio);
- if (preparedSpells.Count > preppedSpellLimit)
- {
- preparedSpells.RemoveAt(0);
- spellsPanel.RemoveOldestSpell();
- }
- spellsPanel.ChangeSpellIcon(preparedSpells);
- }
- public void CastElementalSpell()
- {
- if (preparedSpells.Count > 0 && SpellCasting.magicList.ContainsKey(preparedSpells[0]))
- {
- spellCasting.ProceedWithSpell(preparedSpells[0]);
- }
- else
- RemoveReadiedSpell();
- }
- public void OverchargeCastSpell()
- {
- if (level1Spells.Contains(preparedSpells[0]))
- {
- switch (preparedSpells[0])
- {
- case "lightningBolt":
- spellCasting.ProceedWithSpell("lightningBolt_Level2");
- break;
- case "windVortex":
- spellCasting.ProceedWithSpell("windVortex_Level2");
- break;
- case "iceSpike":
- spellCasting.ProceedWithSpell("iceSpike_Level2");
- break;
- case "fireball":
- spellCasting.ProceedWithSpell("fireball_Level2");
- break;
- default:
- spellCasting.ProceedWithSpell(preparedSpells[0]);
- break;
- }
- }
- else
- spellCasting.ProceedWithSpell(preparedSpells[0]);
- }
- public void CombineSpells(string spell1, string spell2)
- {
- string combinedString = spell1 + spell2;
- if (spellComboList.ContainsKey(combinedString))
- {
- source.PlayOneShot(spellPrepAudio);
- preparedSpells.RemoveAt(0);
- preparedSpells.Add(spellComboList[combinedString]);
- spellsPanel.RemoveOldestSpell();
- spellsPanel.ChangeSpellIcon(preparedSpells);
- Debug.Log(spellComboList[combinedString]);
- if (level2Spells.Contains(spellComboList[combinedString]))
- preparedSpellCost = 0.32f;
- else
- preparedSpellCost = 0.48f;
- }
- }
- public void RemoveReadiedSpell()
- {
- if(preparedSpells.Count > 0)
- {
- preparedSpells.RemoveAt(0);
- spellsPanel.RemoveOldestSpell();
- preparedSpellCost = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement