Exemplo n.º 1
0
        private IArea createArea(string id, IMask mask, bool isWalkable = false, bool isWalkBehind = false)
        {
            TypedParameter idParam = new TypedParameter(typeof(string), id);
            IArea          area    = _resolver.Container.Resolve <IArea>(idParam);

            area.Mask = mask;
            if (isWalkable)
            {
                area.AddComponent <IWalkableArea>();
            }
            if (isWalkBehind)
            {
                area.AddComponent <IWalkBehindArea>();
            }
            return(area);
        }
Exemplo n.º 2
0
        public static IArea WithRollerShutter(this IArea area, Enum id, IBinaryOutput powerOutput, IBinaryOutput directionOutput)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }

            if (powerOutput == null)
            {
                throw new ArgumentNullException(nameof(powerOutput));
            }
            if (directionOutput == null)
            {
                throw new ArgumentNullException(nameof(directionOutput));
            }

            var rollerShutter = new RollerShutter(
                ComponentIdFactory.Create(area.Id, id),
                new PortBasedRollerShutterEndpoint(powerOutput, directionOutput),
                area.Controller.Timer,
                area.Controller.ServiceLocator.GetService <ISchedulerService>());

            area.AddComponent(rollerShutter);
            return(area);
        }
Exemplo n.º 3
0
        public static void Create(IArea area, float minZoom, float maxZoom)
        {
            var component = area.AddComponent <IZoomArea>();

            component.MinZoom = minZoom;
            component.MaxZoom = maxZoom;
        }
Exemplo n.º 4
0
        public IRollerShutter RegisterRollerShutter(IArea area, Enum id, IBinaryOutput powerOutput, IBinaryOutput directionOutput)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }
            if (powerOutput == null)
            {
                throw new ArgumentNullException(nameof(powerOutput));
            }
            if (directionOutput == null)
            {
                throw new ArgumentNullException(nameof(directionOutput));
            }

            var rollerShutter = new RollerShutter(
                ComponentIdGenerator.Generate(area.Id, id),
                new PortBasedRollerShutterEndpoint(powerOutput, directionOutput),
                _timerService,
                _schedulerService,
                _settingsService);

            area.AddComponent(rollerShutter);

            return(rollerShutter);
        }
Exemplo n.º 5
0
        public void Show()
        {
            _shouldAnimate = true;
            var player = _game.State.Player;

            _playerAsFeature = new PlayerAsFeature(player);

            var factory = _game.Factory;

            _label = factory.UI.GetLabel("MoveAreaLabel", "Try Walking!", 100f, 30f, 10f, _parent.Height - 30f, _parent);

            _checkbox                  = factory.UI.GetCheckBox("MoveAreaCheckbox", (ButtonAnimation)null, null, null, null, 10f, _parent.Height - 60f, _parent, "Bind Area & Character", width: 20f, height: 20f);
            _checkbox.Checked          = true;
            _shouldBindAreaToCharacter = true;
            _checkbox.OnCheckChanged.Subscribe(onBindChanged);

            _elevator = factory.Object.GetObject("Elevator Parent");
            _elevator.TreeNode.SetParent(_parent.TreeNode);
            _elevator.RenderLayer = _parent.RenderLayer;
            _elevator.Image       = new EmptyImage(1f, 1f);
            _elevator.Opacity     = 0;
            _elevator.Position    = (200f, 100f);

            var areaParent = factory.Object.GetObject("Elevator Area Parent");

            areaParent.TreeNode.SetParent(_elevator.TreeNode);
            areaParent.RenderLayer = _parent.RenderLayer;

            _playerAsFeature.PlaceInFeatureWindow(_elevator);

            bool[,] maskArr = new bool[200, 200];
            var mask = factory.Masks.Load(maskArr, "Elevator Mask", true, Colors.GreenYellow.WithAlpha(150));

            _area = factory.Room.GetArea("Elevator Area", mask, null, true);
            _area.Mask.DebugDraw.TreeNode.SetParent(areaParent.TreeNode);
            _area.Mask.DebugDraw.RenderLayer = _parent.RenderLayer;
            var areaTranslate = _area.AddComponent <ITranslateComponent>();
            var areaRotate    = _area.AddComponent <IRotateComponent>();

            player.Room.Areas.Add(_area);
            player.PlaceOnWalkableArea();
            player.Z            = _area.Mask.DebugDraw.Z - 1;
            _scheme.CurrentMode = RotatingCursorScheme.WALK_MODE;

            animate(_elevator, areaTranslate, areaRotate);
        }
