コード例 #1
0
    void OnCTRWillChange(object sender, object args)
    {
        ValueChangeException exc = args as ValueChangeException;
        MultDeltaModifier    mod = new MultDeltaModifier(0, 2);

        exc.AddModifier(mod);
    }
コード例 #2
0
    void OnCRTWillChange(object sender, object args)
    {
        ValueChangeException exc = args as ValueChangeException;
        MultDeltaModifier    m   = new MultDeltaModifier(0, 1.10f);

        exc.AddModifier(m);
    }
コード例 #3
0
ファイル: Stats.cs プロジェクト: zuig/MyRPG
    public void SetValue(StatTypes type, int value, bool allowExceptions)
    {
        int oldValue = this[type];
        if (oldValue == value)
            return;

        if (allowExceptions)
        {
            // Allow exceptions to the rule here
            ValueChangeException exc = new ValueChangeException( oldValue, value );

            // The notification is unique per stat type
            this.PostNotification(WillChangeNotification(type), exc);

            // Did anything modify the value?
            value = Mathf.FloorToInt(exc.GetModifiedValue());

            // Did something nullify the change?
            if (exc.toggle == false || value == oldValue)
                return;
        }

        _data[(int)type] = value;
        this.PostNotification(DidChangeNotification(type), oldValue);
    }
コード例 #4
0
ファイル: Stats.cs プロジェクト: LautaDS/Tactics-GWJ
    public void SetValue(StatTypes type, int value, bool allowExceptions)
    {
        int oldValue = this[type];

        if (oldValue == value)
        {
            return;
        }

        if (allowExceptions)
        {
            // Allow exceptions to the rule here
            ValueChangeException exc = new ValueChangeException(oldValue, value);

            // The notification is unique per stat type
            this.PostNotification(WillChangeNotification(type), exc);

            // Did anything modify the value?
            value = Mathf.FloorToInt(exc.GetModifiedValue());

            // Did something nullify the change?
            if (exc.toggle == false || value == oldValue)
            {
                return;
            }
        }

        _data[(int)type] = value;
        this.PostNotification(DidChangeNotification(type), oldValue);
    }
コード例 #5
0
    void OnExperienceException(object sender, object args)
    {
        GameObject           actor = (sender as Stats).gameObject;
        ValueChangeException vce   = args as ValueChangeException;
        int roll = UnityEngine.Random.Range(0, 5);

        switch (roll)
        {
        case 0:
            vce.FlipToggle();
            Debug.Log(string.Format("{0} would have received {1} experience, but we stopped it", actor.name, vce.delta));
            break;

        case 1:
            vce.AddModifier(new AddValueModifier(0, 1000));
            Debug.Log(string.Format("{0} would have received {1} experience, but we added 1000", actor.name, vce.delta));
            break;

        case 2:
            vce.AddModifier(new MultValueModifier(0, 2f));
            Debug.Log(string.Format("{0} would have received {1} experience, but we multiplied by 2", actor.name, vce.delta));
            break;

        default:
            Debug.Log(string.Format("{0} will receive {1} experience", actor.name, vce.delta));
            break;
        }
    }
コード例 #6
0
    public void SetValue(StatTypes type, int value, bool allowExceptions)
    {
        int oldValue = this [type];

        if (oldValue == value)
        {
            return;
        }

        if (allowExceptions)
        {
            ValueChangeException exc = new ValueChangeException(oldValue, value);

            this.PostNotification(WillChangeNotification(type), exc);

            value = Mathf.FloorToInt(exc.GetModifiedValue());

            if (exc.toggle == false || value == oldValue)
            {
                return;
            }
        }

        _data [(int)type] = value;
        this.PostNotification(DidChangeNotification(type), oldValue);
    }
コード例 #7
0
    void OnStatCounterWillChange(object sender, object args)
    {
        // Dont allow a KO'd unit to increment the turn order counter
        ValueChangeException exc = args as ValueChangeException;

        if (exc.toValue > exc.fromValue)
        {
            exc.FlipToggle();
        }
    }
コード例 #8
0
    private void OnStatCounterWillChange(object sender, object args)
    {
        // KO'd unit gains no turn counter
        ValueChangeException exc = args as ValueChangeException;

        if (exc.toValue > exc.fromValue)
        {
            exc.FlipToggle();
        }
    }
