void CreateMonster() { Monster monster = GameObject.Instantiate(monsterPrefab).GetComponent <Monster>(); monster.transform.position = transform.position + spawnOffset; group.AddMonster(monster); }
/// <summary> /// Spawn un groupe de monstre qui sera généré en fonction des constantes de générations. /// </summary> /// <param name="spawns"></param> /// <param name="quiet"></param> public void AddGeneratedMonsterGroup(AbstractMapInstance instance, MonsterSpawnRecord[] spawns, bool quiet) { AsyncRandom random = new AsyncRandom(); MonsterGroup group = new MonsterGroup(instance.Record); for (int w = 0; w < random.Next(1, instance.Record.BlueCells.Count + 1); w++) { int max = spawns.Sum((MonsterSpawnRecord entry) => entry.Probability); int num = random.Next(0, max); int num2 = 0; foreach (var monsterRecord in spawns) { num2 += monsterRecord.Probability; if (num <= num2) { MonsterRecord template = MonsterRecord.GetMonster(monsterRecord.MonsterId); Monster monster = new Monster(template, group, template.RandomGrade(random)); group.AddMonster(monster); break; } } } if (quiet) { instance.AddQuietEntity(group); } else { instance.AddEntity(group); } }
protected override MonsterGroup DequeueNextGroupToSpawn() { if (!Map.CanSpawnMonsters()) { StopAutoSpawn(); return(null); } lock (m_locker) { if (m_spawnsQueue.Count == 0) { return(null); } var spawn = m_spawnsQueue.Dequeue(); var group = new MonsterGroup(Map.GetNextContextualId(), new ObjectPosition(Map, spawn.Cell, (DirectionsEnum)spawn.Direction), this); foreach (var monsterGrade in spawn.GroupMonsters) { group.AddMonster(new Monster(monsterGrade, group)); } m_groupsSpawn.Add(group, spawn); return(group); } }
protected override MonsterGroup DequeueNextGroupToSpawn() { MonsterGroup result; if (!base.Map.CanSpawnMonsters()) { base.StopAutoSpawn(); result = null; } else { lock (this.m_locker) { if (this.m_spawnsQueue.Count == 0) { DungeonSpawningPool.logger.Error("SpawningPool Map = {0} try to spawn a monser group but m_groupsToSpawn is empty", base.Map.Id); result = null; } else { MonsterDungeonSpawn monsterDungeonSpawn = this.m_spawnsQueue.Dequeue(); MonsterGroup monsterGroup = new MonsterGroup(base.Map.GetNextContextualId(), new ObjectPosition(base.Map, base.Map.GetRandomFreeCell(false), base.Map.GetRandomDirection())); foreach (MonsterDungeonSpawnEntity current in monsterDungeonSpawn.GroupMonsters) { var monster = current.GenerateMonster(ref monsterGroup); if (monster != null) { monsterGroup.AddMonster(monster); } } if (monsterGroup.GetMonsters().Count() == 0) { DungeonSpawningPool.logger.Error("SpawningPool Map = {0} try to spawn a monser group but MonsterGroup is empty", base.Map.Id); result = null; } else { this.m_groupsSpawn.Add(monsterGroup, monsterDungeonSpawn); result = monsterGroup; } } } } return(result); }
public void APIStartMonsterBattle(int battleCell, string pattern) { MonsterGroup group = new MonsterGroup() { CellID = battleCell, }; foreach (var monster in pattern.Split('|')) { if (monster.Trim() != string.Empty) { var data = monster.Trim().Split(','); var m = MonsterHelper.GetMonsterTemplate(int.Parse(data[0])).GetLevel(int.Parse(data[1])); group.AddMonster(m); } } Handlers.GameHandler.StartMonstersBattle(this, group); }
/// <summary> /// Spawn un groupe fixe de mobs /// </summary> /// <param name="instance"></param> /// <param name="monsterRecords"></param> /// <param name="quiet"></param> public void AddFixedMonsterGroup(AbstractMapInstance instance, MonsterRecord[] monsterRecords, bool quiet) { MonsterGroup group = new MonsterGroup(instance.Record); foreach (var template in monsterRecords) { Monster monster = new Monster(template, group); group.AddMonster(monster); } if (quiet) { instance.AddQuietEntity(group); } else { instance.AddEntity(group); } }
protected virtual void Start() { group = GetComponent <MonsterGroup>(); //Debug.Log("GROUP IS NULL: " + (group == null) + " CHILD COUNT " + transform.childCount.ToString()); if (group != null) { for (int i = 0; i < this.transform.childCount; i++) { GameObject child = transform.GetChild(i).gameObject; Monster monst = child.GetComponent <Monster>(); //Debug.Log(this.name +" Group: "+ group+" Child: "+ child + "\t Monst: " + monst + " "+(i+1).ToString()+ "/" + this.transform.childCount.ToString()); group.AddMonster(monst); } } else { Debug.LogError("GROUP IS NULL!"); } }
public void AddFixedMonsterGroup(AbstractMapInstance instance, MonsterRecord[] monsterRecords, sbyte[] grades, bool quiet) { if (monsterRecords.Length != grades.Length) { throw new Exception("Record array must have same lenght that grade array."); } MonsterGroup group = new MonsterGroup(instance.Record); for (int i = 0; i < monsterRecords.Length; i++) { Monster monster = new Monster(monsterRecords[i], group, grades[i]); group.AddMonster(monster); } if (quiet) { instance.AddQuietEntity(group); } else { instance.AddEntity(group); } }