Exemple #1
0
    private IEnumerator Generate(int cycle)
    {
        for (int i = 0; i < cycle; i++)
        {
            spawners.Clear();
            spawners = GameObject.FindGameObjectsWithTag("Spawner").ToList();

            foreach (GameObject spawner in spawners)
            {
                GameObject room  = rooms[Random.Range(0, rooms.Count)];
                RoomSpecs  specs = room.GetComponent <RoomSpecs>();

                Vector2 offset = specs.Offset;
                float   x      = spawner.transform.position.x;
                float   y      = spawner.transform.position.y;
                float   z      = spawner.transform.position.z;

                position = new Vector3(x + offset.x, y + offset.y, z);
                size     = specs.Size;

                colliderInRadius = Physics2D.OverlapBox(position, size, room.transform.rotation.z);
                if (colliderInRadius == null)
                {
                    Instantiate(room, spawner.transform.position, spawner.transform.rotation);
                }
                else
                {
                    Debug.Log("place wall");
                    Destroy(spawner);
                }
            }
            yield return(new WaitForSeconds(1f));
        }
    }
Exemple #2
0
        public static bool CreateRoom(this IRepository <IDbProperties> repository, RoomSpecs spec)
        {
            var dataTypes = new List <IDataTypes>
            {
                new DataTypes("@floor", SqlDbType.NVarChar, 50, spec.FloorId, ParameterDirection.Input, false, false, ""),
                new DataTypes("@tag", SqlDbType.NVarChar, 50, spec.Tag, ParameterDirection.Input, false, false, ""),
                new DataTypes("@room", SqlDbType.UniqueIdentifier, 0, string.Empty, ParameterDirection.Output, false, false, "@room")
            };
            var repos = new DbProperties("CreateRoom", dataTypes, string.Empty, true, "@room");
            var x     = repository.Update(new[] { repos });

            if (x > 0 || !string.IsNullOrWhiteSpace(repos.Id))
            {
                spec.RoomId = repos.Id;
                return(true);
            }
            return(false);
        }
Exemple #3
0
 public CreateRoom(RoomSpecs room)
 {
     Room = room;
 }