コード例 #1
0
ファイル: SectorVM.cs プロジェクト: nf2g/Zilon_Roguelike
    private void ProcessDamage(IGraphNode targetNode, ITacticalAct tacticalAct, IActor actor, ActorViewModel actorViewModel)
    {
        var targetActorViewModel        = ActorViewModels.SingleOrDefault(x => x.Actor.Node == targetNode);
        var targetStaticObjectViewModel = _staticObjectViewModels.SingleOrDefault(x => x.StaticObject.Node == targetNode);
        var canBeHitViewModel           = (ICanBeHitSectorObject)targetActorViewModel ?? targetStaticObjectViewModel;

        if (canBeHitViewModel is null)
        {
            return;
        }

        actorViewModel.GraphicRoot.ProcessHit(canBeHitViewModel.Position);

        var sfxObj = _container.InstantiatePrefab(HitSfx, transform);
        var sfx    = sfxObj.GetComponent <HitSfx>();

        canBeHitViewModel.AddHitEffect(sfx);

        // Проверяем, стрелковое оружие или удар ближнего боя
        if (tacticalAct.Stats.Range?.Max > 1)
        {
            sfx.EffectSpriteRenderer.sprite = sfx.ShootSprite;

            // Создаём снаряд
            CreateBullet(actor, targetNode);
        }
    }
コード例 #2
0
ファイル: SectorVM.cs プロジェクト: nf2g/Zilon_Roguelike
    private void CreateBullet(IActor actor, IGraphNode targetNode)
    {
        var actorViewModel = ActorViewModels.Single(x => x.Actor == actor);

        var targetActorViewModel        = ActorViewModels.SingleOrDefault(x => x.Actor.Node == targetNode);
        var targetStaticObjectViewModel = _staticObjectViewModels.SingleOrDefault(x => x.StaticObject.Node == targetNode);
        var canBeHitViewModel           = (ICanBeHitSectorObject)targetActorViewModel ?? targetStaticObjectViewModel;

        var bulletTracer = Instantiate(GunShootTracer, transform);

        bulletTracer.FromPosition   = actorViewModel.transform.position;
        bulletTracer.TargetPosition = canBeHitViewModel.Position;
    }
コード例 #3
0
ファイル: SectorVM.cs プロジェクト: nf2g/Zilon_Roguelike
    private async void Monster_Dead(object sender, EventArgs e)
    {
        await Task.Factory.StartNew(() =>
        {
            // Используем ReferenceEquals, потому что нам нужно сравнить object и ISurvivalData по ссылке.
            // Это делаем, чтобы избежать приведения sender к ISurvivalData.
            var viewModel = ActorViewModels.SingleOrDefault(x => ReferenceEquals(x.Actor.Person.GetModule <ISurvivalModule>(), sender));

            if (viewModel != null)
            {
                ActorViewModels.Remove(viewModel);
            }
        }, CancellationToken.None, TaskCreationOptions.None, _taskScheduler);
    }
コード例 #4
0
ファイル: SectorVM.cs プロジェクト: nf2g/Zilon_Roguelike
    private void ShowFoundPropsModalOrNotFound(IActor actor, IPropContainer propContainer)
    {
        var props = propContainer.Content.CalcActualItems();

        if (props.Any())
        {
            var containerPopupObj = _container.InstantiatePrefab(ContainerPopupPrefab, WindowCanvas.transform);

            var containerPopup = containerPopupObj.GetComponent <ContainerPopup>();

            var transferMachine = new PropTransferMachine(actor.Person.GetModule <IInventoryModule>(),
                                                          propContainer.Content);
            containerPopup.Init(transferMachine);
        }
        else
        {
            var indicator = Instantiate(FoundNothingIndicatorPrefab, transform);
            indicator.CurrentLanguage = _uiSettingService.CurrentLanguage;

            var actorViewModel = ActorViewModels.SingleOrDefault(x => x.Actor == actor);

            indicator.Init(actorViewModel);
        }
    }