Exemplo n.º 6
0
        public LogicalBinaryStateActuator RegisterLogicalActuator(IArea area, Enum id)
        {
            if (area == null) throw new ArgumentNullException(nameof(area));

            var actuator = new LogicalBinaryStateActuator(ComponentIdGenerator.Generate(area.Id, id), _timerService);
            area.AddComponent(actuator);

            return actuator;
        }
Exemplo n.º 7
0
		public static void Create(IArea area, float minScaling, float maxScaling, bool scaleObjectsX = true, bool scaleObjectsY = true, bool scaleVolume = true)
		{
            var component = area.AddComponent<IScalingArea>();
            component.MinScaling = minScaling;
            component.MaxScaling = maxScaling;
            component.ScaleObjectsX = scaleObjectsX;
            component.ScaleObjectsY = scaleObjectsY;
            component.ScaleVolume = scaleVolume;
		}
Exemplo n.º 8
0
        public ILamp RegisterLamp(IArea area, Enum id, IBinaryOutput output)
        {
            if (area == null) throw new ArgumentNullException(nameof(area));
            if (output == null) throw new ArgumentNullException(nameof(output));

            var lamp = new Lamp(ComponentIdGenerator.Generate(area.Id, id), new PortBasedBinaryStateEndpoint(output));
            area.AddComponent(lamp);

            return lamp;
        }
Exemplo n.º 9
0
        public static void Create(IArea area, float minScaling, float maxScaling, bool scaleObjectsX = true, bool scaleObjectsY = true, bool scaleVolume = true)
        {
            var component = area.AddComponent <IScalingArea>();

            component.MinScaling    = minScaling;
            component.MaxScaling    = maxScaling;
            component.ScaleObjectsX = scaleObjectsX;
            component.ScaleObjectsY = scaleObjectsY;
            component.ScaleVolume   = scaleVolume;
        }
Exemplo n.º 10
0
        public IHumiditySensor RegisterHumiditySensor(IArea area, Enum id, INumericValueSensorEndpoint endpoint)
        {
            if (area == null) throw new ArgumentNullException(nameof(area));
            if (endpoint == null) throw new ArgumentNullException(nameof(endpoint));

            var humditySensor = new HumiditySensor(ComponentIdGenerator.Generate(area.Id, id), _settingsService, endpoint);
            area.AddComponent(humditySensor);

            return humditySensor;
        }
Exemplo n.º 11
0
        public static LogicalBinaryStateActuator CombineActuators(this IArea area, Enum id)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }

            var actuator = new LogicalBinaryStateActuator(ComponentIdFactory.Create(area.Id, id), area.Controller.Timer);

            area.AddComponent(actuator);
            return(actuator);
        }
Exemplo n.º 12
0
        public LogicalBinaryStateActuator RegisterLogicalActuator(IArea area, Enum id)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }

            var actuator = new LogicalBinaryStateActuator(ComponentIdGenerator.Generate(area.Id, id), _timerService);

            area.AddComponent(actuator);

            return(actuator);
        }
Exemplo n.º 13
0
        public static IArea WithTemperatureSensor(this IArea area, Enum id, INumericValueSensorEndpoint endpoint)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }
            if (endpoint == null)
            {
                throw new ArgumentNullException(nameof(endpoint));
            }

            area.AddComponent(new TemperatureSensor(ComponentIdFactory.Create(area.Id, id), endpoint));
            return(area);
        }
