コード例 #1
0
        public void PerkLevelUpTest()
        {
            // ARRANGE
            var schemeServiceMock = new Mock <ISchemeService>();

            schemeServiceMock.Setup(x => x.GetSchemes <IPerkScheme>())
            .Returns(new IPerkScheme[] {
                new PerkScheme {
                    Levels = new[] {
                        new PerkLevelSubScheme {
                            MaxValue = 2,
                            Jobs     = new IJobSubScheme[0]
                        }
                    }
                }
            });
            var schemeService = schemeServiceMock.Object;

            var evolutionData = new EvolutionData(schemeService);

            var perk = evolutionData.Perks[0];

            evolutionData.PerkLevelUp(perk);



            // ACT
            evolutionData.PerkLevelUp(perk);



            // ASSERT
            evolutionData.Perks.Length.Should().Be(1);
            evolutionData.Perks[0].CurrentLevel.Sub.Should().Be(1);
        }
コード例 #2
0
ファイル: ModelManager.cs プロジェクト: Skierhou/Study
 private void Awake()
 {
     m_EvolutionData   = ConfigManager.Instance.FindData <EvolutionData>(Consts.Config_EvolutionData);
     m_AchievementData = ConfigManager.Instance.FindData <AchievementData>(Consts.Config_AchievementData);
     m_ShopData        = ConfigManager.Instance.FindData <ShopData>(Consts.Config_ShopData);
     LoadInfoByLocal();
 }
コード例 #3
0
        private static void RestoreEvolutionData(ISchemeService schemeService,
                                                 HumanPersonStorageData storedPerson,
                                                 EvolutionData evolutionData)
        {
            var perksFromSave = new List <IPerk>();

            foreach (var storedPerk in storedPerson.Perks)
            {
                var perkScheme = schemeService.GetScheme <IPerkScheme>(storedPerk.Sid);

                var perk = new Perk
                {
                    Scheme = perkScheme
                };

                if (storedPerk.Level != null)
                {
                    perk.CurrentLevel = new PerkLevel(storedPerk.Level.Value, storedPerk.SubLevel.Value);
                }

                // TODO Доработать, когда будет доработана прокачка больше, чем на один лвл
                var currentLevelScheme = perkScheme.Levels[0];

                perk.CurrentJobs = currentLevelScheme.Jobs.Select(job => new PerkJob(job)
                {
                    IsComplete = storedPerk.Jobs.Single(storedJob => storedJob.Type == job.Type && storedJob.Scope == job.Scope).IsComplete,
                    Progress   = storedPerk.Jobs.Single(storedJob => storedJob.Type == job.Type && storedJob.Scope == job.Scope).Progress,
                }).ToArray();

                perksFromSave.Add(perk);
            }
            evolutionData.SetPerksForced(perksFromSave);
        }
コード例 #4
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);
        }
コード例 #5
0
    private void ShowNextMonsterData()
    {
        this.ngTX_MONS_NEXT_NAME.text  = this.data.md_next.monsterMG.monsterName;
        this.ngTX_MONS_NEXT_SKILL.text = MonsterTribeData.GetTribeName(this.data.md_next.monsterMG.tribe);
        this.specificTypeName.text     = MonsterSpecificTypeData.GetSpecificTypeName(this.data.md_next.monsterMG.monsterStatusId);
        int num = 0;

        if (this.evolutionType == "1" || this.evolutionType == "3" || this.evolutionType == "4")
        {
            string monsterId = this.data.md_next.monsterM.monsterId;
            num = EvolutionData.CalcClusterForEvolve(monsterId);
        }
        else if (this.evolutionType == "5")
        {
            string monsterId2 = this.data.md.monsterM.monsterId;
            num = EvolutionData.CalcClusterForVersionUp(monsterId2);
        }
        else if (this.evolutionType == "2")
        {
            string monsterId3 = this.data.md_next.monsterM.monsterId;
            num = EvolutionData.CalcClusterForModeChange(monsterId3);
        }
        this.ngTX_NEED_CHIP.text = StringFormat.Cluster(num);
        int num2 = int.Parse(DataMng.Instance().RespDataUS_PlayerInfo.playerInfo.gamemoney);

        if (num2 < num)
        {
            this.ngTX_NEED_CHIP.color = Color.red;
        }
    }
