예제 #1
0
        private void Actor_PropTransferPerformed(object?sender, EventArgs e)
        {
            var serviceScope            = ((LivGame)_game).ServiceProvider;
            var animationBlockerService = serviceScope.GetRequiredService <IAnimationBlockerService>();
            var soundEffect             = _personSoundStorage.GetActivitySound(PersonActivityEffectType.Transit);
            var stateEngine             = new ActorCommonActionMoveEngine(
                _graphicsRoot.RootSprite,
                animationBlockerService,
                soundEffect?.CreateInstance());

            AddStateEngine(stateEngine);
        }
예제 #2
0
        private void PersonEquipmentModule_EquipmentChanged(object?sender, EquipmentChangedEventArgs e)
        {
            var serviceScope            = ((LivGame)_game).ServiceProvider;
            var animationBlockerService = serviceScope.GetRequiredService <IAnimationBlockerService>();

            var equipment        = e.Equipment;
            var soundSoundEffect = SelectEquipEffect(equipment);

            var stateEngine = new ActorCommonActionMoveEngine(_graphicsRoot.RootSprite, animationBlockerService,
                                                              soundSoundEffect?.CreateInstance());

            AddStateEngine(stateEngine);
        }
예제 #3
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" or "gall-gland" => ConsumeEffectType.Heal,
                "water-bottle" or "vege-milk" => ConsumeEffectType.Drink,
                "packed-food" or "raw-meat" or "evil-pumpkin" => ConsumeEffectType.Eat,
                _ => ConsumeEffectType.UseCommon
            };

            var soundEffect = _personSoundStorage.GetConsumePropSound(consumableType);

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

            AddStateEngine(stateEngine);

            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),
                this,
                consumableType
                );

            _sectorViewModelContext.EffectManager.VisualEffects.Add(consumeEffect);
        }