public void FromObjectArray(object[] properties) { int i = 0; ID = (int)properties[i++]; IsFinalZone = (bool)properties[i++]; IsCompleted = (bool)properties[i++]; object[] npcObjects = properties[i++] as object[]; EnemyNpcModels = new NpcModel[npcObjects.Length]; for (int j = 0; j < EnemyNpcModels.Length; j++) { EnemyNpcModels[j] = new NpcModel(); EnemyNpcModels[j].FromObjectArray(npcObjects[j] as object[]); } }
public Npc Spawn(NpcModel npcModel, bool activateInstantly = true) { var npc = Instantiate(_npcPrefab); npc.transform.position = _spawnPoint.transform.position; npc.Model = npcModel; npc.ShopWaypoint = _npcTarget; npc.LeaveWaypoint = _npcLeave; if (activateInstantly) { npc.Activate(); } return(npc); }
public static Dictionary <UnitType, Dictionary <BattleStatTypes, IBattleStatsDouble> > CreateSkagryMods( NpcModel npc) { // todo нужно определить одинаковоые или разные статы var dic = new Dictionary <UnitType, Dictionary <BattleStatTypes, IBattleStatsDouble> >(); //todo будут ли статы отличными. тут хорошее место для применения отличных статов от базы var unitsStats = UnitHelper.CreateBaseUnitStats(); //todo заполняем статы для нпс var npcTeches = new BattleTeches(npc.NpcMother.TechProgress); //todo можно вести свзяь с офицерами и элитными войсками скагри var officerBonus = new BattleStatsDouble(0, 0); // todo можно ввести связь с бустерами игрока, или ввести рандом на понижение сил скагрей var boosertsSummaryMods = new BattleStatsDouble(0, 0); var npcAllianceTeches = new BattleTeches(npc.NpcAllianceTeth.Teches); var userBaseUnitStats = npcTeches.GetBaseResultStats(); var userProfileUnitStats = npcTeches.GetProfileResultStats(); var allianceBaseUnitStats = npcAllianceTeches.GetBaseResultStats(); var allianceProfileUnitStats = npcAllianceTeches.GetProfileResultStats(); foreach (var unitStats in unitsStats) { var unitTechType = BattleTeches.UnitTypeToTechType(unitStats.Key); var statTypes = new Dictionary <BattleStatTypes, IBattleStatsDouble>(); var userUnitTechStat = userProfileUnitStats[unitTechType]; var allianceUnitTechStat = allianceProfileUnitStats[unitTechType]; var summaryMod = new BattleStatsDouble(0, 0); summaryMod.Add(userBaseUnitStats, false); summaryMod.Add(userUnitTechStat, false); summaryMod.Add(allianceBaseUnitStats, false); summaryMod.Add(allianceUnitTechStat, false); summaryMod.Add(officerBonus, false); summaryMod.Add(boosertsSummaryMods, true); statTypes.Add(BattleStatTypes.UnitStat, unitStats.Value.DoubleStats); statTypes.Add(BattleStatTypes.UserTechMod, userBaseUnitStats); statTypes.Add(BattleStatTypes.UserUnitProfileTechMod, userUnitTechStat); statTypes.Add(BattleStatTypes.AllianceTechMod, allianceBaseUnitStats); statTypes.Add(BattleStatTypes.AllianceUnitProfileTechMod, allianceUnitTechStat); statTypes.Add(BattleStatTypes.OfficerBonus, officerBonus); statTypes.Add(BattleStatTypes.BooserMod, boosertsSummaryMods); statTypes.Add(BattleStatTypes.SummaryMods, summaryMod); dic.Add(unitStats.Key, statTypes); } return(dic); }
private void CreateNpc(IDbConnection connection, NpcModel npc) { // _dbProvider.Exec(connection, sqlResetIdentity); var npcKey = npc.NpcUser.Id; // npc.NpcUser.Id = 0; var insertedUser = _gameUserService.AddOrUpdate(connection, npc.NpcUser); if (insertedUser.Id != npcKey && npcKey != 0) { throw new NotImplementedException("insertedUser.Id!= npcKey"); } npc.NpcUser.Id = insertedUser.Id; var npcAlliance = _allianceService.AddOrUpdate(connection, npc.NpcAlliance); if (npcAlliance.Id != npcKey) { throw new NotImplementedException("npcAlliance.Id != npcKey"); } npc.NpcAlliance.Id = npcKey; var npcAllianceUser = _allianceService.GetAllianceUserById(connection, npcKey); if (npcAllianceUser == null) { throw new NotImplementedException("creator alliance user incorrect"); } var password = Guid.NewGuid().ToString(); var npcChannel = _channelService.CreateAllianceChannel(connection, npcAlliance, password); if (npc.NpcUser.Id == Npc.ConfederationGameUserId) { _channelService.CreateMessage(connection, new ChannelMessageDataModel { UserId = npc.NpcUser.Id, DateCreate = UnixTime.UtcNow(), ChannelId = npcChannel.Id, UserName = npc.NpcUser.Nickname, Message = "Welcome to Confederation!", UserIcon = npc.NpcUser.Avatar.Icon }); } }
public IDictionary <ElfType, List <object> > Parse() { // Parse .data section Trace.WriteLine("Parsing .data"); var dataParser = new StringDataParser <NpcModel, RawNpcModel>(stringSection, new SimpleDataParser <RawNpcModel>(dataSection, dataRelocationTable, out var mainDataOffsets)); List <object> dataModels = dataParser.Parse()[ElfType.Main]; dataOffsets[ElfType.Main] = mainDataOffsets[ElfType.Main]; // Collect references to .rodata Trace.WriteLine("Collecting references to Model Files and State"); List <long> modelFilesOffsets = new List <long>(); List <int> modelFilesLengths = new List <int>(); List <long> stateOffsets = new List <long>(); List <int> stateLengths = new List <int>(); for (int i = 0; i < dataModels.Count; i++) { NpcModel model = (NpcModel)dataModels[i]; modelFilesOffsets.Add(model.model_files_ptr.AsLong); modelFilesLengths.Add(model.model_files_count); stateOffsets.Add(model.state_ptr.AsLong); stateLengths.Add(model.state_count); } // Parse .rodata section Trace.WriteLine("Parsing .rodata"); var filesParser = new StringDataParser <NpcModelFiles, RawNpcModelFiles>(stringSection, new NpcModelPartParser <RawNpcModelFiles>(rodataSection, modelFilesOffsets, modelFilesLengths, rodataRelocationTable)); var stateParser = new StringDataParser <NpcModelState, RawNpcModelState>(stringSection, new NpcModelPartParser <RawNpcModelState>(rodataSection, stateOffsets, stateLengths, rodataRelocationTable)); var filesData = filesParser.Parse()[ElfType.Main]; var stateData = stateParser.Parse()[ElfType.Main]; dataOffsets[ElfType.Files] = modelFilesOffsets; dataOffsets[ElfType.State] = stateOffsets; // Collect references to substate objects Trace.WriteLine("Collecting references to substate objects"); List <long> substateOffsets = new List <long>(); List <int> substateCounts = new List <int>(); for (int i = 0; i < stateData.Count; i++) { List <object> stateArr = (List <object>)stateData[i]; for (int j = 0; j < stateArr.Count; j++) { NpcModelState state = (NpcModelState)stateArr[j]; substateOffsets.Add(state.substate_arr.AsLong); substateCounts.Add(state.substate_count); } } // Parse substate Trace.WriteLine("Parsing substate objects"); var substateParser = new StringDataParser <NpcModelSubState, RawNpcModelSubState>(stringSection, new NpcModelPartParser <RawNpcModelSubState>(rodataSection, substateOffsets, substateCounts, rodataRelocationTable)); var substateData = substateParser.Parse()[ElfType.Main]; dataOffsets[ElfType.SubStates] = substateOffsets; return(new SortedDictionary <ElfType, List <object> > { { ElfType.Main, dataModels }, { ElfType.Files, filesData }, { ElfType.State, stateData }, { ElfType.SubStates, substateData }, }); }