コード例 #6
0
ファイル: EvolutionPanel.cs プロジェクト: Skierhou/Study
    private void Awake()
    {
        m_BuildData     = ConfigManager.Instance.FindData <BuildData>(Consts.Config_BuildData);
        m_EvolutionData = ConfigManager.Instance.FindData <EvolutionData>(Consts.Config_EvolutionData);
        foreach (EvolutionBase evolution in m_EvolutionData.EvolutionList)
        {
            if (!m_RaceEvoluDict.ContainsKey(evolution.RaceType))
            {
                m_RaceEvoluDict.Add(evolution.RaceType, new List <EvolutionBase>());
            }
            if (evolution.HeroId == 0)
            {
                m_RaceEvoluDict[evolution.RaceType].Add(evolution);
            }
            else
            {
                if (!m_HeroEvoluDict.ContainsKey(evolution.HeroId))
                {
                    m_HeroEvoluDict.Add(evolution.HeroId, new List <EvolutionBase>());
                }
                m_HeroEvoluDict[evolution.HeroId].Add(evolution);
            }
        }
        m_RaceGrid = transform.Find("Bg/RaceGrid");
        m_HeroGrid = transform.Find("Bg/HeroRectView/ViewPort/Grid") as RectTransform;
        m_HeroImg  = transform.Find("Bg/Icon").GetComponent <Image>();
        m_NameTxt  = transform.Find("Bg/Name").GetComponent <Text>();
        m_DesTxt   = transform.Find("Bg/Des").GetComponent <Text>();
        m_ItemGrid = transform.Find("Bg/RectView/ViewPort/Grid") as RectTransform;
        m_CloseBtn = transform.Find("Bg/CloseBtn").GetComponent <Button>();

        m_CloseBtn.onClick.AddListener(CloseBtnClick);
    }
コード例 #7
0
    protected override int CalcCluster()
    {
        int result = 0;

        if (this.baseDigimon != null)
        {
            result = EvolutionData.CalcClusterForVersionUp(this.baseDigimon.monsterM.monsterId);
        }
        return(result);
    }
コード例 #8
0
    private ActorViewModel CreateHumanActorVm([NotNull] IPlayer player,
                                              [NotNull] PersonScheme personScheme,
                                              [NotNull] IActorManager actorManager,
                                              [NotNull] IMapNode startNode,
                                              [NotNull] IEnumerable <MapNodeVM> nodeVMs)
    {
        if (_personManager.Person == null)
        {
            var inventory = new Inventory();

            var evolutionData = new EvolutionData(_schemeService);
            //evolutionData.PerkLeveledUp += (sender, args) => Debug.Log("LevelUp");

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

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

            _personManager.Person = person;

            AddEquipmentToActor(inventory, "battle-axe");
            AddEquipmentToActor(inventory, "short-sword");
            AddEquipmentToActor(inventory, "steel-helmet");
            AddEquipmentToActor(inventory, "steel-armor");
            AddEquipmentToActor(inventory, "pistol");
        }

        var actor = new Actor(_personManager.Person, player, startNode, _personManager.ActorState);

        _personManager.ActorState = actor.State;

        actorManager.Add(actor);

        var actorVm      = Instantiate(ActorPrefab, transform);
        var actorGraphic = Instantiate(HumanoidGraphicPrefab, actorVm.transform);

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

        var graphicController = actorVm.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);

        actorVm.transform.position = actorPosition;
        actorVm.Actor = actor;

        actorVm.Actor.OpenedContainer += PlayerActorOnOpenedContainer;
        actorVm.Actor.UsedAct         += ActorOnUsedAct;

        return(actorVm);
    }
コード例 #9
0
    /// <summary>
    /// save the models all parameters to a byte array
    /// </summary>
    /// <returns></returns>
    public virtual byte[] SaveCheckpoint()
    {
        EvolutionData data = new EvolutionData();

        data.samples = samples;
        data.currentEvaluationIndex = currentEvaluationIndex;
        data.currentGeneration      = currentGeneration;
        data.best = Best;
        var binFormatter = new BinaryFormatter();
        var mStream      = new MemoryStream();

        binFormatter.Serialize(mStream, data);
        return(mStream.ToArray());
    }
コード例 #10
0
ファイル: FeatureContextBase.cs プロジェクト: tgspn/Zilon
        private IActor CreateHumanActor([NotNull] IPlayer player,
                                        [NotNull] PersonScheme personScheme,
                                        [NotNull] IMapNode startNode)
        {
            var schemeService = Container.GetInstance <ISchemeService>();

            var evolutionData = new EvolutionData(schemeService);

            var inventory = new Inventory();

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

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

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

            return(actor);
        }