Exemplo n.º 14
0
        public IButton RegisterVirtualButton(IArea area, Enum id, Action <IButton> initializer = null)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }

            var virtualButton = new Button(ComponentIdGenerator.Generate(area.Id, id), new EmptyButtonEndpoint(), _timerService, _settingsService);

            initializer?.Invoke(virtualButton);

            area.AddComponent(virtualButton);
            return(virtualButton);
        }
Exemplo n.º 15
0
        public static IArea WithVirtualButton(this IArea area, Enum id, Action <IButton> initializer = null)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }

            var virtualButton = new Button(ComponentIdFactory.Create(area.Id, id), new EmptyButtonEndpoint(), area.Controller.Timer);

            initializer?.Invoke(virtualButton);

            area.AddComponent(virtualButton);
            return(area);
        }
Exemplo n.º 16
0
        public static IArea WithRollerShutterButtons(
            this IArea area,
            Enum upId,
            IBinaryInput upInput,
            Enum downId,
            IBinaryInput downInput)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }
            if (upInput == null)
            {
                throw new ArgumentNullException(nameof(upInput));
            }
            if (downInput == null)
            {
                throw new ArgumentNullException(nameof(downInput));
            }

            var upButton = new Button(
                ComponentIdFactory.Create(area.Id, upId),
                new PortBasedButtonEndpoint(upInput),
                area.Controller.Timer);

            area.AddComponent(upButton);

            var downButton = new Button(
                ComponentIdFactory.Create(area.Id, downId),
                new PortBasedButtonEndpoint(downInput),
                area.Controller.Timer);

            area.AddComponent(downButton);

            return(area);
        }
Exemplo n.º 17
0
        public void RegisterRollerShutterButtons(
            IArea area,
            Enum upId,
            IBinaryInput upInput,
            Enum downId,
            IBinaryInput downInput)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }
            if (upInput == null)
            {
                throw new ArgumentNullException(nameof(upInput));
            }
            if (downInput == null)
            {
                throw new ArgumentNullException(nameof(downInput));
            }

            var upButton = new Button(
                ComponentIdGenerator.Generate(area.Id, upId),
                new PortBasedButtonEndpoint(upInput),
                _timerService,
                _settingsService);

            area.AddComponent(upButton);

            var downButton = new Button(
                ComponentIdGenerator.Generate(area.Id, downId),
                new PortBasedButtonEndpoint(downInput),
                _timerService,
                _settingsService);

            area.AddComponent(downButton);
        }
Exemplo n.º 18
0
        public IMotionDetector RegisterMotionDetector(IArea area, Enum id, IBinaryInput input)
        {
            if (area == null) throw new ArgumentNullException(nameof(area));
            if (input == null) throw new ArgumentNullException(nameof(input));

            var motionDetector = new MotionDetector(
                ComponentIdGenerator.Generate(area.Id, id),
                new PortBasedMotionDetectorEndpoint(input),
                _schedulerService,
                _settingsService);

            area.AddComponent(motionDetector);

            return motionDetector;
        }
Exemplo n.º 19
0
        public IButton RegisterButton(IArea area, Enum id, IBinaryInput input, Action<IButton> initializer = null)
        {
            if (area == null) throw new ArgumentNullException(nameof(area));
            if (input == null) throw new ArgumentNullException(nameof(input));

            var button = new Button(
                ComponentIdGenerator.Generate(area.Id, id),
                new PortBasedButtonEndpoint(input),
                _timerService,
                _settingsService);

            initializer?.Invoke(button);

            area.AddComponent(button);
            return button;
        }
Exemplo n.º 20
0
        public static IArea WithLamp(this IArea area, Enum id, IBinaryOutput output)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }
            if (output == null)
            {
                throw new ArgumentNullException(nameof(output));
            }

            var lamp = new Lamp(ComponentIdFactory.Create(area.Id, id), new PortBasedBinaryStateEndpoint(output));

            area.AddComponent(lamp);

            return(area);
        }
Exemplo n.º 21
0
        public IHumiditySensor RegisterHumiditySensor(IArea area, Enum id, INumericValueSensorEndpoint endpoint)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }
            if (endpoint == null)
            {
                throw new ArgumentNullException(nameof(endpoint));
            }

            var humditySensor = new HumiditySensor(ComponentIdGenerator.Generate(area.Id, id), _settingsService, endpoint);

            area.AddComponent(humditySensor);

            return(humditySensor);
        }
