Exemplo n.º 1
0
 private void OnMouseDown()
 {
     if (!isNear)
     {
         return;
     }
     if (playerManager.handPizza.activeInHierarchy && GetOvenStatus == ovenStatus.empty)
     {
         CookPizza(playerManager.handPizza.transform);
     }
     else if (GetPizzaStatus != pizzaStatus.notCooked && !playerManager.hasProduct && !playerManager.handPizza.activeInHierarchy)
     {
         if (GetPizzaStatus == pizzaStatus.cooked)
         {
             cookedPizza.SetActive(true);
         }
         else if (GetPizzaStatus == pizzaStatus.burnt)
         {
             playerManager.BurntPizza.SetActive(true);
         }
         GreenLight.SetActive(false);
         redLight.SetActive(false);
         GetOvenStatus = ovenStatus.empty;
         playerManager.CurrentPizzaIndex = OvenIndex;
         playerManager.recipeCheckCount  = tempCount;
         StopAllCoroutines();
     }
 }
Exemplo n.º 2
0
        public TrafficLight()
        {
            InitializeComponent();
            CurrentPhase = TrafficPhase.Go;

            RedLight.SetState(LampState.Off);
            YellowLight.SetState(LampState.Off);
            GreenLight.SetState(LampState.On);
        }
Exemplo n.º 3
0
    public void SetLight(Color color)
    {
        if (color == Color.red)
        {
            Light = LightType.Red;
            RedLight.SetActive(true);
            GreenLight.SetActive(false);
        }

        if (color == Color.green)
        {
            Light = LightType.Green;
            RedLight.SetActive(false);
            GreenLight.SetActive(true);
        }
    }
Exemplo n.º 4
0
        int curLightIndex;                   //当前所亮的灯

        //public event LightChanged()  ;//事件



        private void UserControl_Resize()
        {
            // 变换灯的大小
            int w, h, d;

            w = this.Width;
            h = this.Height;
            d = w / 4;
            if (d > h)
            {
                d = h;
            }
            RedLight.Move(d / 4, (h - d) / 2, d, d);
            YellowLight.Move(d + d / 2, (h - d) / 2, d, d);
            GreenLight.Move(2 * d + 3 * d / 4, (h - d) / 2, d, d);
        }
Exemplo n.º 5
0
    IEnumerator OvenTimer()
    {
        int i = 0;

        while (i < 45)
        {
            i++;
            if (i == 30)
            {
                GreenLight.SetActive(true);
                GetPizzaStatus = pizzaStatus.cooked;
            }
            yield return(new WaitForSeconds(1f));
        }
        GreenLight.SetActive(false);
        redLight.SetActive(true);
        GetPizzaStatus = pizzaStatus.burnt;
    }
Exemplo n.º 6
0
        private async void ToggleLightsTask(Border control, int waitMillis)
        {
            void action()
            {
                if (GreenLight.Equals(control))
                {
                    ToggleGreen();
                }
                else if (RedLight.Equals(control))
                {
                    ToggleRed();
                }
            };

            for (int i = 0; i < 2; i++)
            {
                Dispatcher.Invoke(action);
                await Task.Delay(waitMillis).ConfigureAwait(false);
            }
        }
 private void Awake()
 {
     greenLight  = new GreenLight(this);
     yellowLight = new YellowLight(this);
     redLight    = new RedLight(this);
     foreach (Transform go in GetComponentsInChildren <Transform>())
     {
         if (go.name == "GreenLight")
         {
             greenLight.gLightBulb = go.gameObject;
         }
         if (go.name == "YellowLight")
         {
             yellowLight.yLightBulb = go.gameObject;
         }
         if (go.name == "RedLight")
         {
             redLight.rLightBulb = go.gameObject;
         }
     }
 }
Exemplo n.º 8
0
        private void LightTimer_Tick(object sender, EventArgs e)
        {
            //Attention phase
            if (CurrentPhase == TrafficPhase.Go)
            {
                CurrentPhase = TrafficPhase.Attention;
                RedLight.SetState(LampState.Off);
                YellowLight.SetState(LampState.On);
                GreenLight.SetState(LampState.Off);
                LightTimer.Interval = 3000;
            }
            //Stop phase
            else if (CurrentPhase == TrafficPhase.Attention)
            {
                CurrentPhase = TrafficPhase.Stop;
                RedLight.SetState(LampState.On);
                YellowLight.SetState(LampState.Off);//LightStateOff();
                GreenLight.SetState(LampState.Off);
                LightTimer.Interval = 6000;
            }
            //Prepare Phase

            else if (CurrentPhase == TrafficPhase.Stop)
            {
                CurrentPhase = TrafficPhase.Prepare;
                RedLight.SetState(LampState.On);
                YellowLight.SetState(LampState.On);
                GreenLight.SetState(LampState.Off);
                LightTimer.Interval = 2000;
            }
            else if (CurrentPhase == TrafficPhase.Prepare)
            {
                CurrentPhase = TrafficPhase.Go;
                RedLight.SetState(LampState.Off);
                YellowLight.SetState(LampState.Off);
                GreenLight.SetState(LampState.On);
                LightTimer.Stop();
            }
        }
