public void RealStart(bool[,] blockArray, int direction, int team_id, Color color)
    {
        // blockArray should be 5x5
        blocks = new GameObject[5, 5];
        System.Random rand = new System.Random();

        string[] FileList = Directory.GetFiles(@"C:\temp2\", "*.png");
        byte[] bytes;
        bytes = System.IO.File.ReadAllBytes(FileList[rand.Next(0, FileList.Length -1)]);

        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 5; j++) {
                if(blockArray[i, j]){
                    Vector3 newPos = transform.position + new Vector3(direction*j*block.GetComponent<Renderer>().bounds.size.x,
                                                                      -i*block.GetComponent<Renderer>().bounds.size.y, 0);
                    GameObject b = (GameObject)Instantiate(block, newPos, Quaternion.identity);
                    b.GetComponent<Mover>().MoveSpeed = direction * 1.5f;
                    b.GetComponent<Mover>().team_id = team_id;
                    Texture2D tex = new Texture2D(12, 12);
                    ///while(!www.isDone) { }
                    ///www.LoadImageIntoTexture(tex);
                    tex.LoadImage(bytes);
                    TextureScale.Bilinear(tex, 12, 12);
                    Sprite sprite = Sprite.Create(tex, new Rect(0, 0, 12, 12), new Vector2(0, 0));
                    b.GetComponent<SpriteRenderer>().sprite = sprite;
                    b.GetComponent<SpriteRenderer>().color = color;
                    blocks[i, j] = b;
                }
            }
        }
        LastBlocks = BlockAmount();
    }
Example #2
0
    // Use this for initialization
    void Start()
    {
        _rowSelector = GameObject.Find("PuzzleGrid/RowSelector");
        _currentlySelectedRow = 1;
        _gridVerticalSize = 4;
        //instantiate puzzle grid
        _puzzleGrid = new PuzzleNode[4,GridHorizontalSize];

        //Create array of gameobjects in game where puzzle nodes are placed
        _anchors = new GameObject[_gridVerticalSize,GridHorizontalSize];
        for (int row = 0; row < _anchors.GetLength(0); row++)
        {
            for (int col = 0; col < _anchors.GetLength(1); col++)
            {
                //find current lane's left and right anchors
                var currentLaneLeftAnchor = GameObject.Find("LaneAnchors/Row" + row + "/Left");
                var currentLaneRightAnchor = GameObject.Find("LaneAnchors/Row" + row + "/Right");
                //divide the distance of anchors by amount of anchors to determine spacing between them
                float rowAnchorSpacing = Vector3.Distance(currentLaneLeftAnchor.transform.position,currentLaneRightAnchor.transform.position)/GridHorizontalSize;
                //create new vector3 for where the current anchor will be placed
                var putAnchorAt = new Vector3(currentLaneLeftAnchor.transform.position.x + rowAnchorSpacing * col,0);
                //create game object, name it, make it's parent the parent of the rest of the row elements
                var currentAnchor = (GameObject) Instantiate(Resources.Load<GameObject>("Prefabs/PuzzleNode"));
                currentAnchor.name = row + "_" + col;
                currentAnchor.transform.parent = GameObject.Find("LaneAnchors/Row" + row).transform;
                //change it's position
                currentAnchor.transform.localPosition = putAnchorAt;
                //add game object to array
                _anchors[row, col] = currentAnchor;
            }
        }
    }
 public void criarMapas()
 {
     Mapas = new GameObject[3, 3];
     for (int cont = 0; cont < 3; cont++)
     {
         for (int cont2 = 0; cont2 < 3; cont2++)
         {
             GameObject mapa = GameObject.Instantiate(MapaPadrao) as GameObject;
             mapa.GetComponent<Mapa>().CriarMapa();
             if(cont == 1 && cont2 == 1)
             {
                 mapa.GetComponent<Mapa>().comprado = true;
                 mapa.GetComponent<Mapa>().setComprador(true);
             } else
             {
                 mapa.GetComponent<Mapa>().comprado = false;
                 mapa.GetComponent<Mapa>().setComprador(false);
             }
             //mapa.GetComponent<Mapa>().Save(cont,cont2);
             Mapas[cont, cont2] = mapa;
         }
     }
     saveMapas();
     destroiMapas();
     load(1, 1);
     gerenciadorObjetosCenario.clonesEstruturaEmPosicao();
 }
