예제 #1
0
        public void setup(string disableAble, string initialEnabled, string colors, string initialColor,
                          string differenceX, string differenceY, string differenceAngle, string length)
        {
            _initialState = new TeleporterState {
                enabled = false
            };
            elementInfo.buildInfos();
            var argumentParser = new ArgumentParser("ColorChanger");

            _disableAble          = argumentParser.TryParse <bool>(disableAble, bool.TryParse);
            _initialState.enabled = argumentParser.TryParse <bool>(initialEnabled, bool.TryParse);
            _initialState.color   = argumentParser.TryParse <ElementColor>(initialColor, Enum.TryParse);

            _difference = new Vector2(0, 0)
            {
                x = argumentParser.TryParse <float>(differenceX, float.TryParse),
                y = argumentParser.TryParse <float>(differenceY, float.TryParse)
            };
            _differenceAngle = argumentParser.TryParse <float>(differenceAngle, float.TryParse);
            _length          = argumentParser.TryParse <float>(length, float.TryParse);

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

            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;
                    });
                    checkEventManager.checkEvent("AddedEvent" + eventInfo.eventName);
                }));
            }
            _currentState = new TeleporterState(_initialState);

            outputTransform.position      = transform.position + _difference;
            outputTransform.localRotation = Quaternion.Euler(0, 0, _differenceAngle);

            gates.ForEach(gateTransform => gateTransform.localScale = new Vector2(gateTransform.localScale.x, _length));

            setVisualsByState(_currentState);
        }
예제 #2
0
 public TeleporterState(TeleporterState that)
 {
     enabled = that.enabled;
     color   = that.color;
 }
예제 #3
0
 public void reset()
 {
     _currentState = new TeleporterState(_initialState);
 }