Exemplo n.º 1
0
    public void LoadLevel(int level)
    {
        if (activeSetup != null)
        {
            activeSetup.gameObject.SetActive(false);
        }

        currentLevel = level;
        LevelData data = Resources.Load <LevelData>("Levels/" + level.ToString());

        if (data == null)
        {
            Debug.LogError("No More Levels Available");
            return;
        }

        int pinSetupIndex = data.pins;

        activeSetup = pinsetUps[pinSetupIndex];
        activeSetup.gameObject.SetActive(true);
        stackPins = activeSetup.stackPins;
        activeSetup.fov.CheckFov();
        //Camera.main.orthographicSize = activeSetup.cameraSize;
        Initialize();
        foreach (PinConfig config in data.pinConfig)
        {
            LoadStack(data.stack, config, data.colors);
        }

        stacksToWin = data.stackCount;
        ActionManager.TriggerEvent(GameEvents.STACK_LOAD_COMPLETE, new Hashtable()
        {
            { "level", currentLevel }
        });
    }
Exemplo n.º 2
0
        // -------------------------------------------------------------

        #endregion ctor

        // -------------------------------------------------------------

        #region methods

        // -------------------------------------------------------------

        /**
         * Um einen Wert für den GPIO zu setzen
         *
         * @param[in] _value (bool) true = gpio high; false = gpio low
         *
         * @return (bool) Wenn true zurück gegeben wird gab es keine probleme. Bei false konnte kein wert gesetzt werden
         */
        public bool Write(ValueState _out)
        {
            if (this.setup != PinSetup.Output)
            {
                return(false);
            }
            if (!File.Exists(this.ValuePath))
            {
                return(false);
            }
            if (_out == ValueState.UNKNOWN)
            {
                return(false);
            }

            string value = _out == ValueState.LOW ? "0" : "1";

            try
            {
                File.WriteAllText(this.ValuePath, value);
            }
            catch
            {
                this.setup = PinSetup.None;

                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
        // -------------------------------------------------------------

        #endregion get/set

        // -------------------------------------------------------------

        #region ctor

        // -------------------------------------------------------------

        /**
         * Konstuktor dieser Klasse
         *
         * @param[in] _pin (Pin) Der Pin der diese Instance zugewiesen wird
         * @param[in] _setup (PinSetup) Das Setup mit dem dieser Pin Initialisiert wurde
         */
        public GPIOPin(Pin _pin, PinSetup _setup)
        {
            this.pin   = _pin;
            this.setup = _setup;

            this.Export(  );
        }
Exemplo n.º 4
0
        private void SetConfiguredAction(PinButton pinButton, PinAction pinAction = PinAction.None)
        {
            PinSetup.Hide();
            var pin = (Pin)pinButton.DataContext;

            pin.Value            = 0;
            pin.ConfiguredAction = pinAction;
            SavePinState(pin);
        }
Exemplo n.º 5
0
        // -------------------------------------------------------------

        /**
         * Ändert das Setup für diesen Pin
         *
         * @param[in] _setup (PinSetup) Das neue Setup für diesen Pin
         *
         * @return (bool) true = setup wurde geändert; false = setup konnte nicht geändert werden
         */
        public bool ChangeSetup(PinSetup _setup)
        {
            if (_setup == this.setup)
            {
                return(true);
            }

            this.setup = _setup;

            return(this.SetDirection(  ));
        }
Exemplo n.º 6
0
        // -------------------------------------------------------------

        /**
         * Gibt die Instance für einen Pin wieder
         *
         * @param[in] _pin (Pin) Den Pin für den die Instance abgerufen wird
         * @param[in] _setup (PinSetup) Der Setup für diesen Pin
         *
         * @return (GPIOPin) Die Instance für den abgerufen Pin.
         */
        public GPIOPin SetupOrChangeGPIOPin(Pin _pin, PinSetup _setup)
        {
            GPIOPin result = this[_pin];

            if (result == null)
            {
                result = new GPIOPin(_pin, _setup);

                this.GPIOPins.Add(result);
            }
            else
            {
                result.ChangeSetup(_setup);
            }

            return(result);
        }
Exemplo n.º 7
0
        private void SetupButton(PinButton pinButton)
        {
            var pin = (Pin)pinButton.DataContext;

            PinSetupCaption.Text              = pin.Caption;
            PinSetupAnalogRead.Visibility     = pin.Functions.Contains(PinAction.AnalogRead) ? Visibility.Visible : Visibility.Collapsed;
            PinSetupAnalogWrite.Visibility    = pin.Functions.Contains(PinAction.AnalogWrite) ? Visibility.Visible : Visibility.Collapsed;
            PinSetupAnalogWriteDac.Visibility = pin.Functions.Contains(PinAction.AnalogWriteDac) ? Visibility.Visible : Visibility.Collapsed;
            PinSetupDigitalgRead.Visibility   = pin.Functions.Contains(PinAction.DigitalRead) ? Visibility.Visible : Visibility.Collapsed;
            PinSetupDigitalWrite.Visibility   = pin.Functions.Contains(PinAction.DigitalWrite) ? Visibility.Visible : Visibility.Collapsed;

            PinSetupAnalogRead.DataContext     = pinButton;
            PinSetupAnalogWrite.DataContext    = pinButton;
            PinSetupAnalogWriteDac.DataContext = pinButton;
            PinSetupDigitalgRead.DataContext   = pinButton;
            PinSetupDigitalWrite.DataContext   = pinButton;

            PinSetup.ShowAt(pinButton);
        }
Exemplo n.º 8
0
        // -------------------------------------------------------------

        /**
         * Exportiert einen Pin um ihn zu verwenden
         *
         * @return (bool) true = export erfolgreich; false = fehlgeschlagen
         */
        private bool Export(  )
        {
            if (!File.Exists(this.ValuePath))
            {
                try
                {
                    File.WriteAllText(GPIOController.GPIOPATH_EXPORT, ((int)this.Pin).ToString(  ));
                }
                catch { return(false); }
            }

            bool isok = this.SetDirection(  );

            if (!isok)
            {
                this.setup = PinSetup.None;
            }

            return(isok);
        }
Exemplo n.º 9
0
        // -------------------------------------------------------------

        /**
         * Unexportiert einen Pin um ihn wieder frei zugeben
         *
         * @return (bool) true = unexport efolgreich; false = unexport fehlgeschlagen
         */
        private bool Unexport(  )
        {
            if (this.setup == PinSetup.None)
            {
                return(true);
            }

            this.setup = PinSetup.None;

            if (!File.Exists(this.ValuePath))
            {
                return(true);
            }

            try
            {
                File.WriteAllText(GPIOController.GPIOPATH_UNEXPORT, ((int)this.Pin).ToString(  ));
            }
            catch { return(false); }

            return(true);
        }
Exemplo n.º 10
0
        // -------------------------------------------------------------

        #endregion get/set

        // -------------------------------------------------------------

        #region ctor

        // -------------------------------------------------------------

        /**
         * Konstuktor dieser Klasse
         *
         * @param[in] _pin (Pin) Der Pin der diese Instance zugewiesen wird
         * @param[in] _setup (PinSetup) Der Setup mit dem dieser Pin Initialisiert wurde
         */
        protected GPIO(Pin _pin, PinSetup _setup)
        {
            this.pin = GPIOController.Instance.SetupOrChangeGPIOPin(_pin, _setup);
        }