Example #4
0
 public void Begin()
 {
     Debug.Log (text.text);
     string[] strs = text.text.Split ('\n');
     row = strs.Length;
     col = strs [0].Length;
     mArray = new int[row, col];
     for (int i=0; i<row; i++)
     for (int j=0; j <col ; j++)
     {
         mArray[j,row-1-i]=(int)strs[i][j]-48;
     //			Debug.Log(i+","+j+","+strs[i][j]+",");
     //			Debug.Log(row-1-i+","+j+","+strs[i][j]+",");
     }
     cellGameObjects=new GameObject[row,col];
     for (int i=0; i<row; i++)
     for (int j=0; j<col; j++) {
         GameObject quad = GameObject.CreatePrimitive(PrimitiveType.Quad);
         quad.transform.position=new Vector3(i+spacing*i,j+spacing*j);
         cellGameObjects[i,j]=quad;
     }
     Camera.main.transform.position = new Vector3 ((row-1 + spacing * (row - 1)) / 2, (col-1 + spacing * (col - 1)) / 2,-10);
     Camera.main.orthographicSize = 1f+Mathf.Max ((row-1 + spacing * (row - 1)) / 2, (col-1 + spacing * (col - 1)) / 2);
     //GameOfLife2 (mArray);
     //ShowResult();
     StartCoroutine (Calculate ());
 }
Example #5
0
    //called as constructor
    public void Awake()
    {
        //rows = 10;
        //columns = 10;
        entrance = new Vector2(-1, -1);
        exit = new Vector2(-1, -1);
        cases = new GameObject[columns, rows];
        walls = new Wall[columns, rows];
        deadends = new List<Vector2>();
        visited = new bool[columns, rows];

        for (int i = 0; i < columns; i++)
        {
            for (int j = 0; j < rows; j++)
            {
                visited[i, j] = false;
                walls[i, j] = Wall.RD;
            }
        }
        //Instantiate cells
        for (int i = 0; i < columns; i++)
        {
            for (int j = 0; j < rows; j++)
            {
                cases[i, j] = (GameObject) Instantiate(cell, new Vector3(i - 4.5f, 0f, j - 4.5f), Quaternion.identity);
            }
        }
    }
 void Awake()
 {
     towers = new GameObject[MapData.rows,MapData.columns];
     for (int i = 0; i < MapData.rows; i++)
         for (int a = 0; a < MapData.columns; a++)
             towers[i, a] = null;
 }
    // Use this for initialization
    void Start()
    {
        timeToAct += turnTime;

        airplane = new Airplane ();
        grid = new GameObject[numCubesX, numCubesY];

        //setting airplane location
        airplane.x = 0;
        airplane.y = 8;

        //setting cargo info
        airplane.cargo = 0;
        airplane.cargoCapacity = 90;

        //spawn all the grid
        for (int x = 0; x < numCubesX; x++) {
            for (int y = 0; y < numCubesY; y++) {
                grid[x,y] = (GameObject) Instantiate (cubePrefab, new Vector3(x*2 - 14, y*2 - 8, 10), Quaternion.identity);
                grid[x,y].GetComponent<CubeBehavior>().x = x;
                grid[x,y].GetComponent<CubeBehavior>().y = y;
            }
        }

        //set airplane as red
        grid [0, 8].GetComponent<Renderer>().material.color = Color.red;

        //set depot as black
        grid [15, 0].GetComponent<Renderer>().material.color = Color.black;
    }
    // Use this for initialization
    void Start()
    {
        Renderer tileRenderer = tileA.GetComponent<Renderer>();
        tileWidth = tileRenderer.bounds.size.x;
        tileHeight = tileRenderer.bounds.size.y;
        float anchorX = anchor.transform.position.x;
        float anchorY = anchor.transform.position.y;
        Debug.Log (anchorX);
        Debug.Log (anchorY);

        tiles = new GameObject[columns, rows];
        for (int i = 0; i < columns; ++i) {
            for (int j = 0; j < rows; j++) {
                float x = ((tileWidth) * i) - (anchorX / 2);
                float y = ((tileHeight) * j) - (anchorY / 2);

                if (i == 0 && j == 0) {
                    //Debug.Log (bgX);
                    //Debug.Log (bgY);
                    Debug.Log (tileWidth);
                    Debug.Log (tileHeight);
                    //Debug.Log (x);
                    //Debug.Log (y);
                }

                // alternating tiles
                var tile = tileA;
                if ((j % 2) == 0) {
                    tile = tileB;
                }

                tiles[i, j] = (GameObject)Instantiate(tile, new Vector3(x, y, tileLayer), Quaternion.identity);
            }
        }
    }
