Пример #1
0
        public bool ChangeSwitchStands(int switchNumber)
        {
            switch (switchNumber)
            {
            case 1:
                Switch1.ChangeSwitchState();
                return(true);

            case 2:
                Switch2.ChangeSwitchState();
                return(true);

            case 3:
                Switch3.ChangeSwitchState();
                return(true);

            case 4:
                Switch4.ChangeSwitchState();
                return(true);

            case 5:
                Switch5.ChangeSwitchState();
                return(true);
            }
            return(false);
        }
Пример #2
0
        /* Initialize GPIO, SPI, and the display */
        private async void InitAll()
        {
            try
            {
                await MCP23S17.InitSPI();

                MCP23S17.InitMCP23S17();
                MCP23S17.setPinMode(0x00FF); // 0x0000 = all outputs, 0xffff=all inputs, 0x00FF is PIFace Default
                MCP23S17.pullupMode(0x00FF); // 0x0000 = no pullups, 0xffff=all pullups, 0x00FF is PIFace Default
                MCP23S17.WriteWord(0x0000);  // 0x0000 = no pullups, 0xffff=all pullups, 0x00FF is PIFace Default



                Switch0.AddHandler(PointerPressedEvent, new PointerEventHandler(Switch0_PointerPressed), true);
                Switch0.AddHandler(PointerReleasedEvent, new PointerEventHandler(Switch0_PointerReleased), true);
                Switch1.AddHandler(PointerPressedEvent, new PointerEventHandler(Switch1_PointerPressed), true);
                Switch1.AddHandler(PointerReleasedEvent, new PointerEventHandler(Switch1_PointerReleased), true);
                Switch2.AddHandler(PointerPressedEvent, new PointerEventHandler(Switch2_PointerPressed), true);
                Switch2.AddHandler(PointerReleasedEvent, new PointerEventHandler(Switch2_PointerReleased), true);
                Switch3.AddHandler(PointerPressedEvent, new PointerEventHandler(Switch3_PointerPressed), true);
                Switch3.AddHandler(PointerReleasedEvent, new PointerEventHandler(Switch3_PointerReleased), true);



                initTimer();
            }
            catch (Exception ex)
            {
                //Text_Status.Text = "Exception: " + ex.Message;
                //if (ex.InnerException != null)
                //{
                //    Text_Status.Text += "\nInner Exception: " + ex.InnerException.Message;
                //}
                //return;
            }
        }
Пример #3
0
    // Update is called once per frame
    void Update()
    {
        if (!isDisabled)
        {
            if (Out1.GetComponent <Object_Button_Trigger>().activated == true && !Ignoreinputs && Timer <= 0)
            {
                if (!FloorUp)
                {
                    CloseDoors();
                    Timer        = MovingTime;
                    insideElev   = false;
                    Ignoreinputs = true;
                    soundPlayed  = false;
                }
                else
                {
                    Door1.DoorSwitch();
                }
            }

            if (Out2.GetComponent <Object_Button_Trigger>().activated == true && !Ignoreinputs && Timer <= 0)
            {
                if (FloorUp)
                {
                    CloseDoors();
                    Timer        = MovingTime;
                    insideElev   = false;
                    Ignoreinputs = true;
                    soundPlayed  = false;
                }
                else
                {
                    Door2.DoorSwitch();
                }
            }

            if ((Switch1.GetComponent <Object_Button_Trigger>().activated == true || Switch2.GetComponent <Object_Button_Trigger>().activated == true) && !Ignoreinputs && Timer <= 0)
            {
                //SwitchFloor(Floor1.transform, Floor2.transform);
                CloseDoors();
                Door1.isDisabled = true;
                Door2.isDisabled = true;
                Timer            = MovingTime;
                insideElev       = true;
                Ignoreinputs     = true;
                soundPlayed      = false;
            }
        }


        Timer -= Time.deltaTime;

        if (Timer <= (MovingTime - 2) && !soundPlayed)
        {
            GameController.instance.GlobalSFX.PlayOneShot(elev);
            soundPlayed = true;
        }

        if (Timer <= 3 && Ignoreinputs)
        {
            Door1.isDisabled = false;
            Door2.isDisabled = false;

            FloorUp = !FloorUp;
            State   = !State;
            GameController.instance.SetObjectState(State, id);

            if (insideElev)
            {
                if (FloorUp)
                {
                    StartCoroutine(SwitchFloor(Floor2, Floor1));
                }
                else
                {
                    StartCoroutine(SwitchFloor(Floor1, Floor2));
                }
            }

            if (FloorUp)
            {
                Door1.DoorSwitch();
                GameController.instance.holdRoom = false;
            }
            else
            {
                Door2.DoorSwitch();
                GameController.instance.holdRoom = true;
            }

            GameController.instance.GlobalSFX.PlayOneShot(ding);
            Ignoreinputs = false;
        }
    }