Esempio n. 1
0
        public static IActorViewModel CreateHumanActorVm([NotNull] IPlayer player,
                                                         [NotNull] ISchemeService schemeService,
                                                         [NotNull] ISurvivalRandomSource survivalRandomSource,
                                                         [NotNull] IPersonScheme personScheme,
                                                         [NotNull] IActorManager actorManager,
                                                         [NotNull] IMapNode startNode)
        {
            var inventory = new Inventory();

            var evolutionData = new EvolutionData(schemeService);

            var defaultActScheme = schemeService.GetScheme <ITacticalActScheme>(personScheme.DefaultAct);

            var person = new HumanPerson(personScheme,
                                         defaultActScheme,
                                         evolutionData,
                                         survivalRandomSource,
                                         inventory);

            var actor = new Actor(person, player, startNode);

            actorManager.Add(actor);

            var actorViewModel = new TestActorViewModel
            {
                Actor = actor
            };

            return(actorViewModel);
        }
Esempio n. 2
0
        public HumanPerson([NotNull] IPersonScheme scheme,
                           [NotNull] ITacticalActScheme defaultActScheme,
                           [NotNull] IEvolutionData evolutionData,
                           [NotNull] ISurvivalRandomSource survivalRandomSource)
        {
            _defaultActScheme = defaultActScheme ?? throw new ArgumentNullException(nameof(defaultActScheme));

            Scheme                = scheme ?? throw new ArgumentNullException(nameof(scheme));
            EvolutionData         = evolutionData ?? throw new ArgumentNullException(nameof(evolutionData));
            _survivalRandomSource = survivalRandomSource ?? throw new ArgumentNullException(nameof(survivalRandomSource));

            Name = scheme.Sid;

            Effects          = new EffectCollection();
            Effects.Added   += Effects_CollectionChanged;
            Effects.Removed += Effects_CollectionChanged;
            Effects.Changed += Effects_CollectionChanged;

            EquipmentCarrier = new EquipmentCarrier(Scheme.Slots);
            EquipmentCarrier.EquipmentChanged += EquipmentCarrier_EquipmentChanged;

            TacticalActCarrier = new TacticalActCarrier();

            EvolutionData.PerkLeveledUp += EvolutionData_PerkLeveledUp;


            CombatStats = new CombatStats();
            ClearCalculatedStats();
            CalcCombatStats();

            TacticalActCarrier.Acts = CalcActs(EquipmentCarrier);

            Survival = new HumanSurvivalData(scheme, survivalRandomSource);
            Survival.StatCrossKeyValue += Survival_StatCrossKeyValue;
        }
        private static IEnumerable <SurvivalStat> GetStatsIterator([NotNull] IPersonScheme personScheme, IAttributesModule attributesModule)
        {
            // Устанавливаем характеристики выживания персонажа
            yield return(SetHitPointsStat(personScheme, attributesModule));

            // Выставляем сытость/упоённость
            if (personScheme.SurvivalStats != null)
            {
                yield return(CreateStatFromScheme(personScheme.SurvivalStats,
                                                  SurvivalStatType.Satiety,
                                                  PersonSurvivalStatType.Satiety));

                yield return(CreateStatFromScheme(personScheme.SurvivalStats,
                                                  SurvivalStatType.Hydration,
                                                  PersonSurvivalStatType.Hydration));

                yield return(CreateStatFromScheme(personScheme.SurvivalStats,
                                                  SurvivalStatType.Intoxication,
                                                  PersonSurvivalStatType.Intoxication));

                yield return(CreateStatFromScheme(personScheme.SurvivalStats,
                                                  SurvivalStatType.Wound,
                                                  PersonSurvivalStatType.Wound));
            }

            yield return(CreateUselessStat(SurvivalStatType.Breath));

            yield return(CreateUselessStat(SurvivalStatType.Energy));
        }
        public HumanSurvivalData([NotNull] IPersonScheme personScheme,
                                 [NotNull] IEnumerable <SurvivalStat> stats,
                                 [NotNull] ISurvivalRandomSource randomSource)
        {
            _personScheme = personScheme ?? throw new ArgumentNullException(nameof(personScheme));
            _randomSource = randomSource ?? throw new ArgumentNullException(nameof(randomSource));

            Stats = stats.ToArray();
        }
        private static ISurvivalModule CreateSurvivalData(IPersonScheme personScheme, ISurvivalRandomSource survivalRandomSource)
        {
            var attributesModuleMock = new Mock <IAttributesModule>();
            var attributesModule     = attributesModuleMock.Object;

            var survivalData = new HumanSurvivalModule(personScheme, survivalRandomSource, attributesModule);

            return(survivalData);
        }