コード例 #11
0
        private static IActor CreateHumanActor(HumanPlayer humanPlayer,
                                               ISchemeService schemeService,
                                               ISurvivalRandomSource survivalRandomSource,
                                               IPropFactory propFactory,
                                               ISectorManager sectorManager,
                                               IActorManager actorManager)
        {
            var personScheme = schemeService.GetScheme <IPersonScheme>("human-person");

            var playerActorStartNode = sectorManager.CurrentSector.Map.Regions
                                       .SingleOrDefault(x => x.IsStart).Nodes
                                       .First();

            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 = new Random().Next(1, 3);
                switch (classRoll)
                {
                case 1:
                    AddEquipmentToActor(person.EquipmentCarrier, 2, "short-sword", schemeService, propFactory);
                    AddEquipmentToActor(person.EquipmentCarrier, 1, "steel-armor", schemeService, propFactory);
                    AddEquipmentToActor(person.EquipmentCarrier, 3, "wooden-shield", schemeService, propFactory);
                    break;

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

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

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

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

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

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

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

            var actor = new Actor(humanPlayer.MainPerson, humanPlayer, playerActorStartNode);

            actorManager.Add(actor);

            return(actor);
        }
コード例 #12
0
    static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
        foreach (string asset in importedAssets)
        {
            if (!filePath.Equals(asset))
            {
                continue;
            }

            EvolutionData data = (EvolutionData)AssetDatabase.LoadAssetAtPath(exportPath, typeof(EvolutionData));
            if (data == null)
            {
                data = ScriptableObject.CreateInstance <EvolutionData> ();
                AssetDatabase.CreateAsset((ScriptableObject)data, exportPath);
                data.hideFlags = HideFlags.NotEditable;
            }

            data.sheets.Clear();
            using (FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) {
                IWorkbook book = null;
                if (Path.GetExtension(filePath) == ".xls")
                {
                    book = new HSSFWorkbook(stream);
                }
                else
                {
                    book = new XSSFWorkbook(stream);
                }

                foreach (string sheetName in sheetNames)
                {
                    ISheet sheet = book.GetSheet(sheetName);
                    if (sheet == null)
                    {
                        Debug.LogError("[QuestData] sheet not found:" + sheetName);
                        continue;
                    }

                    EvolutionData.Sheet s = new EvolutionData.Sheet();
                    s.name = sheetName;

                    for (int i = 1; i <= sheet.LastRowNum; i++)
                    {
                        IRow  row  = sheet.GetRow(i);
                        ICell cell = null;

                        EvolutionData.Param p = new EvolutionData.Param();

                        cell = row.GetCell(0); p.Lv = (int)(cell == null ? 0 : cell.NumericCellValue);
                        cell = row.GetCell(1); p.MonsterNum = (int)(cell == null ? 0 : cell.NumericCellValue);
                        cell = row.GetCell(2); p.Name = (cell == null ? "" : cell.StringCellValue);
                        s.list.Add(p);
                    }
                    data.sheets.Add(s);
                }
            }

            ScriptableObject obj = AssetDatabase.LoadAssetAtPath(exportPath, typeof(ScriptableObject)) as ScriptableObject;
            EditorUtility.SetDirty(obj);
        }
    }
コード例 #13
0
 void Awake()
 {
     evolutionData = GetComponent <EvolutionData>();
     building      = GetComponent <Building>();
 }
コード例 #14
0
    public void Initialize(Action <EvolutionData.MonsterEvolveData, int> evolutionAction)
    {
        this.onEvolution   = evolutionAction;
        this.evolutionType = ClassSingleton <EvolutionData> .Instance.GetEvolutionEffectType(this.data.md.userMonster.monsterId, this.data.md_next.userMonster.monsterId);

        this.ngTAG_NEED_CHIP.text = StringMaster.GetString("SystemCost");
        this.myCluster            = int.Parse(DataMng.Instance().RespDataUS_PlayerInfo.playerInfo.gamemoney);
        if (this.evolutionType == "1" || this.evolutionType == "3" || this.evolutionType == "4")
        {
            this.needCluster = EvolutionData.CalcClusterForEvolve(this.data.md_next.monsterM.monsterId);
        }
        else if (this.evolutionType == "5")
        {
            this.needCluster = EvolutionData.CalcClusterForVersionUp(this.data.md_next.monsterM.monsterId);
        }
        else if (this.evolutionType == "2")
        {
            this.needCluster = EvolutionData.CalcClusterForModeChange(this.data.md_next.monsterM.monsterId);
        }
        this.ShowNextMonsterIcon();
        this.ShowNextMonsterData();
        this.executionButton.Initialize(new Action <CMD>(this.OnPushConfirmYesButton));
        UILabel component = this.goCAN_EVOLVE.GetComponent <UILabel>();

        if (this.CanEvolve())
        {
            if (this.evolutionType == "2")
            {
                if (this.myCluster < this.needCluster)
                {
                    component.text = string.Format(StringMaster.GetString("EvolutionImpossible"), this.GetEvolutionName());
                    this.SetDeactiveButton();
                }
                else
                {
                    this.SetActiveButton();
                }
            }
            else if (this.evolutionType == "1" || this.evolutionType == "3" || this.evolutionType == "4" || this.evolutionType == "5")
            {
                if (this.myCluster < this.needCluster)
                {
                    component.text = string.Format(StringMaster.GetString("EvolutionImpossible"), this.GetEvolutionName());
                    this.SetDeactiveButton();
                }
                else
                {
                    int num  = int.Parse(this.data.md.userMonster.level);
                    int num2 = int.Parse(this.data.md.monsterM.maxLevel);
                    if (num >= num2)
                    {
                        this.SetActiveButton();
                    }
                    else
                    {
                        component.text = StringMaster.GetString("EvolutionNotEnoughLv");
                        this.SetDeactiveButton();
                    }
                }
            }
            else
            {
                global::Debug.LogError("進化タイプエラー.");
            }
        }
        else
        {
            component.text = string.Format(StringMaster.GetString("EvolutionImpossible"), this.GetEvolutionName());
            this.SetDeactiveButton();
        }
    }