Exemplo n.º 9
0
        public async void ToggleState()
        {
            if (TrafficTrafficState == TrafficState.STOP)
            {
                TrafficTrafficState = TrafficLight.TrafficState.READY;

                await Task.Delay(4000);

                TrafficTrafficState = TrafficLight.TrafficState.GO;
                RedLight.ToggleState();
                GreenLight.ToggleState();
                return;
            }

            TrafficTrafficState = TrafficState.READY;
            GreenLight.ToggleState();
            YellowLight.ToggleState();
            await Task.Delay(3000);

            TrafficTrafficState = TrafficState.STOP;
            YellowLight.ToggleState();
            RedLight.ToggleState();
        }
Exemplo n.º 10
0
        public new async Task ToggleState()
        {
            if (TrafficTrafficState == TrafficLight.TrafficState.STOP)
            {
                TrafficTrafficState = TrafficLight.TrafficState.READY;

                await Task.Delay(4000);

                TrafficTrafficState = TrafficLight.TrafficState.GO;
                RedLight.ToggleState();
                GreenLight.ToggleState();
                return;
            }

            TrafficTrafficState = TrafficLight.TrafficState.READY;
            GreenLight.ToggleState();
            await Blink(3000, 300, RedLight);

            TrafficTrafficState = TrafficState.STOP;
            if (!RedLight.IsActive)
            {
                RedLight.ToggleState();
            }
        }
Exemplo n.º 11
0
        private static unsafe void Main(string[] args)
        {
            var options = new EngineOptions(
                "simple 3d game",
                720, 1280,
                true,
                UiResourcesHelper.PressStart2PFontPath,
                UiResourcesHelper.CrossSpritePath,
                UiResourcesHelper.ScrollSpritePath);

            using var engine = EngineBuilder.BuildEngine25D(options);
            var resourceLoader = ResourceCachedLoader.Instance;
            var player         = new MyPlayer(new Vector2(2.0f, 2.0f), new Vector2(0.3f, 0.3f), MathF.PI / 2, 10);
            var wallTexture    = Sprite.Load("./sprites/greystone.png");
            var floorTexture   = Sprite.Load("./sprites/colorstone.png");
            var windowTexture  = Sprite.Load("./sprites/window.png");
            var ceilingTexture = Sprite.Load("./sprites/wood.png");
            var bedTexture     = Sprite.Load("./sprites/bed.png");
            var sword          = Sword.Create(resourceLoader);
            var bow            = Bow.Create(resourceLoader);
            var doorAnimation  = resourceLoader.GetAnimation("./animations/door");

            player.Weapons = new Weapon[] { sword, bow };
            var backGroundMusic = resourceLoader.GetMusic(MusicResourceHelper.EnvironmentDungeonMusic);
            var objects         = new IMapObject[]
            {
                Lich.Create(resourceLoader, new Vector2(6f, 6f), 0.0f),
                Skeleton.Create(resourceLoader, new Vector2(6f, 6f), 0.0f),
                GreenLight.Create(resourceLoader, new Vector2(8.0f, 8.0f), new Vector2(0, 0), 0),
                HealingPotion.Create(new Vector2(6f, 6f)),
                ArrowPack.Create(new Vector2(7f, 7f)),
                Note.Create(new Vector2(5f, 5f), "о, привет!\nследующая строка\nотвратительно длинная строка с кучей слов капец\nа вот это уже максимум по длине лучше бы его не переступать ага га гус")
            };

            backGroundMusic.Play(-1);
            var storage = new MapTextureStorage(ceilingTexture, wallTexture, floorTexture, windowTexture, bedTexture, doorAnimation);
            var map     = Map.FromStrings(new[]
            {
                "###############################",
                "#.............................#",
                "#.............................#",
                "#.............................#",
                "##...................#........#",
                "#b...................###......#",
                "#b...................#........#",
                "####......##########.#........#",
                "##...................#......###",
                "#........####........#........#",
                "#........#..#........#........#",
                "#........#..#........###......#",
                "#####.####..####.....#........#",
                "#####.####..####.....#........#",
                "#....................#......###",
                "#....................#........#",
                "#####.####..####.....###......#",
                "#####.####..####.....#........#",
                "#....................#........#",
                "###############################"
            }, storage.GetCellByChar);
            var level = new Scene(player, map, objects);

            while (engine.Update(level))
            {
            }
        }