Example #9
0
        void Start()
        {
            world = WorldControler.Instance.World;
            go_actor = new Dictionary<Actors.Actor, GameObject>();
            if (world == null)
            {
                Debug.LogError("No world?!");
                return;
            }

            go_tiles = new GameObject[world.Width, world.Hight];
            System.Random rnd = new System.Random();
            //Create game objets for each tile
            for (int x = 0; x < world.Width; x++)
            {
                for (int y = 0; y < world.Hight; y++)
                {
                    GameObject tile_go = new GameObject();
                    tile_go.name = "Tile_" + x + "_" + y;
                    tile_go.transform.position = new Vector3(world[x, y].X, world[x, y].Y);
                    tile_go.transform.SetParent(this.transform, true);
                    SpriteRenderer tile_sr = tile_go.AddComponent<SpriteRenderer>();
                    tile_sr.sortingLayerName = "Tiles";
                    go_tiles[x, y] = tile_go;
                    SetTileSprite(x, y, tile_go, rnd);
                }
            }
            SetHeroSprite();
            world.TileTypeChanged += w_TileTypeChange;
            world.ActorMoved += MoveActorSprite;
        }
Example #10
0
    void Start()
    {
        //Set up NodeMap
        xOffSet = 1-(Node.minX);
        yOffSet = 1-(Node.minY);
        nodeMap = new GameObject[(Node.maxX+xOffSet+2),(Node.maxY+yOffSet+2)]; //+2 is to create a buffer edge
        //Populate empty map
        for(int x=0;x<(nodeMap.GetLength(0));x++){
            for(int y=0;y<(nodeMap.GetLength(1));y++){
                nodeMap[x,y] = null;
            }
        }

        //Stick nodes in the map
        GameObject[] temp = GameObject.FindGameObjectsWithTag("Node");
        for(int i=0;i<temp.Length;i++){
            Node node = temp[i].GetComponent<Node>();
            node.refactorX(xOffSet);
            node.refactorY(yOffSet);
            nodeMap[node.getX(),node.getY()]=temp[i];
        }

        //Now that they're in the big map, tell them who
        //the neighbours are.
        for(int i=0;i<temp.Length;i++){
            Node node = temp[i].GetComponent<Node>();
            node.mapNeighbours();
        }

        //Identify the Player.
        player = GameObject.FindGameObjectWithTag("Player");
        //PrintDimensions();
        PrintMap();
    }
Example #11
0
	void Start () {

		BoardCreator bc = gameObject.GetComponent<BoardCreator>();
		int size=bc.getBoardSize();
		print(size);
		tileSheet = new GameObject[size,size];
	}
Example #12
0
    // Use this for initialization
    void Start()
    {
        var arenaSize = Arena.Instance.GetArenaSize();
        var gridSize = mapSize / arenaSize.y;
        GridMap = new GameObject[(int)arenaSize.x, (int)arenaSize.y];

        // create the minimap grid squares to match arena size
        for(var x = 0; x < arenaSize.x; x++)
        {
            for(var y = 0; y < arenaSize.y; y++)
            {
                var sq = (GameObject)Instantiate(GridSquarePrefab);
                sq.transform.SetParent(transform);
                var rect = sq.GetComponent<RectTransform>();
                rect.sizeDelta = new Vector2(gridSize, gridSize);
                var posx = (x * gridSize) + (x); //<-- leave a gap of 1px for every sq except the first one
                var posy = (y * gridSize) + (y); //<-- leave a gap of 1px for every sq except the first one
                sq.transform.localPosition = new Vector3(posx, posy, 0);

                GridMap[x,y] = sq;

                var info = Arena.Instance.GetGridSquare(x, y);
                GridContentsChanged(info);
            }
        }

        var myrect = GetComponent<RectTransform>();
        myrect.sizeDelta = new Vector2((arenaSize.x * gridSize) + arenaSize.x, (arenaSize.y * gridSize) + arenaSize.y);
        myrect.localPosition = new Vector3(-myrect.sizeDelta.x / 2, myrect.localPosition.y + 16, 0);

        Arena.Instance.OnGridContentsChanged.AddListener(GridContentsChanged);
    }
