Exemplo n.º 1
0
        public CoffeeMachine()
        {
            _coffeeMachineStateSaver = new CoffeeMachineStateSaver();
            CoffeeMachineState state = _coffeeMachineStateSaver.Load();

            CounterCappuccino = state.CounterCappuccino;
        }
Exemplo n.º 2
0
        public void Save(string baseId)
        {
            CoffeeMachineState coffeeMachineState = new CoffeeMachineState()
            {
                status               = status,
                currentCoffee        = currentCoffee,
                coffeeSetFromOutside = coffeeSetFromOutside,
                coffeeSize           = coffeeSize,
                coffeeStrength       = coffeeStrength
            };

            SaveLoadSystem.Save <CoffeeMachineState>(coffeeMachineState, baseId, "CoffeeMachine");

            MyLog.TryLog(this, $"Saved", debug);
            MyLog.TryLog(this, JsonConvert.SerializeObject(coffeeMachineState), debug);
        }
    protected override void buildObject(int level)
    {
        base.buildObject(level);

        usettings = upgrades[level];

        indicator.gameObject.SetActive(false);

        indicator.gameObject.transform.Translate(usettings.indicatorOffset.x, usettings.indicatorOffset.y, 0);

        ContentManager.instance.configureObject(indicator, usettings.indicatorAtlasName, "");
        ContentManager.instance.precacheAnimation(indicator, usettings.indicatorAnimationAtlasName);

        _type  = ObjectType.COFFEE_MACHINE;
        _state = CoffeeMachineState.IDLE;
    }
        private string ConvertStateEnumToString(CoffeeMachineState state)
        {
            switch (state)
            {
            case CoffeeMachineState.Brewing:
                return("brewing");

            case CoffeeMachineState.Standby:
                return("standby");

            case CoffeeMachineState.TimedForActivation:
                return("brewingsoon");

            default:
                return("none");
            }
        }
    void setState(CoffeeMachineState state, float delay = -1)
    {
        if (delay == -1)
        {
            switch (state)
            {
            case CoffeeMachineState.IDLE:
                if (_currentProduct != ItemTypes.UNKNOWN)
                {
                    Inventory.instance.addStuf(_currentProduct.ToString());
                    _currentProduct = ItemTypes.UNKNOWN;
                }

                indicator.Stop();
                indicator.gameObject.SetActive(false);
                resetToDefaults();
                break;

            case CoffeeMachineState.WORK_NORMAL:
                break;

            case CoffeeMachineState.WORK_DANGER:
                playTimerAnimation(timerRedAnimation);
                setState(CoffeeMachineState.BROCKEN, usettings.brockenTime);
                break;

            case CoffeeMachineState.BROCKEN:
                _sprite.Stop();

                break;

            default:
                Logger.message(LogLevel.LOG_ERROR, "Unknown coffee machine state - " + state.ToString());
                break;
            }

            _state = state;
        }
        else
        {
            _nextState = state;
            Invoke("onStateChanged", delay);
        }
    }
Exemplo n.º 6
0
        public void Load(string baseId)
        {
            CoffeeMachineState state = SaveLoadSystem.Load <CoffeeMachineState>(baseId, "CoffeeMachine");

            if (state == null)
            {
                state = new CoffeeMachineState();
            }

            currentCoffee        = state.currentCoffee;
            coffeeSetFromOutside = state.coffeeSetFromOutside;
            coffeeStrength       = state.coffeeStrength;
            coffeeSize           = state.coffeeSize;

            if (state.status == Status.Idle || state.status == Status.Busy)
            {
                TurnOn();
            }

            MyLog.TryLog(this, $"Loaded", debug);
            MyLog.TryLog(this, JsonConvert.SerializeObject(state), debug);
        }
Exemplo n.º 7
0
        Boolean coffeeMachineOn()
        {
            Debug.Print("Setting coffeeMachine ON");
            // set state of the device
            coffeeMachineState = CoffeeMachineState.ON;

            // This is needed as the the command may come from orchestrator.js, end hence is run in different thread!
            //Program.BeginInvoke(new DispatcherOperationCallback(delegate
            //{
                onBtnBorder.Background = selectedONAndLoadedBackgroundBrush;
                offBtnBorder.Background = unselectedBackgroundBrush;
                loadedBtnBorder.Background = unselectedBackgroundBrush;

                timeUntilCoffeeReady = COFFEE_MAKE_TIME;
                timeUntilCoffeeReadyTimer = new GT.Timer(1000);
                timeUntilCoffeeReadyTimer.Tick += new GT.Timer.TickEventHandler((timer) =>
                {
                    if (timeUntilCoffeeReady == 0)
                        timerText.TextContent = "coffee ready";
                    else
                        timerText.TextContent = "" + timeUntilCoffeeReady;
                    timeUntilCoffeeReady -= 1;
                    if (timeUntilCoffeeReady < 0) { timeUntilCoffeeReadyTimer.Stop(); }
                });
                timeUntilCoffeeReadyTimer.Start();

                // the actual functionality
                coffeeRelay.TurnOff();

            //    return null;
            //}), "");

            return true;
        }
