protected override void LoadMenu() { catalog = turn.actor.GetComponentInChildren <AbilityCatalog>(); GameObject container = catalog.GetCategory(category); menuTitle = container.name; int count = catalog.AbilityCount(container); if (menuOptions == null) { menuOptions = new List <string>(count); } else { menuOptions.Clear(); } var locks = new bool[count]; for (int i = 0; i < count; ++i) { Ability ability = catalog.GetAbility(category, i); if (ability == null) { throw new Exception("Missing Ability component."); } AbilityManaCost cost = ability.GetComponent <AbilityManaCost>(); if (cost) { menuOptions.Add(string.Format("{0}: {1}", ability.name, cost.amount)); } else { menuOptions.Add(ability.name); } locks[i] = !ability.CanPerform(); } actionMenuPanelController.Show(menuTitle, menuOptions); for (int i = 0; i < count; ++i) { actionMenuPanelController.SetLocked(i, locks[i]); } }
public void Load(CardRecipe data) { AbilityManaCost abilityManaCost = GetComponent <AbilityManaCost>(); if (abilityManaCost == null) { abilityManaCost = gameObject.AddComponent <AbilityManaCost>(); } AbilityEffectTarget abilityEffectTarget = GetComponent <AbilityEffectTarget>(); if (abilityEffectTarget != null) { DestroyImmediate(abilityEffectTarget, true); } BaseAbilityEffect abilityEffect = GetComponent <BaseAbilityEffect>(); if (abilityEffect != null) { DestroyImmediate(abilityEffect, true); } BaseAbilityPower power = GetComponent <BaseAbilityPower>(); if (power != null) { DestroyImmediate(power, true); } AbilityRange range = GetComponent <AbilityRange>(); if (range != null) { DestroyImmediate(range, true); } if (data == null) { Name = ""; Desc = ""; abilityManaCost.amount = 0; abilityEffectTarget = gameObject.AddComponent <DefaultAbilityEffectTarget>(); abilityEffect = gameObject.AddComponent <DamageAbilityEffect>(); power = gameObject.AddComponent <PhysicalAbilityPower>(); power.Power = 0; range = gameObject.AddComponent <ConstantAbilityRange>(); range.horizontal = 0; this.data = Resources.Load("Recipes/CardRecipes/Empty Card Data") as CardRecipe; ID = GetInstanceID(); visualEffect = null; return; } Name = data.Name; Desc = data.Description; abilityManaCost.amount = data.AbilityManaCost; abilityEffectTarget = gameObject.AddComponent(Type.GetType(data.AbilityEffectTarget)) as AbilityEffectTarget; if (data.AbilityEffect.Contains("InflictStatus")) { string ae = "InflictStatusAbilityEffect"; string status = string.Format("{0}StatusEffect", data.AbilityEffect.Substring(13, data.AbilityEffect.Length - 26)); InflictStatusAbilityEffect effect = gameObject.AddComponent(Type.GetType(ae)) as InflictStatusAbilityEffect; effect.statusName = status; abilityEffect = effect; } else { abilityEffect = gameObject.AddComponent(Type.GetType(data.AbilityEffect)) as BaseAbilityEffect; } power = gameObject.AddComponent(Type.GetType(data.AbilityPower)) as BaseAbilityPower; power.Power = data.BasePower; range = gameObject.AddComponent(Type.GetType(data.AbilityRange)) as AbilityRange; range.horizontal = data.AbilityRangeHorizontal; this.data = data; ID = GetInstanceID(); visualEffect = data.ParticleEffect; }