Example #13
0
    public void JewelMapCreate(int[,] Map)
    {
		JewelGrib = new GameObject[GameController.WIDTH, GameController.HEIGHT];

		JewelGribScript = new JewelObj[GameController.WIDTH, GameController.HEIGHT];

		for (int x = 0; x < GameController.WIDTH; x++)
        {
            int s = 0;
			for (int y = 0; y < GameController.HEIGHT; y++)
            {
                if (GribManager.cell.GribCellObj[x, y] != null && GribManager.cell.GribCellObj[x, y].cell.CellEffect == 4)
                    s = y;
            }
			for (int y = s; y < GameController.HEIGHT; y++)
            {
                if (Map[x, y] > 0)
                {
                    RJewelInstantiate(x, y);
                }
            }
        }

        while (!Supporter.sp.isNoMoreMove())
        {
            RemakeGrib();
            JewelMapCreate(Map);
        }
    }
Example #14
0
    // Use this for initialization
    void Start()
    {
        m_Grid = new GameObject[m_iSize, m_iSize];

        for (int i = 0; i <m_iSize; i++)
            for (int j = 0; j <m_iSize; j++) {
                GameObject kachel = GameObject.CreatePrimitive (PrimitiveType.Quad);
                m_Grid [i, j] = kachel;
                kachel.transform.position = new Vector3 (i, j, 0);
                kachel.transform.parent = this.transform;

                kachel.name = "kachel(" + i + "," + j + ")";

                if (Random.value < 0.5) {
                    kachel.GetComponent<Renderer> ().material.color = Color.black;
                }

                Camera.main.transform.position = new Vector3 (m_iSize / 2, m_iSize / 2, -10);
                Camera.main .orthographicSize = m_iSize;

            }

        transform.position = new Vector3 (0.5f, 0.5f, 0);

        int iCol = 3;
        int iRow = 3;
        print ("Anzahl Nachbarn (" + iCol + "," + iRow + "): " + GetAliveN (iCol, iRow));
    }
Example #15
0
        void Start()
        {
            GameObject tempPar = new GameObject("ElasticLine");
            _lineParts = new GameObject[10, 2];

            for (int j = 0; j < 2; j++)
            {
                for (int i = 0; i < (int)(_elasticLengthInUnits * 0.5f * 10); i++)
                {
                    GameObject temp = _lineParts[i, j];
                    temp.transform.parent = tempPar.transform;
                    temp = GameObject.CreatePrimitive(PrimitiveType.Cube);

                    if (j == 0)
                        temp.transform.position = new Vector3(temp.transform.position.x + i,temp.transform.position.y,temp.transform.position.z);
                    //Set these up on the left
                    else
                        temp.transform.position = new Vector3(temp.transform.position.x + -i,temp.transform.position.y,temp.transform.position.z);
                    //set these up on the right.

                    temp.AddComponent<ElasticBehaviour>();

                    temp.GetComponent<ElasticBehaviour>().MaxElasticLength = 2;
                    temp.GetComponent<ElasticBehaviour>().MinElasticLength = 1;
                    temp.AddComponent<BoxCollider>();

                    _lineParts[i,j] = temp;
                }
            }
        }
 public GameObjectGrid(int rows, int columns, string id = "")
 {
     grid = new GameObject[columns, rows];
     for (int x = 0; x < columns; x++)
         for (int y = 0; y < rows; y++)
             grid[x, y] = null;
 }
