Esempio n. 1
0
 public RadialGravityState(RadialGravityState that)
 {
     force              = that.force;
     enabled            = that.enabled;
     color              = that.color;
     colliderBodyInside = that.colliderBodyInside;
 }
Esempio n. 2
0
        public void setup(string force, string invertAble, string disableAble, string colors, string initialColor, string radius)
        {
            _initialState = new RadialGravityState {
                enabled = false
            };
            elementInfo.buildInfos();
            var argumentParser = new ArgumentParser("RadialGravityEffector");

            _initialState.force = argumentParser.TryParse <float>(force, float.TryParse);
            _invertAble         = argumentParser.TryParse <bool>(invertAble, bool.TryParse);
            _disableAble        = argumentParser.TryParse <bool>(disableAble, bool.TryParse);
            _initialState.color = argumentParser.TryParse <ElementColor>(initialColor, Enum.TryParse);
            _radius             = argumentParser.TryParse <float>(radius, float.TryParse);

            BoundaryBuilder.Instance.buildCircle(rangeChildren, _radius);
            for (int i = 0; i < rangeChildren.childCount; i++)
            {
                colorChangeAbles.Add(rangeChildren.GetChild(i).GetComponent <SpriteGlowEffect>());
                range.Add(rangeChildren.GetChild(i).GetComponent <SpriteRenderer>());
            }

            if (_disableAble)
            {
                var eventInfo = elementInfo.getEventInfoBySearchTag("on_off");
                effectorEvents.Add(new EffectorEvent(eventInfo.icon,
                                                     () => { Elements.executeVisualChange(this,
                                                                                          () => _currentState.enabled = !_currentState.enabled);
                                                             checkEventManager.checkEvent("AddedEventOn/Off"); }));
            }

            if (_invertAble)
            {
                var eventInfo = elementInfo.getEventInfoBySearchTag("invert");
                effectorEvents.Add(new EffectorEvent(eventInfo.icon,
                                                     () => {
                    var beforeState      = new RadialGravityState(_currentState);
                    _currentState.force *= -1;
                    var afterState       = new RadialGravityState(_currentState);
                    ReplayTimeline.Instance.addVisualEvent(this, beforeState, afterState);
                }));
            }

            foreach (var color in ParseHelper.parseEnumListFromString <ElementColor>(colors))
            {
                var eventInfo = elementInfo.getEventInfoBySearchTag("color_change_" + color.ToString().ToLower());
                effectorEvents.Add(new EffectorEvent(eventInfo.icon,
                                                     () => {
                    Elements.executeVisualChange(this, () => {
                        var savedColor      = color;
                        _currentState.color = savedColor;
                    });
                }));
            }
            _currentState = new RadialGravityState(_initialState);
            setVisualsByState(_currentState);
        }
Esempio n. 3
0
 public void reset()
 {
     _currentState = new RadialGravityState(_initialState);
 }