Exemplo n.º 1
0
    //get possible results from events calling addValueToValue and add them to the preview
    public void computeEventResultsPreview(mEvent _mEvent)
    {
        int             eventCnt = _mEvent.GetPersistentEventCount();
        addValueToValue avtv;
        Object          o;

        //check for each persistent call, if it is a 'addValueToValue' script
        for (int i = 0; i < eventCnt; i++)
        {
            //get the type of the persistent object, if it is correct cast it to 'addValueToValue'
            o = _mEvent.GetPersistentTarget(i);
            if (o.GetType() == typeof(addValueToValue))
            {
                avtv = (addValueToValue)o;
            }
            else
            {
                avtv = null;
            }

            if (avtv != null)
            {
                //the object was a 'addValueToValue' script, therefore generate the previews

                previewModifiers.Clear();

                if (avtv.valuesToChange.Length > 0)
                {
                    float rValue = 0f;
                    float diff   = 0f;
                    foreach (addValueToValue.resultModifierForAddingValueToValue valueAddValue in avtv.valuesToChange)
                    {
                        //get the change in the value
                        rValue = valueManager.instance.getFirstFittingValue(valueAddValue.rArgument).value;
                        diff   = rValue * valueAddValue.multiplier;

                        //generate a preview instance the change
                        resultModifierPreview preview = new resultModifierPreview();
                        preview.resultModification = new resultModifier();

                        preview.modificationIsRandomIndependant = true;
                        preview.resultModification.modifier     = valueAddValue.lArgument;                      // get the affected value
                        preview.resultModification.valueAdd     = diff;

                        previewModifiers.Add(preview);

                        //Debug.Log ("added event preview for " + preview.resultModification.modifier.ToString () + ", change is " + diff.ToString ());
                    }
                }

                //Tell the valueManager to tell the ValueScripts to show these previews.
                valueManager.instance.setPreviews(ref previewModifiers);
            }
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// 移除某个事件
    /// </summary>
    public void RemoveEvent(EventEnum ec, mEvent me)
    {
        List <mEvent> lists = null;

        if (events.TryGetValue(ec, out lists))
        {
            if (lists.Contains(me))
            {
                events[ec].Remove(me);
            }
            else
            {
                Debug.LogWarning(TAG + "events dont contain this list " + ec);
            }
        }
        else
        {
            Debug.LogWarning(TAG + "events dont contain this list " + ec);
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// 添加事件
    /// </summary>
    public void AddEvent(EventEnum ec, mEvent me)
    {
        List <mEvent> lists = null;

        if (events.TryGetValue(ec, out lists))
        {
            if (lists.Contains(me))
            {
                return;
            }
            events[ec].Add(me);
        }
        else
        {
            lists = new List <mEvent>
            {
                me
            };
            events.Add(ec, lists);
        }
    }