Exemplo n.º 8
0
        Boolean coffeeMachineOff()
        {
            Debug.Print("coffeeMeachine OFF");

            // set state of the device
            coffeeMachineState = CoffeeMachineState.OFF;

            // This is needed as the the command may come from orchestrator.js, end hence is run in different thread!
            //Program.BeginInvoke(new DispatcherOperationCallback(delegate
            //{
                offBtnBorder.Background = selectedOFFBackgroundBrush;
                onBtnBorder.Background = unselectedBackgroundBrush;
                loadedBtnBorder.Background = unselectedBackgroundBrush;

                timeUntilCoffeeReadyTimer.Stop();
                timerText.TextContent = "off";

                // the actual functionality
                coffeeRelay.TurnOn();

            //    return null;
            //}), "");

            return false;
        }
Exemplo n.º 9
0
        /*
         * This mehtod CANNOT be called from orchestrator.js
         */
        void coffeeMachineLoaded()
        {
            Debug.Print("coffeeMeachine LOADED");
            // set state of the device
            coffeeMachineState = CoffeeMachineState.LOADED;
            offBtnBorder.Background = unselectedBackgroundBrush;
            onBtnBorder.Background = unselectedBackgroundBrush;
            loadedBtnBorder.Background = selectedONAndLoadedBackgroundBrush;

            timeUntilCoffeeReadyTimer.Stop();
            timerText.TextContent = "loaded";

            // the actual functionality
            coffeeRelay.TurnOn();
        }
Exemplo n.º 10
0
 public FavoritesCoffeesController(CoffeeMachineState coffeeMachineState, CoffeeMachineSettings settings)
 {
     this.settings           = settings;
     this.coffeeMachineState = coffeeMachineState;
     currentCoffeeIndex      = -1; // -1 means add coffee page
 }
Exemplo n.º 11
0
    void setState(CoffeeMachineState state, float delay=-1)
    {
        if (delay == -1)
        {
            switch(state)
            {
            case CoffeeMachineState.IDLE:
                if (_currentProduct != ItemTypes.UNKNOWN)
                {
                    Inventory.instance.addStuf(_currentProduct.ToString());
                    _currentProduct = ItemTypes.UNKNOWN;
                }

                indicator.Stop();
                indicator.gameObject.SetActive(false);
                resetToDefaults();
                break;
            case CoffeeMachineState.WORK_NORMAL:
                break;

            case CoffeeMachineState.WORK_DANGER:
                playTimerAnimation(timerRedAnimation);
                setState(CoffeeMachineState.BROCKEN, usettings.brockenTime);
                break;

            case CoffeeMachineState.BROCKEN:
                _sprite.Stop();

                break;

            default:
                Logger.message(LogLevel.LOG_ERROR, "Unknown coffee machine state - "+state.ToString());
                break;
            }

            _state = state;
        }
        else
        {
            _nextState = state;
            Invoke("onStateChanged", delay);
        }
    }
Exemplo n.º 12
0
    protected override void buildObject(int level)
    {
        base.buildObject(level);

        usettings = upgrades[level];

        indicator.gameObject.SetActive(false);

        indicator.gameObject.transform.Translate(usettings.indicatorOffset.x, usettings.indicatorOffset.y, 0);

        ContentManager.instance.configureObject(indicator, usettings.indicatorAtlasName, "");
        ContentManager.instance.precacheAnimation(indicator, usettings.indicatorAnimationAtlasName);

        _type = ObjectType.COFFEE_MACHINE;
        _state = CoffeeMachineState.IDLE;
    }
Exemplo n.º 13
0
 public CoffeeMachine(CoffeeMachineState coffeeMachineState, CoffeeMachineSettings settings, FavoritesCoffeesController favoritesCoffeesController)
 {
     this.coffeeMachineState         = coffeeMachineState;
     this.settings                   = settings;
     this.favoritesCoffeesController = favoritesCoffeesController;
 }