void SetupBlankBoard(int cols, int rows) { owner = new int[cols, rows]; tile_type = new type[cols, rows]; remaining = new int[cols, rows]; defense_type = new type[cols, rows]; defense = new int[cols, rows]; tiles = new tile[cols, rows]; for (int x = 0; x != cols; ++x) { for (int y = 0; y != rows; ++y) { owner[x, y] = -1; defense_type[x, y] = tile_type[x, y] = type.Empty; remaining[x, y] = 0; defense[x, y] = 0; tile nt = Instantiate <tile>(tilePrefab); //nt.GetComponent<Transform>().position = new Vector3((float)x, (float)y, 0f); nt.GetComponent <Transform>().position = new Vector3((float)x, (float)y + 10.0f + 10.0f * Random.value, 0f); nt.GetComponent <Rigidbody>().velocity = new Vector3(0f, -20.0f, 0f); nt.col = x; nt.row = y; nt.owner = -1; tiles[x, y] = nt; } } }
public void Move() { if (path.Count > 0) { tile t = path.Peek(); Vector3 target = t.transform.position; target.y += halfHeight + t.GetComponent <Collider>().bounds.extents.y; if (Vector3.Distance(transform.position, target) >= 0.05f) { bool jump = transform.position.y != target.y; if (jump) { Jump(target); } else { CalculateHeading(target); SetHorizontalVelocity(); } transform.forward = heading; transform.position += velocity * Time.deltaTime; } else { transform.position = target; path.Pop(); } } else { RemoveSelectableTiles(); moving = false; if (moving == false) { TurnManager.EndTurn(); } } }
void SetupBoard(int cols, int rows) { owner = new int[cols, rows]; tile_type = new type[cols, rows]; remaining = new int[cols, rows]; defense_type = new type[cols, rows]; defense = new int[cols, rows]; tiles = new tile[cols, rows]; for (int x = 0; x != cols; ++x) { for (int y = 0; y != rows; ++y) { owner[x, y] = -1; defense_type[x, y] = tile_type[x, y] = type.Empty; remaining[x, y] = 0; defense[x, y] = 0; tile nt = Instantiate <tile>(tilePrefab); //nt.GetComponent<Transform>().position = new Vector3((float)x, (float)y, 0f); nt.GetComponent <Transform>().position = new Vector3((float)x, (float)y + 10.0f + 10.0f * Random.value, 0f); nt.GetComponent <Rigidbody>().velocity = new Vector3(0f, -20.0f, 0f); nt.col = x; nt.row = y; nt.owner = -1; tiles [x, y] = nt; } } for (int p = 0; p < 14; p++) { for (int q = 0; q < 10; q++) { if (Random.value < 0.1) { tile_type[p, q] = type.Fire; } else if (Random.value < 0.2) { tile_type[p, q] = type.Water; } else if (Random.value < 0.3) { tile_type[p, q] = type.Earth; } } } owner[4, 2] = 0; owner[4, 7] = 1; owner[9, 7] = 2; owner[9, 2] = 3; tile_type[4, 2] = type.Empty; tile_type[4, 7] = type.Empty; tile_type[9, 7] = type.Empty; tile_type[9, 2] = type.Empty; tiles_owned[0] = 1; tiles_owned[1] = 1; tiles_owned[2] = 1; tiles_owned[3] = 1; for (int p = 0; p < 14; p++) { for (int q = 0; q < 10; q++) { if (tile_type[p, q] != type.Empty) { remaining[p, q] = 10; } } } UpdateSelectableTiles(); }