void InitiateActors() { AddModelToList(playerList, PlayerSession.GetProfile().GetCharacter(0)); AddModelToList(playerList, PlayerSession.GetProfile().GetCharacter(PlayerSession.GetProfile().party.member1)); AddModelToList(playerList, PlayerSession.GetProfile().GetCharacter(PlayerSession.GetProfile().party.member2)); AddModelToList(playerList, PlayerSession.GetProfile().GetCharacter(PlayerSession.GetProfile().party.member3)); AddModelToList(enemyList, MonsterLoader.LoadMonsterData(DungeonModel.enemy1, DungeonModel.lvEnemy1)); AddModelToList(enemyList, MonsterLoader.LoadMonsterData(DungeonModel.enemy2, DungeonModel.lvEnemy2)); AddModelToList(enemyList, MonsterLoader.LoadMonsterData(DungeonModel.enemy3, DungeonModel.lvEnemy3)); AddModelToList(enemyList, MonsterLoader.LoadMonsterData(DungeonModel.enemy4, DungeonModel.lvEnemy4)); enemyList.ForEach(enemy => InitEnemy(enemy)); }
private LevelContext CreateContext(LevelData leveldata) { CardLoader _cardLoader = new CardLoader(); MonsterLoader monsterLoader = new MonsterLoader(); CharacterLoader _characterLoader = new CharacterLoader(); //init level context LevelContext context = new LevelContext(); context.LevelData = leveldata; context.Player = _characterLoader.LoadUserCharacter(); context.EnemyList.AddRange(monsterLoader.LoadEnemies(leveldata.Level, leveldata.Mission)); context.ElementCardList.AddRange(_cardLoader.LoadUserCards(context.Player.Properties.ElementCards)); context.UltimateCardList.AddRange(_cardLoader.LoadUltimateCards(context.Player.Properties.UltimateCards)); return(context); }
// 导入武器数据 public void saveWeaponData() { if (excelData == null || excelData.Length == 0) { reverseData(); } string[] s1 = getOutputPath().Split('/'); string className = s1[s1.Length - 1].Split('.')[0]; Debug.Log("模式 :" + dataType); switch (dataType) { case "Weapon": Debug.Log("F**k Weapon"); WeaponLoader.exchangeData(className, excelData); break; case "Monster": MonsterLoader.exchangeData(className, excelData); break; } }
private void PlaceMonsters() { var monsterSpawns = MonsterLoader.LoadSpawns(ServerConfiguration.SpawnsFileName); var loadedCount = 0; var spawnsList = monsterSpawns as IList <Spawn> ?? monsterSpawns.ToList(); var totalCount = spawnsList.Sum(s => s.Count); var percentageCompleteFunc = new Func <byte>(() => (byte)Math.Floor(Math.Min(100, Math.Max((decimal)0, loadedCount * 100 / (totalCount + 1))))); var cts = new CancellationTokenSource(); Task.Factory.StartNew( () => { while (!cts.IsCancellationRequested) { // TODO: proper logging Console.WriteLine($"Monster placed percentage: {percentageCompleteFunc()} %"); Thread.Sleep(TimeSpan.FromSeconds(7)); // TODO: this is arbitrary... } }, cts.Token); var rng = new Random(); Parallel.ForEach(spawnsList, spawn => { Parallel.For(0, spawn.Count, i => { // var halfRadius = spawn.Radius / 2; var placed = false; byte tries = 1; do { // TODO: revisit this logic var randomLoc = spawn.Location + new Location { X = (int)Math.Round((i * Math.Cos(rng.Next(360))) - i), Y = (int)Math.Round((i * Math.Cos(rng.Next(360))) - i), Z = 0 }; var randomTile = GetTileAt(randomLoc); if (randomTile == null) { continue; } // Need to actually pathfind to avoid placing a monster in unreachable places. Pathfind(spawn.Location, randomTile.Location, out Location foundLocation, (i + 1) * 100); var foundTile = GetTileAt(foundLocation); if (foundTile != null && !foundTile.BlocksPass) { Functions.MonsterOnMap(foundLocation, spawn.Id); placed = true; } }while (++tries != 0 && !placed); if (!placed) { // TODO: proper logging Console.WriteLine($"Given up on placing monster with type {spawn.Id} around {spawn.Location}, no suitable tile found."); } Interlocked.Add(ref loadedCount, 1); });