Example #1
0
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        ToggleImage.Disable("BackButton");

        FindObjectOfType <Button>().enabled = false;
        FindObjectOfType <Button>().gameObject.GetComponent <Image>().enabled = false;
    }
Example #2
0
    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
    //
    //}

    // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
    override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        ToggleImage.EnableWorldDisableRest();
        animator.SetInteger("ZoomState", 0);

        GameState.currentState = State.WORLD;
    }
Example #3
0
        private async Task RunAsync()
        {
            await foreach (var item in _channel.Reader.ReadAllAsync())
            {
                switch (item)
                {
                case ToggleImage image:
                    if (ToggleImage is not null)
                    {
                        await ToggleImage.Invoke(image);
                    }
                    break;

                case PlaySound sound:
                    if (PlaySound is not null)
                    {
                        await PlaySound.Invoke(sound);
                    }
                    break;

                case Services.ClearAll:
                    if (ClearAll is not null)
                    {
                        await ClearAll.Invoke();
                    }
                    break;
                }
            }
        }
Example #4
0
        private async void OnMessageReceived(object?sender, OnMessageReceivedArgs e)
        {
            if (TryGetCommand(e.ChatMessage.Message, out var command))
            {
                if (command.Equals("images"))
                {
                    var images  = _imageStore.GetImageNames().Select(s => $"!{s}");
                    var text    = string.Join(", ", images);
                    var message = $"These image commands are available: {text}";
                    _client.SendMessage(_twitchAuth.UserName.ToLowerInvariant(), message);
                    return;
                }
                var image = await _imageStore.GetImage(command);

                if (image is not null)
                {
                    var toggleImage = new ToggleImage(image.Name);
                    await _controlBus.AddAsync(toggleImage);

                    return;
                }

                var sound = await _soundStore.GetSound(command);

                if (sound is not null)
                {
                    var playSound = new PlaySound(sound.Name);
                    await _controlBus.AddAsync(playSound);

                    return;
                }
            }
        }
Example #5
0
        public override void Metamorphose(LegoUIMeta uiMeta)
        {
            if (MetamorphoseStage == LegoMetamorphoseStage.Completed)
            {
                MetamorphoseStage = LegoMetamorphoseStage.Metamorphosing;
            }

            if (PlaneToggleMeta == null)
            {
                PlaneToggleMeta = uiMeta.NextPlaneToggle;
                RectMeta        = uiMeta.CurrentRect;
            }

            switch (planeMetamorphoseStatus)
            {
            case MetamorphoseStatus.Toggle:
                MetamorphoseRect(RectMeta);
                if (PlaneToggleMeta.TransitionType == LegoTransition.ColorTint &&
                    PlaneToggleMeta.ColorTintMeta != null)
                {
                    var colorTintMeta = PlaneToggleMeta.ColorTintMeta;

                    colors = new ColorBlock
                    {
                        normalColor      = colorTintMeta.NormalLegoColor.ToColor(),
                        highlightedColor = colorTintMeta.HighlightedLegoColor.ToColor(),
                        pressedColor     = colorTintMeta.PressedLegoColor.ToColor(),
                        disabledColor    = colorTintMeta.DisabledLegoColor.ToColor(),
                        colorMultiplier  = colorTintMeta.ColorMultiplier,
                        fadeDuration     = colorTintMeta.FadeDuration
                    };
                }

                IsOn                    = PlaneToggleMeta.Ison;
                Interactable            = PlaneToggleMeta.Interactable;
                SoundEffectId           = PlaneToggleMeta.SoundId;
                planeMetamorphoseStatus = MetamorphoseStatus.SelfImage;
                break;

            case MetamorphoseStatus.SelfImage:
                ToggleImage.As <YuLegoImage>().Metamorphose(PlaneToggleMeta.ToggleImageMeta);
                planeMetamorphoseStatus = MetamorphoseStatus.Background;
                break;

            case MetamorphoseStatus.Background:
                FrontImage.As <YuLegoImage>().Metamorphose(PlaneToggleMeta
                                                           .ImageFrontPointRectMeta, PlaneToggleMeta.ImageFrontPointImageMeta);
                planeMetamorphoseStatus = MetamorphoseStatus.Toggle;
                MetamorphoseStage       = LegoMetamorphoseStage.Completed;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Example #6
0
        public static async Task Show(HttpContext context)
        {
            var controlBus = context.RequestServices.GetRequiredService <ControlBus>();

            if (!context.Request.RouteValues.TryGetValue("image", out var image))
            {
                context.Response.StatusCode = 404;
                return;
            }

            var command = new ToggleImage(image.ToString());

            await controlBus.AddAsync(command);

            context.Response.StatusCode = 200;
            await context.Response.WriteAsync("OK");
        }
Example #7
0
 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     ToggleImage.DisableAllExcept(thisImageName);
 }