Esempio n. 6
0
 public HumanPerson(IPersonScheme scheme,
                    [NotNull] ITacticalActScheme defaultScheme,
                    [NotNull] IEvolutionData evolutionData,
                    [NotNull] ISurvivalRandomSource survivalRandomSource,
                    [NotNull] Inventory inventory) :
     this(scheme, defaultScheme, evolutionData, survivalRandomSource)
 {
     Inventory = inventory;
 }
Esempio n. 7
0
 public HumanSurvivalModule([NotNull] IPersonScheme personScheme,
                            [NotNull] ISurvivalRandomSource randomSource,
                            [NotNull] IAttributesModule attributesModule) : this(
         personScheme,
         randomSource,
         attributesModule,
         null,
         null,
         null)
 {
 }
 public HumanSurvivalModule([NotNull] IPersonScheme personScheme,
                            [NotNull] ISurvivalRandomSource randomSource,
                            [NotNull] IAttributesModule attributesModule) : this(
         personScheme,
         randomSource,
         attributesModule,
         effectsModule : null,
         evolutionModule : null,
         equipmentModule : null)
 {
 }
Esempio n. 9
0
 public HumanSurvivalModule(IPersonScheme personScheme,
                            ISurvivalRandomSource randomSource,
                            IAttributesModule attributesModule) : this(
         personScheme,
         randomSource,
         attributesModule,
         сonditionModule : null,
         evolutionModule : null,
         equipmentModule : null)
 {
 }
