public void ExecuteAbility(string attackName, Player owner) { //tell ballatack to do something based upon the received attack name. AttackDef d = abilityDict[attackName]; //trigger different ability set based on ability type. switch (d.abilityType) { case 0: //attack print(attackName + " " + owner); ba.TriggerAttack(d, owner); break; case 1: //heal ba.TriggerHeal(d, owner); break; case 2: //Revive ba.TriggerRevive(d, owner); break; case 3: //buff ba.TriggerBuff(d, owner); break; case 4: //debuff ba.TriggerDebuff(d, owner); break; } }
private void ResetAll() { //after the attack has been executed rest all related variables to return play to normal. Time.timeScale = 1; currentAttackDef = null; damaging = false; AOEDamaging = false; AOECol.radius = 0.1f; }
public void TriggerBuff(AttackDef def, Player owner) { //set current user currentAttackDef = def; currentAttacker = owner; //calibrate the attacks values. CalibrateAttack(def); def.TriggerEffect(b); TriggerDefaultAnim(1.0f, def); }
//tells the ball to be damaging for a period. sets the area of effects and other valuable effects. public void CalibrateAttack(AttackDef def) { damaging = true; if (def.GetAOE()) { AOEDamaging = true; AOECol.radius = def.GetAOERadius(); } Invoke("ResetAll", def.GetDuration()); }
//trigger various attack types based upon the ability definition. public void TriggerAttack(AttackDef def, Player owner) { print("Attack TRIGGERED"); //set current user currentAttackDef = def; currentAttacker = owner; //calibrate the attacks values. CalibrateAttack(def); //use attack stats received to set off attack and trigger animation. def.TriggerEffect(b); TriggerDefaultAnim(1.0f, def); }
//establish a dictionary of all attacks possible in the game. This will be called by the attack function based upon the playercards attack strings. private void Start() { ba = FindObjectOfType <BallAttack>(); abilityTypeDict.Add("Attack", 0); abilityTypeDict.Add("Heal", 1); abilityTypeDict.Add("Revive", 2); abilityTypeDict.Add("Buff", 3); abilityTypeDict.Add("Debuff", 4); AEFlamestrike flameStrike = new AEFlamestrike(); AEDragonkick dragonKick = new AEDragonkick(); AttackDef fs = new AttackDef("FlameStrike", GameManager.Instance.AIActions["Attack"], abilityTypeDict["Attack"], 1.2f, 35, 23, true, 15, 1.5f, flameStrike); AttackDef dk = new AttackDef("DragonKick", GameManager.Instance.AIActions["Attack"], abilityTypeDict["Attack"], 1.2f, 34, 0, false, 0, 1.5f, dragonKick); print(fs + " " + dk); //this could potentially be exposed via a public array of these enteries. maybe? abilityDict.Add("FlameStrike", fs); abilityDict.Add("DragonKick", dk); }
/// <summary> /// the default animation for an attack being a slow, zoom and background dim. /// </summary> /// <param name="duration">how long should DefaultAnim last?</param> public void TriggerDefaultAnim(float duration, AttackDef def) { print("AnimTriggered"); //darken the screen to focus the player on the attack. StartCoroutine(FadeTo(0.5f, GameManager.Instance.universalAnimationDuration)); //slow the time down to add to the effect of the attack Time.timeScale = 0.2f; //manage the ability plate. this will pass vluable info to the player. abilityPlaque.color = new Color(1, 1, 1, 1); abilityTitle.color = new Color(0, 0, 0, 1); abilityTitle.text = def.name; //pause the ball. ballBody.Pause(); b.PauseBall(); Invoke("Unpause", GameManager.Instance.universalAnimationDuration); Invoke("ResetAllEffects", def.GetDuration()); }