Esempio n. 1
0
 public virtual void link(ChainLinkData data)
 {
     if (condition.doesPass(data.getData()))
     {
         MLNumericParam passOn = filter.filter(data.getData());
         target_.enforce(passOn);
     }
 }
Esempio n. 2
0
    public void enforce(MLNumericParam _mlnp)
    {
        param = _mlnp;
        gameStateSaver.writeToPrefs(this);
        notifyChainLinks();

        //Editor
        callEditorUpdate();
    }
Esempio n. 3
0
    protected override void performStaticAction(MLNumericParam value)
    {
        Item theItem = item;

        if (giveInfinitely)
        {
            theItem = Instantiate <Item>(item);
        }
        GameManager.Instance.player.inventory.add(theItem);
    }
Esempio n. 4
0
    public bool doesPass(MLNumericParam param)
    {
        switch (type)
        {
        case ConditionType.PASS_ANY:
        default:
            return(true);

        case ConditionType.ONLY_TRUE:
            return(param == true);

        case ConditionType.INT_EQUALS:
            return(param == equalsCondition);

        case ConditionType.FLOAT_GREATER_THAN:
            Debug.Log(string.Format("param: {0} greater than {1} : {2}", param.value_, paramGreaterThan, param.value_ > paramGreaterThan));
            return(param > paramGreaterThan);
        }
    }
Esempio n. 5
0
    public MLNumericParam filter(MLNumericParam param)
    {
        if (debug)
        {
            return(debugFilter((float)param));
        }
        switch (type)
        {
        case FilterType.PASS_AS_IS:
        default:
            return(param);

        case FilterType.FLOAT_TO_BOOL:
            return(param.Bool ? 1f : 0f);

        case FilterType.SCALE_ADD:
            return(param * scale + add);

        case FilterType.SCALE_ADD_MOD:
            return(MLMath.fmod(param * scale + add, mod));

        case FilterType.SCALE_ADD_CLAMP:
            return(Mathf.Clamp(param * scale + add, clampRange.min, clampRange.max));

        case FilterType.SCALE_ADD_MOD_ROUND:
            return(Mathf.Round(MLMath.fmod(param * scale + add, mod)));

        case FilterType.SCALE_ADD_MOD_FLOOR:
            return(Mathf.Floor(MLMath.fmod(param * scale + add, mod)));

        case FilterType.SCALE_ADD_MOD_CEIL:
            return(Mathf.Ceil(MLMath.fmod(param * scale + add, mod)));

        case FilterType.SCALE_ADD_MOD_OFFSET:
            return(MLMath.fmod(param * scale + add, mod) + offset);

        case FilterType.FLOAT_TO_BOOL_INVERT:
            return(param.Bool ? 0f : 1f);

        case FilterType.TRUE_IF_EQUALS_AS_INT:
            return((int)param.value_ == intCompare ? 1f : 0f);
        }
    }
Esempio n. 6
0
    protected float next(MLNumericParam param)
    {
        switch (updateMode)
        {
        case UpdateMode.ONE_VALUE:
        default:
            return(onValue);

        case UpdateMode.TOGGLE_VALUE:
            return(Mathf.Abs(param - onValue) > Mathf.Abs(param - offValue) ? onValue : offValue);

        case UpdateMode.INCREMENT_LOOP:
        case UpdateMode.INCREMENT_PING_PONG:
            return(range.next(param));

        case UpdateMode.USE_Z_ROTATION:
            return(mlGameState.transform.rotation.eulerAngles.z);
        }
    }
Esempio n. 7
0
    private IEnumerator animateTo(MLNumericParam value, Action callback)
    {
        float start         = lerpDelimiter.cursor;
        float end           = value;
        float totalDuration = Mathf.Abs(start - end) * zeroToOneAnimationDuration;
        int   frames        = Mathf.CeilToInt(Mathf.Abs(start - end) * resolution);
        float tick          = totalDuration / resolution;
        float nudge         = (end - start) / resolution;

        for (int i = 1; i <= frames; ++i)
        {
            lerpDelimiter.interp(start + nudge * i);
            yield return(new WaitForSeconds(tick));
        }

        lerpDelimiter.interp(value);
        playAudioFor(end);
        callback.Invoke();
    }
Esempio n. 8
0
    public MLNumericParam fromPrefs(MLGameState mlGameState)
    {
        MLNumericParam param = default(MLNumericParam);

        switch (type)
        {
        case MLGameSavedStateType.DONT_SAVE:
            break;

        case MLGameSavedStateType.SAVE_BOOL:
        case MLGameSavedStateType.SAVE_INT:
            param = new MLNumericParam(PlayerPrefs.GetInt(mlGameState.key));
            break;

        case MLGameSavedStateType.SAVE_FLOAT:
        default:
            param = new MLNumericParam(PlayerPrefs.GetFloat(mlGameState.key));
            break;
        }
        return(param);
    }
Esempio n. 9
0
 protected override void performStaticAction(MLNumericParam value)
 {
     DialogBoss.Instance.load(GetComponent <DialogNode>());
 }
Esempio n. 10
0
 protected abstract void performStaticAction(MLNumericParam value);
 protected override void performStaticAction(MLNumericParam value)
 {
     alpha.gameObject.SetActive(show);
 }
Esempio n. 12
0
 protected override void performStaticAction(MLNumericParam value)
 {
     presenter.present(item.srendrr, () => {
         base.performStaticAction(value);
     });
 }