コード例 #15
0
        public HumanPerson Restore(ISchemeService schemeService,
                                   ISurvivalRandomSource survivalRandomSource,
                                   IPropFactory propFactory)
        {
            var storedPerson = this;

            var personScheme = schemeService.GetScheme <IPersonScheme>("human-person");

            var inventory = new Inventory();

            var evolutionData = new EvolutionData(schemeService);

            RestoreEvolutionData(schemeService, storedPerson, evolutionData);

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

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

            foreach (var survivalStoredItem in storedPerson.Survival)
            {
                var normalizedValueShare = RangeHelper.NormalizeShare(survivalStoredItem.Value);

                var stat = person.Survival.Stats.Single(x => x.Type == survivalStoredItem.Type);

                stat.SetShare(normalizedValueShare);
            }

            foreach (var storedProp in storedPerson.Inventory)
            {
                var   propScheme = schemeService.GetScheme <IPropScheme>(storedProp.Sid);
                IProp prop;
                switch (storedProp.Type)
                {
                case PropType.Resource:
                    prop = propFactory.CreateResource(propScheme, storedProp.Count);
                    break;

                case PropType.Equipment:
                    var equipment = propFactory.CreateEquipment(propScheme);
                    equipment.Durable.Value = storedProp.Durable;
                    prop = equipment;

                    break;

                default:
                    throw new Exception();
                }

                inventory.Add(prop);
            }

            for (var i = 0; i < storedPerson.Equipments.Length; i++)
            {
                var storedEquipment = storedPerson.Equipments[i];

                if (storedEquipment == null)
                {
                    continue;
                }

                var equipmentScheme = schemeService.GetScheme <IPropScheme>(storedEquipment.Sid);

                var equipment = propFactory.CreateEquipment(equipmentScheme);
                equipment.Durable.Value = storedEquipment.Durable;

                person.EquipmentCarrier[i] = equipment;
                //TODO Уменьшать прочность согласно сохранённым данным
            }

            return(person);
        }
コード例 #16
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);
    }
コード例 #17
0
        private static IActor CreateHumanActor(HumanPlayer humanPlayer,
                                               ISchemeService schemeService,
                                               ISurvivalRandomSource survivalRandomSource,
                                               IPropFactory propFactory,
                                               ISectorManager sectorManager,
                                               IActorManager actorManager)
        {
            var personScheme = schemeService.GetScheme <IPersonScheme>("human-person");

            var playerActorStartNode = sectorManager.CurrentSector.Map.Regions
                                       .SingleOrDefault(x => x.IsStart).Nodes
                                       .First();

            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;

                // TODO Использовать генератор персонажа, как в игре.
                // Для этого нужно научить ботов корректно использовать оружие дальнего боя и посохи лечения.
                var classRoll = new Random().Next(1, 3);
                switch (classRoll)
                {
                case 1:
                    AddEquipmentToActor(person.EquipmentCarrier, 2, "short-sword", schemeService, propFactory);
                    AddEquipmentToActor(person.EquipmentCarrier, 1, "steel-armor", schemeService, propFactory);
                    AddEquipmentToActor(person.EquipmentCarrier, 3, "wooden-shield", schemeService, propFactory);
                    break;

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

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

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

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

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

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

                default:
                    throw new InvalidOperationException("Эта комбинация начальной экипировки не поддерживается.");
                }

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

            var actor = new Actor(humanPlayer.MainPerson, humanPlayer, playerActorStartNode);

            actorManager.Add(actor);

            return(actor);
        }