Ejemplo n.º 1
0
        public void Initialize(StoredData data)
        {
            size_x = data.stored_size_x;
            size_y = data.stored_size_y;

            SetupCamera();

            world = new Tile[size_x, size_y];

            for (int x = 0; x < size_x; x++)
            {
                for (int y = 0; y < size_y; y++)
                {
                    if (data.storedTiles[x, y].type != 0)
                    {
                        TilePhysical obj = Instantiate(tile_prefab, new Vector3(x - size_x / 2, 0, y - size_y / 2), Quaternion.identity, null);

                        int type = data.storedTiles[x, y].type;

                        world[x, y] = new Tile((Tile.Tiletype)type, false, obj);

                        world[x, y].obj.x         = x;
                        world[x, y].obj.y         = y;
                        world[x, y].obj.masterref = this;
                        world[x, y].SetColor(this);
                    }
                }
            }
            AssignNumbers();

            if (!SpawnPlayer())
            {
                Debug.Log("No Spawn region");
            }
        }
Ejemplo n.º 2
0
        public void CreateNew(int size_x, int size_y)
        {
            this.size_x = size_x;
            this.size_y = size_y;

            SetupCamera();


            world = new Tile[size_x, size_y];

            for (int x = 0; x < size_x; x++)
            {
                for (int y = 0; y < size_y; y++)
                {
                    TilePhysical obj = Instantiate(tile_prefab, new Vector3(x - size_x / 2, 0, y - size_y / 2), Quaternion.identity, null);

                    world[x, y] = new Tile(Tile.Tiletype.nothing, false, obj);

                    world[x, y].obj.x         = x;
                    world[x, y].obj.y         = y;
                    world[x, y].obj.masterref = this;
                    world[x, y].SetColor(this);
                    world[x, y].EditVisible();
                }
            }

            SpawnPlayer();
        }
Ejemplo n.º 3
0
        private void Query(int index)
        {
            RaycastHit hit;
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(ray, out hit, 100.0f))
            {
                TilePhysical tile = hit.transform.GetComponent <TilePhysical>();

                if (tile != null)
                {
                    if (index == 0)
                    {
                        tile.masterref.QueryActivate(tile.x, tile.y);
                    }
                    else
                    {
                        tile.masterref.QuerySeal(tile.x, tile.y);
                    }
                }
            }
        }
Ejemplo n.º 4
0
 public Tile(Tiletype currentTile, bool visible, TilePhysical obj)
 {
     value            = 0;
     this.currentTile = currentTile;
     this.obj         = obj;
 }
Ejemplo n.º 5
0
 //Constructors:
 public Tile(TilePhysical obj)
 {
     value       = 0;
     currentTile = Tiletype.normal;
     this.obj    = obj;
 }