Exemplo n.º 22
0
        public ILamp RegisterLamp(IArea area, Enum id, IBinaryOutput output)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }
            if (output == null)
            {
                throw new ArgumentNullException(nameof(output));
            }

            var lamp = new Lamp(ComponentIdGenerator.Generate(area.Id, id), new PortBasedBinaryStateEndpoint(output));

            area.AddComponent(lamp);

            return(lamp);
        }
Exemplo n.º 23
0
        public IRollerShutter RegisterRollerShutter(IArea area, Enum id, IBinaryOutput powerOutput, IBinaryOutput directionOutput)
        {
            if (area == null) throw new ArgumentNullException(nameof(area));
            if (powerOutput == null) throw new ArgumentNullException(nameof(powerOutput));
            if (directionOutput == null) throw new ArgumentNullException(nameof(directionOutput));

            var rollerShutter = new RollerShutter(
                ComponentIdGenerator.Generate(area.Id, id),
                new PortBasedRollerShutterEndpoint(powerOutput, directionOutput),
                _timerService,
                _schedulerService,
                _settingsService);

            area.AddComponent(rollerShutter);

            return rollerShutter;
        }
Exemplo n.º 24
0
        public ISocket RegisterSocket(IArea area, Enum id, IBinaryOutput output)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }
            if (output == null)
            {
                throw new ArgumentNullException(nameof(output));
            }

            var socket = new Socket(ComponentIdGenerator.Generate(area.Id, id), new PortBasedBinaryStateEndpoint(output));

            area.AddComponent(socket);

            return(socket);
        }
Exemplo n.º 25
0
        public static IArea WithWindow(this IArea area, Enum id, Action <Window> initializer)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }
            if (initializer == null)
            {
                throw new ArgumentNullException(nameof(initializer));
            }

            var window = new Window(ComponentIdFactory.Create(area.Id, id));

            initializer(window);

            area.AddComponent(window);
            return(area);
        }
Exemplo n.º 26
0
        public IWindow RegisterWindow(IArea area, Enum id, Action <Window> initializer)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }
            if (initializer == null)
            {
                throw new ArgumentNullException(nameof(initializer));
            }

            var window = new Window(ComponentIdGenerator.Generate(area.Id, id), _settingsService);

            initializer(window);

            area.AddComponent(window);
            return(window);
        }
Exemplo n.º 27
0
        public static IArea WithMotionDetector(this IArea area, Enum id, IBinaryInput input)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            var motionDetector = new MotionDetector(
                ComponentIdFactory.Create(area.Id, id),
                new PortBasedMotionDetectorEndpoint(input),
                area.Controller.ServiceLocator.GetService <ISchedulerService>());

            area.AddComponent(motionDetector);
            return(area);
        }
Exemplo n.º 28
0
        public IStateMachine RegisterStateMachine(IArea area, Enum id, Action <StateMachine, IArea> initializer)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }
            if (initializer == null)
            {
                throw new ArgumentNullException(nameof(initializer));
            }

            var stateMachine = new StateMachine(ComponentIdGenerator.Generate(area.Id, id));

            initializer(stateMachine, area);
            stateMachine.SetInitialState(BinaryStateId.Off);

            area.AddComponent(stateMachine);
            return(stateMachine);
        }
Exemplo n.º 29
0
        public static IArea WithStateMachine(this IArea area, Enum id, Action <StateMachine, IArea> initializer)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }
            if (initializer == null)
            {
                throw new ArgumentNullException(nameof(initializer));
            }

            var stateMachine = new StateMachine(
                ComponentIdFactory.Create(area.Id, id));

            initializer(stateMachine, area);
            stateMachine.SetInitialState(BinaryStateId.Off);

            area.AddComponent(stateMachine);
            return(area);
        }
