// Use this for initialization void Start() { grid.Create(30, 30); Vector2 gridSize = grid.size; Vector2 gridPos = new Vector2(gridSize.x * -0.5f, gridSize.y * 0.5f); grid.transform.position = gridPos; for (int i = 0; i < 3; i++) { GameObject newActor; newActor = CreateActor(); Vector3 spawnPoint = grid.GetNode(Random.Range(0, 29), Random.Range(0, 14)).transform.position; spawnPoint.z = -0.2f; newActor.transform.position = spawnPoint; newActor.tag = "Red"; newActor.name = "Red" + i; newActor.SetActive(true); } for (int i = 0; i < 3; i++) { GameObject newActor; newActor = CreateActor(); Vector3 spawnPoint = grid.GetNode(Random.Range(0, 29), Random.Range(15, 29)).transform.position; spawnPoint.z = -0.2f; newActor.transform.position = spawnPoint; newActor.tag = "Blue"; newActor.name = "Blue" + i; newActor.SetActive(true); } CreateFlags(); }
// public TreasureFinderController _tfc; private void Awake() { // Create and center the grid grid.Create(GRIDHEIGHT, GRIDLENGTH); Vector2 gridSize = grid.size; Vector2 gridPos = new Vector2(gridSize.x * -0.5f, gridSize.y * 0.5f); grid.transform.position = gridPos; }
void Start() { // Create and center the grid grid.Create(30, 50); Vector2 gridSize = grid.size; Vector2 gridPos = new Vector2(gridSize.x * -0.5f, gridSize.y * 0.5f); grid.transform.position = gridPos; GameObject actor = (GameObject)Instantiate(_actor, new Vector3(-17.0f, 0.6f, -1.0f), Quaternion.identity); actor.name = "TreasureSeeker"; actor.transform.parent = transform; actor.gameObject.SetActive(true); actor.gameObject.GetComponentInChildren <Transform>().gameObject.SetActive(true); BuildTreasureMap(); }
private void Start() { // Create and center the grid score = 0; boardsize = 6; depth = 4; grid.Create(boardsize, boardsize); Vector2 gridSize = grid.size; Vector2 gridPos = new Vector2(gridSize.x * -0.5f, gridSize.y * 0.5f); grid.transform.position = gridPos; playerChance = true; // set up the board board = new Board(grid._nodes, boardsize); uiScore = ui.GetComponentsInChildren <Text>()[0]; uiRedScore = ui.GetComponentsInChildren <Text>()[2]; uiGreenScore = ui.GetComponentsInChildren <Text>()[3]; }
// Use this for initialization void Start() { //stateMachine = new StateMachine(); terrainNodes = new List <GridNode>(); grid.Create(30, 30); Vector2 gridSize = grid.size; Vector2 gridPos = new Vector2(gridSize.x * -0.5f, gridSize.y * 0.5f); grid.transform.position = gridPos; while (terrainNodes.Count < 40) { GridNode node = grid.GetNode(Random.Range(0, 30), Random.Range(0, 30)); int cost = Random.Range(0, 5); if (!terrainNodes.Contains(node)) { if (cost != 1) { terrainNodes.Add(node); } switch (cost) { case 0: if (blockedCount > 0) { node.blocked = true; blockedCount--; } break; case 1: node.cost = cost; break; case 2: if (roadCount > 0) { node.road = true; roadCount--; node.cost = cost; } break; case 3: if (forestCount > 0) { node.forest = true; forestCount--; node.cost = cost; } break; case 4: if (swampCount > 0) { node.swamp = true; swampCount--; } break; } } } //SetDoors(); //SetKeys(); //SetTreasure(); for (int i = 0; i < 10; i++) { GameObject newActor; newActor = CreateActor(); GameObject canvas = GameObject.Find("Canvas"); newActor.GetComponent <Pathfinding>().Initialize(); newActor.GetComponent <Pathfinding>().showPathToggle = canvas.transform.GetChild(i).GetComponentInChildren <Toggle>(); newActor.GetComponent <Pathfinding>().triangleImage = canvas.transform.GetChild(i).GetChild(1).GetComponent <Image>(); newActor.GetComponent <Pathfinding>().triangleImage.color = newActor.GetComponent <SpriteRenderer>().color; newActor.GetComponent <Pathfinding>().setDestination(grid.GetNode(Random.Range(0, 30), Random.Range(0, 30))); newActor.SetActive(true); _flock.Enqueue(newActor); } //AddStates(); }