Esempio n. 10
0
        public static IActorViewModel CreateHumanActorVm([NotNull] IPlayer player,
                                                         [NotNull] ISchemeService schemeService,
                                                         [NotNull] ISurvivalRandomSource survivalRandomSource,
                                                         [NotNull] IPersonScheme personScheme,
                                                         [NotNull] IActorManager actorManager,
                                                         [NotNull] IGraphNode startNode)
        {
            if (player is null)
            {
                throw new System.ArgumentNullException(nameof(player));
            }

            if (schemeService is null)
            {
                throw new System.ArgumentNullException(nameof(schemeService));
            }

            if (survivalRandomSource is null)
            {
                throw new System.ArgumentNullException(nameof(survivalRandomSource));
            }

            if (personScheme is null)
            {
                throw new System.ArgumentNullException(nameof(personScheme));
            }

            if (actorManager is null)
            {
                throw new System.ArgumentNullException(nameof(actorManager));
            }

            if (startNode is null)
            {
                throw new System.ArgumentNullException(nameof(startNode));
            }

            var person = new HumanPerson(personScheme);

            var actor = new Actor(person, player, startNode);

            actorManager.Add(actor);

            var actorViewModel = new TestActorViewModel
            {
                Actor = actor
            };

            return(actorViewModel);
        }
        private static SurvivalStat SetHitPointsStat(IPersonScheme personScheme, IAttributesModule attributesModule)
        {
            var constitutionHpBonus = GetConstitutionHpBonus(attributesModule);

            // В схеме храним базовые ХП.
            // Конституция добавяет или снижает ХП.
            var totalHp = personScheme.Hp + constitutionHpBonus;
            var hpStat  = new HpSurvivalStat(totalHp, 0, totalHp)
            {
                Type = SurvivalStatType.Health
            };

            return(hpStat);
        }
        private static IEnumerable <SurvivalStat> GetStats([NotNull] IPersonScheme personScheme, [NotNull] IAttributesModule attributesModule)
        {
            if (personScheme is null)
            {
                throw new ArgumentNullException(nameof(personScheme));
            }

            if (attributesModule is null)
            {
                throw new ArgumentNullException(nameof(attributesModule));
            }

            return(GetStatsIterator(personScheme, attributesModule).Where(x => x != null));
        }
        public HumanSurvivalData([NotNull] IPersonScheme personScheme,
                                 [NotNull] ISurvivalRandomSource randomSource)
        {
            _personScheme = personScheme ?? throw new ArgumentNullException(nameof(personScheme));
            _randomSource = randomSource ?? throw new ArgumentNullException(nameof(randomSource));

            Stats = new[] {
                new SurvivalStat(_personScheme.Hp, 0, _personScheme.Hp)
                {
                    Type = SurvivalStatType.Health
                },
                CreateStat(SurvivalStatType.Satiety),
                CreateStat(SurvivalStatType.Water)
            };
        }
        public HumanSurvivalModule([NotNull] IPersonScheme personScheme,
                                   [NotNull] ISurvivalRandomSource randomSource,
                                   [NotNull] IAttributesModule attributesModule,
                                   IEffectsModule effectsModule,
                                   IEvolutionModule evolutionModule,
                                   IEquipmentModule equipmentModule) : base(GetStats(personScheme, attributesModule))
        {
            _personScheme     = personScheme ?? throw new ArgumentNullException(nameof(personScheme));
            _randomSource     = randomSource ?? throw new ArgumentNullException(nameof(randomSource));
            _attributesModule = attributesModule ?? throw new ArgumentNullException(nameof(attributesModule));
            _effectsModule    = effectsModule;
            _evolutionModule  = evolutionModule;
            _equipmentModule  = equipmentModule;

            RegisterModuleEventHandlers();

            foreach (var stat in Stats)
            {
                stat.Changed += Stat_Changed;
            }

            CalcSurvivalStats();
        }
        private IActor CreateHumanActor([NotNull] IPlayer player,
                                        [NotNull] IPersonScheme personScheme,
                                        [NotNull] IMapNode startNode)
        {
            var schemeService        = Container.GetInstance <ISchemeService>();
            var survivalRandomSource = Container.GetInstance <ISurvivalRandomSource>();

            var evolutionData = new EvolutionData(schemeService);

            var inventory = new Inventory();

            var defaultActScheme = schemeService.GetScheme <ITacticalActScheme>(personScheme.DefaultAct);

            var person = new HumanPerson(personScheme,
                                         defaultActScheme,
                                         evolutionData,
                                         survivalRandomSource,
                                         inventory);

            var actor = new Actor(person, player, startNode);

            return(actor);
        }
Esempio n. 16
0
        public HumanSurvivalModule(IPersonScheme personScheme,
                                   ISurvivalRandomSource randomSource,
                                   IAttributesModule attributesModule,
                                   IConditionsModule?сonditionModule,
                                   IEvolutionModule?evolutionModule,
                                   IEquipmentModule?equipmentModule) : base(GetStats(personScheme, attributesModule))
        {
            _personScheme     = personScheme;
            _randomSource     = randomSource;
            _attributesModule = attributesModule;
            _сonditionModule  = сonditionModule;
            _evolutionModule  = evolutionModule;
            _equipmentModule  = equipmentModule;

            RegisterModuleEventHandlers();

            foreach (var stat in Stats)
            {
                stat.Changed += Stat_Changed;
            }

            CalcSurvivalStats();
        }
Esempio n. 17
0
        public HumanPerson([NotNull] IPersonScheme scheme, IFraction fraction) : base(fraction)
        {
            Scheme = scheme ?? throw new ArgumentNullException(nameof(scheme));

            Name = scheme.Sid;
        }
Esempio n. 18
0
        public HumanPerson(IPersonScheme scheme, IFraction fraction) : base(fraction)
        {
            Scheme = scheme;

            Name = scheme.Sid ?? throw new InvalidOperationException();
        }