Example #17
0
    // Use this for initialization
    void Start()
    {
        tileViewers = new GameObject[width, height];
        elementViewers = new GameObject[width, height];

        GameObject mapViewer = new GameObject("MapViewer");
        GameObject tiles = new GameObject("Tiles");
        GameObject elements = new GameObject("Elements");

        tiles.transform.parent = mapViewer.transform;
        elements.transform.parent = mapViewer.transform;

        for(int Y = 0; Y < height; Y++) {

            for(int X = 0; X < width; X++) {

                GameObject newTile = Instantiate(Resources.Load ("Tiles/Tile")) as GameObject;
                newTile.transform.position = new Vector3(X, -Y, 0);
                newTile.name = "Tile " + X + ", " + Y;
                newTile.transform.parent = tiles.transform;
                tileViewers[X,Y] = newTile;

                GameObject newElement = Instantiate(Resources.Load ("Tiles/Tile")) as GameObject;
                newElement.transform.position = new Vector3(X, -Y, -1);
                newElement.name = "Element " + X + ", " + Y;
                newElement.transform.parent = elements.transform;
                elementViewers[X,Y] = newElement;
            }
        }

        InvokeRepeating("Refresh", 0, refreshRate);
    }
Example #18
0
    void createCube()
    {
        cubeTileArray = new GameObject[width, height];

        Vector3 size = cube.GetComponent<Renderer>().bounds.size;

        for (int y = 0; y < height; y++)
        {
            for (int x = 0; x < width; x++)
            {
                Vector3 pos = new Vector3(posX, 0, posZ);
                GameObject newTile = Instantiate(cube, pos, cube.transform.rotation) as GameObject;
                newTile.transform.SetParent(this.transform, false);

                cubeTileArray[x, y] = newTile;

                posX += size.x;

            }

            posZ += size.z;
            posX = 0;

        }
    }
Example #19
0
    private void initLevelData()
    {
        tileEarth = Resources.Load("Sprite_Earth") as GameObject;

        tileBlockade1 = Resources.Load("Blockade_1") as GameObject;
        tileBlockade2 = Resources.Load("Blockade_2") as GameObject;
        tileBlockade3 = Resources.Load("Blockade_3") as GameObject;
        tileStart = Resources.Load("Sprite_Player01_Start") as GameObject;
        tileEvent = Resources.Load("Sprite_Player02_Start") as GameObject;

        levelVisualisation = new GameObject[maxSizeElementsArray,maxSizeElementsArray];
        try
        {
            for (int x = 0; x < 10; x++)
            {
                for (int y = 0; y <10; y++)
                {
                    GameObject newtile = Instantiate(selectTile(lvlInformation[x, y]), new Vector3(x + 5, y + 5, 0) + zeroPointLevel, Quaternion.Euler(Vector3.zero)) as GameObject;

                    levelVisualisation[x, y] = newtile;
                }
            }
        }

        catch (System.Exception e)
        {
            Debug.Log(e.Message);

        }
    }
Example #20
0
    void CreateHexGrid() {
        hexes = new GameObject[gridWidthInHexes, gridHeightInHexes];

        //Loop for Hex Rows
        for (int y = 0; y < gridHeightInHexes; y++)
        {
            //Loop for Hex Columns
            for (int x = 0; x < gridWidthInHexes; x++)
            {
                Vector2 gridPosition = new Vector2(x, y);
                
                //Create a clone of the supplied Hex object
                //GameObject hex = (GameObject)Instantiate(Hex);
                hexes[x, y] = (GameObject)Instantiate(hex);
                
                hexes[x, y].GetComponent<GridTile>().myGridPosition = gridPosition;
               
                
                //Get the current x,y of loop to place Hex | column 5, row 3, etc.
                //Vector2 gridPosition = new Vector2(x, y);
                
                //Center of grid is 0,0,0 figure out the pixel coordinates of this hex based on it's x,y
                //hex.transform.position = calculateWorldCoordinates(gridPosition);
                hexes[x, y].transform.position = CalculateWorldCoordinates(gridPosition);
                
                //Add the hex to the parent ojbect
                //hex.transform.parent = gridParent.transform;
                hexes[x, y].transform.parent = gridParent.transform;
                
            }
        }
    }
