Пример #1
0
        public bool SpawnNpc(DungeonArrayRoom room)
        {
            List<Loc2D> possiblePoints = new List<Loc2D>();
            for (int y = room.StartY; y <= room.EndY; y++) {
                for (int x = room.StartX; x <= room.EndX; x++) {
                    if (MapArray[x, y].Data.Type == PMDToolkit.Enums.TileType.Walkable && StartPoint != new Loc2D(x, y)) {
                        bool placeHere = true;
                        for (int n = 0; n < BasicMap.MAX_NPC_SLOTS; n++) {
                            if (!Npcs[n].dead && Npcs[n].CharLoc == new Loc2D(x, y)) {
                                placeHere = false;
                                break;
                            }
                        }
                        if (placeHere) {
                            possiblePoints.Add(new Loc2D(x, y));
                        }
                    }
                }
            }

            if (possiblePoints.Count > 0) {
                int npcIndex = rand.Next(1, 3);
                Npc npc = new Npc(possiblePoints[rand.Next(possiblePoints.Count)], (Direction8)rand.Next(8), npcIndex);
                AddNpc(npc);
                return true;
            }
            return false;
        }
Пример #2
0
        public void SpawnNpcs()
        {
            //spawn NPCs

            for (int i = 0; i < BasicMap.MAX_NPC_SLOTS; i++) {
                Npcs[i] = new Npc();
            }

            for (int i = 0; i < Rooms.GetLength(0); i++) {
                for (int j = 0; j < Rooms.GetLength(1); j++) {
                    if (Rooms[i, j].Opened == DungeonArrayRoom.RoomState.Open) {
                        int npcsPerRoom = rand.Next(minNpcsPerRoom, maxNpcsPerRoom + 1);
                        for (int n = 0; n < npcsPerRoom; n++) {
                            SpawnNpc(Rooms[i, j]);
                        }
                    }
                }
            }
        }
Пример #3
0
 public void SpawnNpc(Loc2D loc)
 {
     for (int i = 0; i < BasicMap.MAX_NPC_SLOTS; i++)
     {
         if (Npcs[i].dead)
         {
             int npcIndex = rand.Next(1, 3);
             Npcs[i] = new Npc(loc, (Direction8)rand.Next(8), npcIndex);
             break;
         }
     }
 }