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); } }
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; }
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); }
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); } }