Example #21
0
    // Use this for initialization
    public GameObject[,] createGameGrid()
    {
        grid = new GameObject[gridWidth,gridHeight];

        for(int i = 0; i < gridWidth; i++)
        {
            for(int j = 0; j < gridHeight; j++)
            {
                GameObject tile = (GameObject)Instantiate(gridTile);
                tile.transform.position = new Vector3(i,0,j);
                tile.tag = "Tile";

                grid[i,j] = tile;
            }
        }

        /*		for(float i = 0.0f; i <= gridWidth*1.1f; i+=2.2f)
        {
            for(float j = 0.0f; j <= gridHeight*1.1f; j+=2.2f)
            {
                GameObject light = (GameObject)Instantiate(edgeLight);
                light.transform.position = new Vector3(i-0.5f,0,j-2f);
            }
        }
        */
        GameObject light = (GameObject)Instantiate(GlobalLight);
        light.transform.position = light.transform.position;

        return grid;
    }
Example #22
0
    void Start()
    {

        boxesArray = new GameObject[100, 100];
        for (int i = 0; i < 100; i++)
        {
            for (int j = 0; j < 100; j++)
            {
                GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                boxesArray[i, j] = cube;
                cube.transform.position = new Vector3(i, 30, j);
                cube.AddComponent<BoxCollider>();
                cube.name = i + " " + j;
                cube.layer = 8;
                cube.GetComponent<Renderer>().material.color = Color.gray;
            }
        }

//		fogOfWarColor = new Color (170, 170, 170, 1);
//		transparentColor = new Color (200, 200, 200, 0.5f);
//		// renders the objects
//		var renderer = GetComponent<Renderer> ();
//		// get the material of object
//		Material fogOfWarMat = null;
//		if (renderer != null) {
//			fogOfWarMat = renderer.material;
//		}
//		texture = new Texture2D (100, 100, TextureFormat.RGBA32, false);
//		texture.wrapMode = TextureWrapMode.Clamp;
//		fogOfWarMat.mainTexture = texture;
    }
Example #23
0
 private void MakeMap(Map map)
 {
     mapped = new GameObject[map.map_w,map.map_h];
     //Create Map
     for (int i=0; i<map.map_h; i++) {
         for (int j=0; j<map.map_w; j++) {
             GameObject hex;
             if (Misc.IsEven (j)) {
                 hex = (GameObject)Instantiate (hexPrefab, new Vector3 (j * Config.hex_x_offset, 0,
                                                -Config.hex_h * i), Quaternion.identity);
             } else {
                 hex = (GameObject)Instantiate (hexPrefab, new Vector3 (j * Config.hex_x_offset, 0,
                                                -(Config.hex_h * i) - Config.hex_y_offset), Quaternion.identity);
             }
             mapped[j,i] = hex;
             //put hex as child of map
             hex.transform.parent = this.gameObject.transform;
             SDL_Surface hexTex;
             //Draw Terrain
             hexTex = map.map_draw_terrain (j, i);
             if (map.map [j, i].g_unit != null || map.map [j, i].a_unit != null) {
                 hexTex = map.map_draw_units (hexTex, j, i, !Engine.Air_mode, false);
             }
             hex.renderer.material = hexTex.BitmapMaterial;
         }
     }
     Engine.status = STATUS.STATUS_NONE;
 }
