public float Execute() { float total = 0; commandParams.GetTargets().ToList().ForEach(it => { total += DamageOne(commandParams.GetSubject(), it, commandParams.GetSkill()); }); return(total); }
private void ItemSelected(string i) { Debug.Log("ItemSelected"); // Get the item by id ItemSO item = inventory.items.ToList().First(it => it.itemId.Equals(i)); // Create wrapper object with the subject, item and skill related to the item CommandParams newParams = new CommandParams(commandParams.GetSubject(), item, null); // Go to the next state: select one target or attack if (item.targeting.Equals(SINGLE_OPPONENT) || item.targeting.Equals(SINGLE_ALLY)) { base.owner.ChangeState(new SelectOneTargetState(base.owner, newParams)); } else if (item.targeting.Equals(SELF)) { commandParams = new CommandParams(commandParams.GetSubject(), commandParams.GetSubject(), item, null); base.owner.ChangeState(new AttackState(base.owner, commandParams)); } }
public override void OnStateEnter() { bool offensive = false; if (commandParams.GetItem() != null) { offensive = commandParams.GetItem().targeting.Equals(SINGLE_OPPONENT) || commandParams.GetItem().targeting.Equals(MULTIPLE_OPPONENTS); } else if (commandParams.GetSkill() != null) { offensive = commandParams.GetSkill().targeting.Equals(SINGLE_OPPONENT) || commandParams.GetSkill().targeting.Equals(MULTIPLE_OPPONENTS); } else { throw new System.Exception("SelectOneTargetState couldn't infer offensive intention of skill/item."); } targetSelector.Show(UnitUtil.GetUnitsFor(commandParams.GetSubject(), base.owner.allUnits, offensive)); targetSelector.OnTargetClicked += Next; base.owner.UpdateDialogueText("Choose a target."); }
public override void Tick() { if (timer.Progress()) { if (commandParams.GetSkill() != null) { ExecuteSkill(); // Consume mana/energy UnitUtil.SubstractMana(commandParams.GetSubject(), commandParams.GetSkill()); } else if (commandParams.GetItem() != null) { ExecuteItem(); // Consume item UnitUtil.ConsumeItem(owner.GetInventory(), commandParams.GetItem()); } owner.ChangeState(new ApplyBurnState(base.owner)); } }
public float Execute() { // Modifier should take into account resistances/weaknesess float modifier = 1; float power = commandParams.GetSkill().power; // Decide between physical and magical attack+defense bool isMagic = commandParams.GetSkill().isMagical; float attack = isMagic? commandParams.GetSubject().finalMagicAttack : commandParams.GetSubject().finalAttack; float level = commandParams.GetSubject().level; float formulaRes = ((2 * level / 5 + 2) * (power / 50) * (attack / 200) + 2) * modifier; commandParams.GetTargets().ToList().ForEach(it => { if (it.currentStatusEffect.Contains(StatusEffect.DEATH)) { return; // If is dead, do not heal. } new ModifyHPUseCase(it, formulaRes).Execute(); DamageLogger.Add(it.unitId, (int)formulaRes); }); return(formulaRes); }