コード例 #9
0
ファイル: Stats.cs プロジェクト: arthurwoo/TaticsHero
    public void SetValue(StatTypes type, int value, bool allowExceptions)
    {
        int oldVlaue = this [type];
        if (oldVlaue == value)
            return;

        if (allowExceptions) {
            ValueChangeException exc = new ValueChangeException(oldVlaue, value);
            this.PostNotification (WillChangeNotification(type), exc);
            value = Mathf.FloorToInt (exc.GetModifiedValue());

            if(exc.toggle == false || value == oldVlaue)
                return;
        }

        _data [(int)type] = value;
        this.PostNotification (DidChangeNotification (type), oldVlaue);
    }
コード例 #10
0
ファイル: Stats.cs プロジェクト: swejk/2DRPG
    public void SetValue(StatTypes s, float value, bool allowExceptions)
    {
        float oldValue = this[s];
        if (oldValue == value)
        {
            return;
        }

        if (allowExceptions)
        {
            ValueChangeException ve = new ValueChangeException(oldValue, value);
            this.PostNotification(WillChangeNotification(s), ve);
            value = Mathf.FloorToInt(ve.GetModifiedValue());
            if (ve.toggle == false || oldValue == value)
            {
                return;
            }
        }
        
        _data[(int)s] = value;
        this.PostNotification(DidChangeNotification(s), oldValue);
    }
コード例 #11
0
    // handler method for speed counter notification
    void OnCounterWillChange(object sender, object args)
    {
        ValueChangeException exc = args as ValueChangeException;

        exc.FlipToggle();
    }
コード例 #12
0
ファイル: Health.cs プロジェクト: LautaDS/Tactics-GWJ
    void OnHPWillChange(object sender, object args)
    {
        ValueChangeException vce = args as ValueChangeException;

        vce.AddModifier(new ClampValueModifier(int.MaxValue, MinHP, stats[StatTypes.MHP]));
    }
コード例 #13
0
    void OnExpWillChange(object sender, object args)
    {
        ValueChangeException vce = args as ValueChangeException;

        vce.AddModifier(new ClampValueModifier(int.MaxValue, EXP, maxExperience));
    }
コード例 #14
0
    public float SetValue(StatTypes type, float value, bool allowExceptions)
    {
        float oldValue = this[type];

        if (allowExceptions)
        {
            // Allow exceptions to the rule here
            ValueChangeException exc = new ValueChangeException(oldValue, value);

            // The notification is unique per stat type
            this.PostNotification(WillChangeNotification(type), exc);

            // Did anything modify the value?
            value = Mathf.FloorToInt(exc.GetModifiedValue());

            // Did something nullify the change?
            if (exc.toggle == false || value == oldValue)
            {
                return(oldValue);
            }
        }


        if (oldValue == value)
        {
            return(oldValue);
        }

        // Modify value for special cases (ie Health/Mana will not go lower than 0, or higher than MHP/MMP)
        switch (type)
        {
        case StatTypes.HP:
            value = Mathf.Clamp(value, 0, this[StatTypes.MHP]);
            break;

        case StatTypes.MP:
            value = Mathf.Clamp(value, 0, this[StatTypes.MMP]);
            break;
        }

        // Set Value
        _data[(int)type] = value;

        // Wrap up other stat changes affected by value, and send completed notifications
        if (type == StatTypes.DEX)
        {
            if (_data[(int)type] <= 0)
            {
                _data[(int)StatTypes.SPD] = 0;
            }
            else
            {
                _data[(int)StatTypes.SPD] = 1 / _data[(int)type] / 2;
            }
        }


        this.PostNotification(DidChangeNotification(type), oldValue);
        this.PostNotification(UnitUpdateNotification, GetComponent <Unit>());
        return(value);
    }
コード例 #15
0
ファイル: Rank.cs プロジェクト: LautaDS/Tactics-GWJ
    void OnExpWillChange(object sender, object args)
    {
        ValueChangeException vce = args as ValueChangeException;

        vce.AddModifier(new ClampValueModifier(int.MaxValue, EXP, maxExperience)); //the highest possible sort order (to make sure it is the last modifier to be applied)
    }