Example #24
0
    /*int GetAliveNeighbours (int _iColumn, int _iRow)
    {
        int iAliveNeighbours = 0;
        //nachbarn für feld 3,8 wäre column 2-4 und row 7-9 (im range 1)
        for (int iColumn = _iColumn -1; iColumn <= _iColumn +1; iColumn++)
        {
            for (int iRow = _iRow -1; iRow <= _iRow -1; iRow++)
            {
                if (iColumn == _iColumn && iRow == _iRow)
                    continue;

                if (iColumn >= 0 && iColumn < m_iSize && iRow >= 0 && iRow < m_iSize &&
                    m_Grid[iColumn, iRow].GetComponent<Renderer>().material.color == Color.blue) //Check Range/Bounce
                    iAliveNeighbours++;
            }
        }
        return iAliveNeighbours;
    }*/
    // Use this for initialization
    void Start()
    {
        m_Grid = new GameObject[m_iSize, m_iSize];

        for (int i = 0; i < m_iSize; i++)
        for (int j = 0; j < m_iSize; j++)
        {
            GameObject kachel = GameObject.CreatePrimitive(PrimitiveType.Quad);
            kachel.name = "Kachel(" + i + "," + j + ")";
            m_Grid[i, j] = kachel;
            kachel.transform.position = new Vector3 (i, j, 0);
            kachel.transform.parent = this.transform;
        }
        Camera.main.transform.position = new Vector3 (m_iSize/2, m_iSize/2, -100);
        Camera.main.orthographicSize = m_iSize;

        transform.position = new Vector3 (0.5f, 0.5f, 0);

        for (int i = 0; i < m_iSize; i++)
        for (int j = 0; j < m_iSize; j++)
        {
            float farben = Random.value;
            if (farben <= 0.5)
                SetAlive (i, j, true);//m_Grid [i, j].GetComponent<Renderer>().material.color = Color.blue;
            else
                SetAlive (i, j, false);//m_Grid [i, j].GetComponent<Renderer>().material.color = Color.white;
        }
        print ("Anzahl Nachbarn: " + GetAliveNeighbours (1, 1));
        Debug.Log (GetAliveNeighbours (9, 9));

        //KillAll ();
    }
Example #25
0
    public void generateNewStage(GameObject floorTile,
		                         GameObject wallBlock,
	                             GameObject coin,
	                             GameObject player,
	                             GameObject targetSprite,
	                             GameObject door,
		                         int difficulty,
	                             int maxDifficulty)
    {
        // Grab prefabs from function call
        _floorTile = floorTile;
        _wallBlock = wallBlock;
        _coin = coin;
        _player = player;
        _targetSprite = Instantiate(targetSprite);
        _door = door;
        // Determine size and num coins for this stage
        determineParamsBasedOnDifficulty(difficulty, maxDifficulty);
        // Create our maze
        _maze = new Maze(_size, difficulty, maxDifficulty);
        _maze.generateMap();
        // Allocate our arrays
        _coins = new GameObject[_numCoins];
        _components = new GameObject[(int)_size.x,(int)_size.y];
        // Instantiate our prefabs
        placeComponentsFromMap();
    }
Example #26
0
    void Awake()
    {
        //Get size of sprite
        Renderer rend = (Renderer)Tile.GetComponent(typeof(Renderer));
        tileSize = rend.bounds.size.x;
        //Debug.Log("TileSize: " + tileSize);
        //Create Arrays
        coordinates = new Vector3[4, 4];
        tileGrid = new GameObject[4, 4];

        //Initialize Arrays
        initArrays();

        //Update edges
        BotLeft = coordinates[0, 0];
        BotLeft.x -= (float)tileSize / 2;
        BotLeft.y -= (float)tileSize / 2;

        TopRight = coordinates[3, 3];
        TopRight.x += (float)tileSize / 2;
        TopRight.y += (float)tileSize / 2;

        //The distance between two tile
        tileDistance = tileSize + margin;
        //Debug.Log("tileDistance: " + tileDistance);
    }
Example #27
0
    void Start()
    {
        int numQuadX = camera.pixelWidth / quadPixelSize + 1;
        int numQuadY = camera.pixelHeight / quadPixelSize + 1;

        quads = new GameObject[numQuadX + 1, numQuadY + 1];

        Vector3 worldStartPosition = camera.ViewportToWorldPoint(Vector3.zero);
        Vector3 worldOffset = camera.ScreenToWorldPoint(new Vector3(quadPixelSize, quadPixelSize, 2)) - camera.ScreenToWorldPoint(Vector3.zero);

        baseScale = new Vector3(worldOffset.x + overlap, worldOffset.y + overlap, 1);

        for (int xi = 0; xi <= numQuadX; xi++) {
            for (int yi = 0; yi <= numQuadY; yi++) {
                Vector3 position = worldStartPosition + Vector3.Scale(worldOffset, new Vector3(xi, yi, 1));

                quads[xi, yi] = (GameObject)Instantiate(screenTransitionQuad, position, Quaternion.identity);
                quads[xi, yi].name = "Screen Transition Quad (" + xi + ", " + yi + ")";
                quads[xi, yi].transform.parent = transform;

                quads[xi, yi].transform.localScale = baseScale;
            }
        }

        time = domainMin;
        targetTime = domainMax;

        nextSceneName = "";

        instance = this;

        isTransitioning = true;
        StartCoroutine(setTransitioningFalse(0.5f));
    }