Exemplo n.º 30
0
        public IMotionDetector RegisterMotionDetector(IArea area, Enum id, IBinaryInput input)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            var motionDetector = new MotionDetector(
                ComponentIdGenerator.Generate(area.Id, id),
                new PortBasedMotionDetectorEndpoint(input),
                _schedulerService,
                _settingsService);

            area.AddComponent(motionDetector);

            return(motionDetector);
        }
Exemplo n.º 31
0
        public static IArea WithButton(this IArea area, Enum id, IBinaryInput input, Action <IButton> initializer = null)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            var button = new Button(
                ComponentIdFactory.Create(area.Id, id),
                new PortBasedButtonEndpoint(input),
                area.Controller.Timer);

            initializer?.Invoke(button);

            area.AddComponent(button);
            return(area);
        }
Exemplo n.º 32
0
        public IButton RegisterButton(IArea area, Enum id, IBinaryInput input, Action <IButton> initializer = null)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            var button = new Button(
                ComponentIdGenerator.Generate(area.Id, id),
                new PortBasedButtonEndpoint(input),
                _timerService,
                _settingsService);

            initializer?.Invoke(button);

            area.AddComponent(button);
            return(button);
        }
Exemplo n.º 33
0
        public IStateMachine RegisterStateMachine(IArea area, Enum id, Action<StateMachine, IArea> initializer)
        {
            if (area == null) throw new ArgumentNullException(nameof(area));
            if (initializer == null) throw new ArgumentNullException(nameof(initializer));

            var stateMachine = new StateMachine(ComponentIdGenerator.Generate(area.Id, id));

            initializer(stateMachine, area);
            stateMachine.SetInitialState(BinaryStateId.Off);

            area.AddComponent(stateMachine);
            return stateMachine;
        }
Exemplo n.º 34
0
 public static void Create(IArea area, float minZoom, float maxZoom)
 {
     var component = area.AddComponent<IZoomArea>();
     component.MinZoom = minZoom;
     component.MaxZoom = maxZoom;
 }
Exemplo n.º 35
0
        public IButton RegisterVirtualButton(IArea area, Enum id, Action<IButton> initializer = null)
        {
            if (area == null) throw new ArgumentNullException(nameof(area));

            var virtualButton = new Button(ComponentIdGenerator.Generate(area.Id, id), new EmptyButtonEndpoint(), _timerService, _settingsService);
            initializer?.Invoke(virtualButton);

            area.AddComponent(virtualButton);
            return virtualButton;
        }
Exemplo n.º 36
0
        public IWindow RegisterWindow(IArea area, Enum id, Action<Window> initializer)
        {
            if (area == null) throw new ArgumentNullException(nameof(area));
            if (initializer == null) throw new ArgumentNullException(nameof(initializer));

            var window = new Window(ComponentIdGenerator.Generate(area.Id, id), _settingsService);
            initializer(window);

            area.AddComponent(window);
            return window;
        }
Exemplo n.º 37
0
        public void RegisterRollerShutterButtons(
            IArea area,
            Enum upId,
            IBinaryInput upInput,
            Enum downId,
            IBinaryInput downInput)
        {
            if (area == null) throw new ArgumentNullException(nameof(area));
            if (upInput == null) throw new ArgumentNullException(nameof(upInput));
            if (downInput == null) throw new ArgumentNullException(nameof(downInput));

            var upButton = new Button(
                ComponentIdGenerator.Generate(area.Id, upId),
                new PortBasedButtonEndpoint(upInput),
                _timerService,
                _settingsService);

            area.AddComponent(upButton);

            var downButton = new Button(
                ComponentIdGenerator.Generate(area.Id, downId),
                new PortBasedButtonEndpoint(downInput),
                _timerService,
                _settingsService);

            area.AddComponent(downButton);
        }
Exemplo n.º 38
0
        public ISocket RegisterSocket(IArea area, Enum id, IBinaryOutput output)
        {
            if (area == null) throw new ArgumentNullException(nameof(area));
            if (output == null) throw new ArgumentNullException(nameof(output));

            var socket = new Socket(ComponentIdGenerator.Generate(area.Id, id), new PortBasedBinaryStateEndpoint(output));
            area.AddComponent(socket);

            return socket;
        }