예제 #1
0
    public override async Task <bool> UseOnMapAsync(IItemUseableMenu menu, Unit user)
    {
        var affected  = false;
        var wasActive = menu.IsActive();

        menu.SetActive(true);
        var target = await menu.SelectUnitTargetAsync();

        if (target != null)
        {
            if (data.restrictRace.Where(x => x == target.Race).Count() == 0)
            {
                affected = false;
            }
            else if (data.maxValue != 0 && target.BaseStats[data.stat] > data.maxValue)
            {
                affected = false;
                // TODO: polish: maybe print an error message?
            }
            else
            {
                affected = true;
                int delta = data.maxGain - data.minGain;
                if (delta > 0)
                {
                    delta = Random.Range(0, delta);
                }
                target.PermanentlyModifyStat(data.stat, data.minGain + delta);
            }
            FinishMapEffect(affected);
        }
        if (affected)
        {
            menu.Repopulate();
            await menu.ConfirmAsync();

            menu.SetActive(wasActive);
        }
        return(affected);
    }
예제 #2
0
    public override async Task <bool> UseOnMapAsync(IItemUseableMenu menu, Unit user)
    {
        var wasActive = menu.IsActive();
        var confirmed = false;
        var affected  = false;

        switch (data.projector)
        {
        case AllyProjectorType.ALLY_PARTY:
        case AllyProjectorType.PLAYER_PARTY_ENEMY_GROUP:
            menu.SelectAll();
            menu.SetActive(true);
            confirmed = await menu.ConfirmSelectionAsync();

            if (confirmed)
            {
                affected = ApplyMapEffect(user, Global.Instance().Data.Party);
                menu.Repopulate();
                await menu.ConfirmAsync();
            }
            menu.SetActive(wasActive);
            return(affected);

        case AllyProjectorType.SINGLE_ALLY:
            menu.SetActive(true);
            while (true)
            {
                var target = await menu.SelectUnitTargetAsync();

                if (target != null)
                {
                    if (!target.IsAlive ^ CanTargetDead())
                    {
                        Global.Instance().Audio.PlaySFX("fail");
                    }
                    else
                    {
                        affected = ApplyMapEffect(user, new Unit[] { target });
                        if (affected)
                        {
                            menu.Repopulate();
                            await menu.ConfirmAsync();

                            menu.SetActive(wasActive);
                            return(true);
                        }
                    }
                }
                else
                {
                    break;
                }
            }
            menu.SetActive(wasActive);
            return(false);

        case AllyProjectorType.USER:
            return(ApplyMapEffect(user, new Unit[] { user }));
        }
        return(false);
    }