Example #28
0
    IEnumerator GenerateGrid(int columnCount)
    {
        grid.m_Column = columnCount;
        cellArray = new GameObject[columnCount*columnCount, columnCount*columnCount];
        yield return new WaitForEndOfFrame ();

        for (var i = 0; i < columnCount; i++)
        {
            for(var j = 0; j < columnCount; j++)
            {
                cellArray[i,j] = (GameObject)Instantiate(cell, new Vector3(1, 1, 1), Quaternion.identity);
                cellArray[i,j].transform.SetParent(grid.transform);
                cellArray[i,j].transform.localScale = new Vector3(1, 1, 1);
                cellArray[i,j].name = "Cell[" + i + "][" + j + "]";

                cellList.Add (cellArray[i,j]);

                cellHandler = cellArray[i,j].GetComponent<CellHandler> ();
                cellHandler.CoordX = i;
                cellHandler.CoordY = j;

                // Add color:
                var rand = Random.Range (0,2);

                if (rand == 1) {
                    cellHandler.cellStatus = CellHandler.Status.On;
                    cellArray[i,j].GetComponent<CanvasRenderer> ().SetColor (new Color32 (135, 204, 196, 255));
                } else {
                    cellHandler.cellStatus = CellHandler.Status.Off;
                    cellArray[i,j].GetComponent<CanvasRenderer>().SetColor (new Color32 (128, 128, 128, 128));
                }
            }
        }
    }
    //when player clicks on plane, make the color change/have airplane glow to show it's activated
    //if player clicks active plane it deactivates (changes back to red/stop glowing)
    //if there is no active airplane, don't do anything, no teleportation, nothing
    // Use this for initialization
    void Start()
    {
        allCubes = new GameObject[gridWidth,gridHeight];
        for(int x = 0; x < gridWidth; x++) {
            for (int y = 0; y < gridHeight; y++){
            allCubes[x,y] = (GameObject) Instantiate (Cube, new Vector3 (x*2, y*2, 0), Quaternion.identity);

            allCubes[x,y].GetComponent<CubeBehavior>().x = x;
            allCubes[x,y].GetComponent<CubeBehavior>().y = y;
            }
            print ("Cubes spawned");
            //reaching into CubeBehavior script, which is tracking the plane position
            //uses those coordinates in cubes spawned here (in allCubes)
        }

        airplane = new Aiplane ();

        airplane.x = 0;
        airplane.y = 8;
        if(airplane.x == 0 && airplane.y == 8){
            allCubes[airplane.x,airplane.y].GetComponent<Renderer>().material.color = Color.red;
        }

        print ("load airplane");
    }
Example #30
0
 public void LoadMap()
 {
    var path =  EditorUtility.OpenFilePanel("Select a Map", @"\Assets\Maps", "map");
    if (path.Length == 0)
        return;
    StreamReader Mapreader = new StreamReader(path);
    Mapreader.ReadLine();
    var htext = Mapreader.ReadLine().Split(' ')[1];
    var wtext = Mapreader.ReadLine().Split(' ')[1];
    Mapreader.ReadLine();
    var height  = Int32.Parse(htext);
    var width = Int32.Parse(wtext);
    Char[] mapline = new char[width];
    Char[,] FinalMap = new char[height,width];
    for (int i = 0; i < height; ++i)
    {
        mapline = Mapreader.ReadLine().ToCharArray();
        for (int j = 0; j < width; ++j)
        {
            FinalMap[i, j] = mapline[j];
        }
    }
    AiMap = FinalMap;
    DrawMap(FinalMap, GameMap = CreateGrid(tilesize, height, width));
 }