Exemplo n.º 1
0
        private static void SpawnRandomMonsters()
        {
            if (!settings.spawnRandomMonsters)
            {
                return;
            }

            int            x1          = -600;
            int            x2          = 1000;
            int            z1          = -900;
            int            z2          = 900;
            int            numMonsters = rand.Next(settings.spawnRandomMonstersMin, settings.spawnRandomMonstersMax + 1);
            int            area        = (x2 - x1) * (z2 - z1);
            float          distance    = Mathf.Sqrt(area / numMonsters / 4);
            int            lvl         = Math.Min(Module <Player> .Self.ActorLevel, 60);
            List <Vector3> points      = new List <Vector3>();
            int            c           = 0;

            while (points.Count < numMonsters)
            {
                Vector3 v = new Vector3(rand.Next(x1, x2), 0, rand.Next(z1, z2));

                /*
                 * foreach (Vector3 p in points)
                 * {
                 *  if (Vector3.Distance(v, p) < distance)
                 *  {
                 *      continue;
                 *  }
                 * }
                 */
                Vector3 valid = GetValidPos(v);
                if (valid != Vector3.zero)
                {
                    int     idx = rand.Next((int)Math.Round(Math.Max(0, (lvl / 60f) * MonstersDungeon.Length - MonstersDungeon.Length / 2f)), (int)Math.Round(Math.Min(MonstersDungeon.Length - 1, (lvl / 60f) * MonstersDungeon.Length + MonstersDungeon.Length / 2f)));
                    Monster mm  = MonstersDungeon[idx];

                    int gangNo = rand.Next(1, settings.spawnRandomMonstersGroupMax + 1);

                    for (int i = 0; i < gangNo; i++)
                    {
                        Vector3 pos = GetValidPos(GetGroupPos(valid, i, 2f, 1f));
                        if (pos != Vector3.zero)
                        {
                            BossActorAgent agentM = new BossActorAgent(pos, Vector3.forward, mm.id, new Action <ActorAgent>(MonsterGangDeath));
                            Module <SpawnMgr> .Self.AddActorAgent(agentM);

                            agentM.Spawn();
                            points.Add(pos);
                        }
                    }
                }
                c++;
                if (c > numMonsters * 100)
                {
                    break;
                }
            }
        }
Exemplo n.º 2
0
        private static void SpawnBossMonster()
        {
            if (monsterAlive)
            {
                Vector3 pos = GetValidPos(bossMonster.pos.Value);
                agent = new BossActorAgent(pos, bossMonster.rot, bossMonster.id, new Action <ActorAgent>(MonsterDeath));

                Module <SpawnMgr> .Self.AddActorAgent(agent);

                agent.Spawn();
            }
        }