Esempio n. 1
0
        private bool CheckIfLocationIsFreeOfItems(IntVector2 location, MapGen_Room room)
        {
            bool locationFree = true;

            foreach (ItemData a in room.Items)
            {
                if (a.x == location.X && a.y == location.Y)
                {
                    locationFree = false;
                }
            }

            return(locationFree);
        }
Esempio n. 2
0
        private bool PlaceActorInRoom(string actorType, MapGen_Room room)
        {
            int  attempts    = 0;
            bool actorPlaced = false;

            while (attempts < 50 && !actorPlaced)
            {
                int tryX = rand.Next(1, room.Size.X - 1);
                int tryY = rand.Next(1, room.Size.Y - 1);

                if (CheckIfLocationIsFreeOfActors(new IntVector2(tryX, tryY), room))
                {
                    room.Actors.Add(new ActorData(tryX, tryY, actorType));
                    actorPlaced = true;
                }
                attempts++;
            }

            return(actorPlaced);
        }
Esempio n. 3
0
        private bool PlaceItemInRoom(string itemType, string parameter, MapGen_Room room)
        {
            int  attempts   = 0;
            bool itemPlaced = false;

            while (attempts < 50 && !itemPlaced)
            {
                int tryX = rand.Next(1, room.Size.X - 1);
                int tryY = rand.Next(1, room.Size.Y - 1);

                if (CheckIfLocationIsFreeOfItems(new IntVector2(tryX, tryY), room))
                {
                    ItemData data = new ItemData(tryX, tryY, itemType);
                    data.parameter = parameter;
                    room.Items.Add(data);
                    itemPlaced = true;
                }
                attempts++;
            }

            return(itemPlaced);
        }
Esempio n. 4
0
 private bool PlaceItemInRoom(string itemType, MapGen_Room room)
 {
     return(PlaceItemInRoom(itemType, "", room));
 }