Esempio n. 19
0
    private ActorViewModel CreateHumanActorViewModel([NotNull] IPlayer player,
                                                     [NotNull] IPersonScheme personScheme,
                                                     [NotNull] IActorManager actorManager,
                                                     [NotNull] ISurvivalRandomSource survivalRandomSource,
                                                     [NotNull] IMapNode startNode,
                                                     [NotNull] IEnumerable <MapNodeVM> nodeVMs)
    {
        if (_humanPlayer.MainPerson == null)
        {
            var inventory = new Inventory();

            var evolutionData = new EvolutionData(_schemeService);

            var defaultActScheme = _schemeService.GetScheme <ITacticalActScheme>(personScheme.DefaultAct);

            var person = new HumanPerson(personScheme, defaultActScheme, evolutionData, survivalRandomSource, inventory);

            _humanPlayer.MainPerson = person;


            var classRoll = UnityEngine.Random.Range(1, 6);
            switch (classRoll)
            {
            case 1:
                AddEquipmentToActor(person.EquipmentCarrier, 2, "short-sword");
                AddEquipmentToActor(person.EquipmentCarrier, 1, "steel-armor");
                AddEquipmentToActor(person.EquipmentCarrier, 3, "wooden-shield");
                break;

            case 2:
                AddEquipmentToActor(person.EquipmentCarrier, 2, "battle-axe");
                AddEquipmentToActor(person.EquipmentCarrier, 3, "battle-axe");
                AddEquipmentToActor(person.EquipmentCarrier, 0, "highlander-helmet");
                break;

            case 3:
                AddEquipmentToActor(person.EquipmentCarrier, 2, "bow");
                AddEquipmentToActor(person.EquipmentCarrier, 1, "leather-jacket");
                AddEquipmentToActor(inventory, "short-sword");
                AddResourceToActor(inventory, "arrow", 10);
                break;

            case 4:
                AddEquipmentToActor(person.EquipmentCarrier, 2, "fireball-staff");
                AddEquipmentToActor(person.EquipmentCarrier, 1, "scholar-robe");
                AddEquipmentToActor(person.EquipmentCarrier, 0, "wizard-hat");
                AddResourceToActor(inventory, "mana", 15);
                break;

            case 5:
                AddEquipmentToActor(person.EquipmentCarrier, 2, "pistol");
                AddEquipmentToActor(person.EquipmentCarrier, 0, "elder-hat");
                AddResourceToActor(inventory, "bullet-45", 5);

                AddResourceToActor(inventory, "packed-food", 1);
                AddResourceToActor(inventory, "water-bottle", 1);
                AddResourceToActor(inventory, "med-kit", 1);

                AddResourceToActor(inventory, "mana", 5);
                AddResourceToActor(inventory, "arrow", 3);
                break;
            }

            AddResourceToActor(inventory, "packed-food", 1);
            AddResourceToActor(inventory, "water-bottle", 1);
            AddResourceToActor(inventory, "med-kit", 1);
        }

        var actor = new Actor(_humanPlayer.MainPerson, player, startNode);

        actorManager.Add(actor);

        var actorViewModelObj = _container.InstantiatePrefab(ActorPrefab, transform);
        var actorViewModel    = actorViewModelObj.GetComponent <ActorViewModel>();
        var actorGraphic      = Instantiate(HumanoidGraphicPrefab, actorViewModel.transform);

        actorGraphic.transform.position = new Vector3(0, 0.2f, 0);
        actorViewModel.GraphicRoot      = actorGraphic;

        var graphicController = actorViewModel.gameObject.AddComponent <HumanActorGraphicController>();

        graphicController.Actor   = actor;
        graphicController.Graphic = actorGraphic;

        var actorNodeVm   = nodeVMs.Single(x => x.Node == actor.Node);
        var actorPosition = actorNodeVm.transform.position + new Vector3(0, 0, -1);

        actorViewModel.transform.position = actorPosition;
        actorViewModel.Actor     = actor;
        actorViewModel.Selected += HumanActorViewModel_Selected;

        actor.OpenedContainer      += PlayerActorOnOpenedContainer;
        actor.UsedAct              += ActorOnUsedAct;
        actor.Person.Survival.Dead += HumanPersonSurvival_Dead;

        return(actorViewModel);
    }