Exemplo n.º 1
0
        private void Actor_UsedProp(object?sender, UsedPropEventArgs e)
        {
            var serviceScope                = ((LivGame)_game).ServiceProvider;
            var animationBlockerService     = serviceScope.GetRequiredService <IAnimationBlockerService>();
            var visualizationContentStorage = serviceScope.GetRequiredService <IGameObjectVisualizationContentStorage>();

            var consumableType = e.UsedProp.Scheme.Sid switch
            {
                "med-kit" => ConsumeEffectType.Heal,
                "water-bottle" => ConsumeEffectType.Drink,
                "packed-food" => ConsumeEffectType.Eat,
                _ => ConsumeEffectType.UseCommon
            };

            var soundEffect = _personSoundStorage.GetConsumePropSound(consumableType);

            _actorStateEngine = new ActorCommonActionMoveEngine(_graphicsRoot.RootSprite, animationBlockerService,
                                                                soundEffect?.CreateInstance());

            var hexSize   = MapMetrics.UnitSize / 2;
            var actorNode = (HexNode)(Actor.Node);
            var playerActorWorldCoords = HexHelper.ConvertToWorld(actorNode.OffsetCoords.X, actorNode.OffsetCoords.Y);
            var actorPosition          = new Vector2(
                (float)(playerActorWorldCoords[0] * hexSize * Math.Sqrt(3)),
                playerActorWorldCoords[1] * hexSize * 2 / 2
                );

            const int START_EFFECT_Y = 24;
            var       consumeEffect  = new ConsumingEffect(visualizationContentStorage,
                                                           actorPosition - (Vector2.UnitY * START_EFFECT_Y),
                                                           consumableType
                                                           );

            _sectorViewModelContext.EffectManager.VisualEffects.Add(consumeEffect);
        }
Exemplo n.º 2
0
    private void Actor_UsedProp(object sender, UsedPropEventArgs e)
    {
        if (e.UsedProp.Scheme.Sid != "camp-tools")
        {
            return;
        }

        SleepShadowManager.StartShadowAnimation();
    }
Exemplo n.º 3
0
    private async void Actor_UsedProp(object sender, UsedPropEventArgs e)
    {
        await Task.Factory.StartNew(() =>
        {
            if (e.UsedProp.Scheme.Sid != "camp-tools")
            {
                return;
            }

            SleepShadowManager.StartSleepShadowAnimation();
        }, CancellationToken.None, TaskCreationOptions.None, _taskScheduler);
    }