private void SetRandomColor() { int index = Random.RandomRange(0, 3); switch (index) { case 0: _currentColor = "Cyan"; sr.color = colorCyan; break; case 1: _currentColor = "Yellow"; sr.color = colorYellow; break; case 2: _currentColor = "Magenta"; sr.color = colorMagenta; break; case 3: _currentColor = "Pink"; sr.color = colorPink; break; } }
private GameObject GetNextSpawnPoint() { if (spawnPoints.Length == 0) { Debug.LogError("No spawn points specified"); return(null); } var index = -1; while (index < 0 || index == lastSpawnPoint) { index = Random.RandomRange(0, spawnPoints.Length); } if (index < 0 || index >= spawnPoints.Length) { Debug.Log("Invalid spawnpoint index"); return(null); } lastSpawnPoint = index; return(spawnPoints[index]); }
void SpawnBall(GameObject ball) { // Spawn a ball a certain distance from the robots base var location = Robot.transform.position; var randomCircle = Random.insideUnitCircle; var shiftX = SpawnRadius * randomCircle.x; var shiftZ = SpawnRadius * randomCircle.y; // var shiftY = Robot.transform.position.y; // SpawnHeight + Random.RandomRange(-HeightRange / 2, HeightRange / 2); var shiftY = SpawnHeight + Random.RandomRange(-HeightRange / 2, HeightRange / 2); // Set boundaries if (Math.Pow(Math.Pow(shiftX, 2) + Math.Pow(shiftZ, 2), .5) < MinRadius) { //If it's not within the desired boundaries, retry SpawnBall(ball); return; } // The robots rotat-able space is set to -90 to 90. Limit the ability for balls to spawn behind robot. if (shiftZ <= 0) { SpawnBall(ball); return; } location.x += shiftX; location.z += shiftZ; location.y += shiftY; Instantiate(ball, location, Quaternion.identity); }
public void generateLeaves(Material mat) { if (childs.Count == 0) { for (int i = 0; i < (int)Random.RandomRange(2, 10); i++) { TwoSideQuad quad = new TwoSideQuad(pos, 0.2f); GameObject newLeave = quad.generateQuad(mat); newLeave.transform.parent = go.transform; leaves.Add(newLeave); leavesTimeOut.Add(Random.Range(5.0f, 60.0f)); } hasLeaf = true; } else { if (!isTrunk && rad <= 0.1f) { for (int i = 0; i < (int)Random.RandomRange(0, 4); i++) { TwoSideQuad quad = new TwoSideQuad(pos, 0.2f); GameObject newLeave = quad.generateQuad(mat); newLeave.transform.parent = go.transform; leaves.Add(newLeave); leavesTimeOut.Add(Random.Range(5.0f, 60.0f)); } hasLeaf = true; } for (int i = 0; i < childs.Count; i++) { childs[i].generateLeaves(mat); } } }
void TickFrame(uint a, GameData b) { if (a >= NextEventFrame) { NextEventFrame = a + (uint)Random.RandomRange(10, 40); var x = Random.RandomRange(-8, 8); var z = Random.RandomRange(-8, 8); var o = GameObject.Instantiate(Objs[Random.RandomRange(0, Objs.Count - 1)], new Vector3(x, 0, z), Quaternion.identity); o.name = a.ToString(); objs.Add(o); } for (int i = 0; i < objs.Count;) { var n = UInt64.Parse(objs[i].name); if (a > n + 60) { GameObject.Destroy(objs[i]); objs.RemoveAt(i); continue; } i++; } }
public void CreateObstrecle() { if (Game.gameState == GameStatus.BucketFull && !gameEndShown) { gameEndShown = true; var gameEndRing = Instantiate(this.gameEndRing, obstrecleCreationLocation.position, Quaternion.identity, _pipeHolder); return; } if (Game.gameState == GameStatus.BucketFull || Game.gameState == GameStatus.GameWon) { return; } var rand = Random.RandomRange(0, 2); if (Game.gameState != GameStatus.Playing) { rand = 0; } var tempPipe = Instantiate(obstreclePipe[rand], obstrecleCreationLocation.position, Quaternion.identity, _pipeHolder); Physics.Raycast(obstrecleCreationSensor.position, obstrecleCreationSensor.forward, out var hit, 10); if (rand == 0) { tempPipe.transform.localScale = new Vector3(hit.transform.parent.localScale.z + .5f, tempPipe.transform.localScale.y, hit.transform.parent.localScale.z + .5f); } _newObstrecleCreated = true; }
public void GenereteMission(int i) { Destroy(missions[i].gameObject); GameObject newMission = new GameObject("Mission" + i); newMission.transform.SetParent(transform); MissionType[] missionType = { MissionType.SingleRun, MissionType.TotalMeter, MissionType.FishesSingleRun }; int ramdomType = Random.RandomRange(0, missionType.Length); if (ramdomType == (int)MissionType.SingleRun) { missions[i] = newMission.AddComponent <SingleERun>(); } else if (ramdomType == (int)MissionType.TotalMeter) { missions[i] = newMission.AddComponent <TotalMeters>(); } else if (ramdomType == (int)MissionType.FishesSingleRun) { missions[i] = newMission.AddComponent <FishesSingleRun>(); } missions[i].Created(); FindObjectOfType <Menu>().SetMission(); }
private void spawnInteractable() { //returns prefab Interactable chosen = chooseInteractable(); Vector3 pos = Vector3.zero; //spawning in scene based on prefab Interactable created = Instantiate(chosen, pos, chosen.transform.rotation, transform); float topLimit = topCeiling.getBottomLeft().y; float bottomLimit = BottomCeiling.getTopRight().y; topLimit -= created.getTopDistance(); bottomLimit += created.getBottomDistance(); pos.y = Random.RandomRange(topLimit, bottomLimit); if (interactables.Count > 0) { var last = interactables[interactables.Count - 1]; pos.x = last.getMaxX() + Random.Range(minDistance, maxDistance); } else { pos.x = cam.getRightBound() + maxDistance; } interactables.Add(created); created.transform.position = pos; }
private void CreatePoints() { //PowerUp and points for (int xi = 1; xi < XSize - 1; xi++) { for (int zi = 1; zi < ZSize - 1; zi++) { if (!_points.Exists(it => it.x == xi * scale && it.z == zi * scale)) { if (Random.RandomRange(0f, 1f) > 0.4) { if (Random.Range(0f, 1f) > 0.97f) { Instantiate(PowerUpPrefab, new Vector3(xi * scale, STANDARD_HEIGHT * 2, zi * scale), Quaternion.identity); } else { Instantiate(PointPrefab, new Vector3(xi * scale, STANDARD_HEIGHT * 2, zi * scale), Quaternion.identity); } pointsAndPowerupCount.Value += 1; } } } } }
public void RandomList1(ref List <GameObject> lst) { GameObject temp; int random; for (int i = 0; i < lst.Count; i++) { temp = lst[i]; random = Random.RandomRange(0, lst.Count); lst[i] = lst[random]; lst[random] = temp; } }
void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Player")) { int number = Random.Range(0, ChunksMap.Length); var pos = new Vector3Int(0, 0, 0); chunksMap = ChunksMap[number].ToString(); linhas = chunksMap.Split('\n'); pos.y = (int)startPositionY; foreach (string linhas in linhas) { caracteres = linhas.ToCharArray(); foreach (char letras in caracteres) { switch (letras) { case '#': //Debug.Log("Pisos"); tileMap.SetTile(pos, dirt); break; case ' ': //Debug.Log("Vazio"); break; case 'E': //Debug.Log("Inimigo"); Instantiate(inimigos[Random.RandomRange(0, inimigos.Length)], pos, Quaternion.identity); break; case 'H': //Debug.Log("Decoração"); break; case '1': //Debug.Log("Loot"); Instantiate(itemSpawn, pos, Quaternion.identity); break; } pos.x++; } pos.x = (int)startPositionX; pos.y--; } } Destroy(gameObject); }
// Start is called before the first frame update void Start() { cellsWithin = GameObject.Find("Space"); //The "Space" object has a "Volume" component and a "CellularAutomata" component cellularAutomata = cellsWithin.GetComponent <CellularAutomata>(); for (int i = 0; i < 150; i++) { //Lets spawn a bunch of random cells in a 23x23x23 volume. var randX = Random.RandomRange(0, 23); var randY = Random.RandomRange(0, 23); var randZ = Random.RandomRange(0, 23); AddCell(new Vector3(randX, randY, randZ)); } return; }
private void Update() { timeSinceLastSplit += Time.deltaTime; if (timeSinceLastSplit > splitCooldown) { // Split event SplitRandomRectangle(); splitCooldown = splitCooldownBase + Random.RandomRange(-1f, 1f); timeSinceLastSplit = 0f; } if (Input.GetKeyDown(KeyCode.Space)) { //SplitRandomRectangle(); } }
void SpawnFood() { int spawnIndex = Random.RandomRange(0, SpawnPoints.Length); int spawnGarbage = Random.RandomRange(1, randomrangeNumber); if (spawnGarbage == 1) { Instantiate(Food[3], SpawnPoints[spawnIndex].position, SpawnPoints[spawnIndex].rotation); } else { int foodIndex = Random.RandomRange(0, Food.Length - 1); Instantiate(Food[foodIndex], SpawnPoints[spawnIndex].position, SpawnPoints[spawnIndex].rotation); } }
private void Awake() { if (gm == null) { gm = this; } else if (gm != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); filePath = Application.persistentDataPath + "/playerInfo.dat"; missions = new MissionBase[3]; if (File.Exists(filePath)) { Load(); } else { for (int i = 0; i < missions.Length; i++) { GameObject newMission = new GameObject("Mission" + i); newMission.transform.SetParent(transform); MissionType[] missionType = { MissionType.SingleRun, MissionType.TotalMeter, MissionType.FishesSingleRun }; int ramdomType = Random.RandomRange(0, missionType.Length); if (ramdomType == (int)MissionType.SingleRun) { missions[i] = newMission.AddComponent <SingleERun>(); } else if (ramdomType == (int)MissionType.TotalMeter) { missions[i] = newMission.AddComponent <TotalMeters>(); } else if (ramdomType == (int)MissionType.FishesSingleRun) { missions[i] = newMission.AddComponent <FishesSingleRun>(); } missions[i].Created(); } } }
private void Populate() { roomsGenerated = 0; for (int y = 0; y < mapSize.y; y++) { for (int x = 0; x < mapSize.x; x++) { float rand = Random.RandomRange(0, 100f); int debugValue = (int)((mapSize.x * mapSize.y) * 0.1); ocupiedArea[x, y] = rand <= ((roomsGenerated < (debugValue)) ? 95 : proceduralPercentageProbability); if (roomsGenerated > 1) { ocupiedArea[x, y] &= AreaHasNeighbord(x, y); } roomsGenerated += ocupiedArea[x, y] ? 1 : 0; } } }
private void CreateEntryAndExitOfMaze(int mazeWidth, int mazeHeight) { //Create Entry Cell entryCell = cellsOfMaze[Random.RandomRange(1, mazeWidth)]; entryX = entryCell.BottomWall.transform.position.x; entryY = entryCell.BottomWall.transform.position.y; entryZ = entryCell.BottomWall.transform.position.z; entryId = entryCell.Id; Destroy((entryCell.BottomWall)); //Create Exit int randomExitValue = Random.RandomRange(mazeHeight * mazeWidth - mazeWidth + 1, mazeHeight * mazeWidth); Cell exitCell = cellsOfMaze[randomExitValue]; exitX = exitCell.TopWall.transform.position.x; exitY = exitCell.TopWall.transform.position.y; exitZ = exitCell.TopWall.transform.position.z; exitId = exitCell.Id; Destroy((exitCell.TopWall)); }
public void GenerateMazeAndSetPlayerEnemyToEntry() { Stopwatch sw = new Stopwatch(); sw.Start(); //Every Startup we want a random material for the walls materials = Resources.LoadAll <Material>("WallMats"); int randomNumber = Random.RandomRange(0, materials.Length - 1); wallPrefab.GetComponent <MeshRenderer>().material = materials[randomNumber]; cellsOfMaze = InitializeAllCells(mazeWidth, mazeHeight); InitializeWallsOfCells(wallPrefab, mazeWidth, mazeHeight); //Delete Walls to get Maze Cell initCell = cellsOfMaze[Random.RandomRange(1, (mazeWidth * mazeHeight))]; DeleteWallsDepthFirst(initCell); CreateEntryAndExitOfMaze(mazeWidth, mazeHeight); //Instantiate Police and Ambulance CreatePoliceAndAmbulanceAtEnd(ambulanceCar, policeCar); //Instantiate Finish CreateFinishAtEnd(finish); //Instantiate Borders CreateBorders(border, mazeWidth); //Moove Player and enemy PutPlayerAndEnemyNearEntrance(player, enemy); //Update NavMesh surface.BuildNavMesh(); //List<int> path = FindPathStartToEndDepths(entryId, exitId); List <int> shortestPath = FindStartToEnd(entryId, exitId); pathStartEnd = shortestPath; //string shortestPathString = ""; //foreach (int step in shortestPath) //{ // shortestPathString = shortestPathString + step + ", "; //} //Debug.Log("Debug Pathfinding: " + shortestPathString); sw.Stop(); Debug.Log("Elapsed= " + sw.Elapsed); }
private void Awake() { stars = new ParticleSystem.Particle[maxStars]; particle = GetComponent <ParticleSystem>(); Assert.IsNotNull(particle, "Missing particles"); xOffset = fieldWidth * 0.5f; yOffset = fieldHeight * 0.5f; for (int i = 0; i < maxStars; i++) { float randSize = Random.RandomRange(starSizeRange, starSizeRange + 1f); float scaledColor = (true == colorize) ? randSize - starSizeRange : 1f; stars[i].position = GetRandomInRectangle(fieldWidth, fieldHeight) + transform.position; stars[i].startSize = starSize * randSize; stars[i].startColor = new Color(1f, scaledColor, scaledColor, 1f); } particle.SetParticles(stars, stars.Length); }
private WaypointListNode FindClosestNode(int p, Vector3 pos, int previous) { bool check_previous = !(previous < 0); Stopwatch a = new Stopwatch(); a.Start(); int ID = -1; float lowestDist = Mathf.Infinity; foreach (WaypointNode m in paths[p].Map) { if (check_previous && previous <= m.ID && Random.RandomRange(0, 1f) > 0.25f) { continue; } float d = Vector3.Distance(m.position, pos); if (d < lowestDist) { ID = m.ID; lowestDist = d; } } if (ID > -1) { //UnityEngine.Debug.Log(paths[p].ToString()); //UnityEngine.Debug.Log(paths[p].Map.Length); WaypointListNode wp = new WaypointListNode(paths[p].Map[ID].position, paths[p].Map[ID].ID, paths[p].Map[ID].Iii, null, paths[p].Map[ID].neighbors); return(wp); //print("Closest waypoint is " + ID); } else { return(null); } }
void LookAtSelect() { tar = target[(int)Random.RandomRange(0, target.Count)]; }
public void GerandoLabirinto() { Vector3 refT = prefabParede[0].GetComponent <Renderer>().bounds.size; Vector3 refP = new Vector3(-2, 0, -1); String temp = GerarLabirinto.generateMaze(colunaLabirinto, linhaLabirinto); string[] str = temp.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); int lin = str.Length; int col = str[0].Length; int item = (str.Length + str[0].Length) / 2; for (int l = 0; l < lin; l++) { for (int c = 0; c < col; c++) { if (str[l][c] == '1') { //int rnd = Random.RandomRange(0, prefabParede.Length ); if (varianteParede == 0) { GameObject obj = GameObject.Instantiate(prefabParede[varianteParede], new Vector3(refT.x * l, refP.y, refT.z * c), Quaternion.identity); obj.name = "P" + l + "_" + c; } if (varianteParede == 1) { GameObject obj = GameObject.Instantiate(prefabParede[varianteParede], new Vector3(refT.x * l, refP.y, refT.z * c), Quaternion.identity); obj.name = "P" + l + "_" + c; } if (varianteParede == 0) { varianteParede = 1; } else { varianteParede = 0; } } if (str[l][c] == '0') { int rndPickup = Random.RandomRange(0, item - 2); if (rndPickup == 1) { int rnd = Random.RandomRange(0, prefabPickup.Length); GameObject obj = GameObject.Instantiate(prefabPickup[rnd], new Vector3(refT.x * l, refP.y, refT.z * c), Quaternion.identity); obj.name = "P" + l + "_" + c; obj.transform.Rotate(new Vector3(90, 0, 0)); } GameObject objChao = GameObject.Instantiate(prefabChao, new Vector3(refT.x * l, refP.y - 0.90f, refT.z * c), Quaternion.identity); objChao.name = "Chao" + l + "_" + c; } if (c == 0 && l == 1) { startLocalition = new Vector3(refT.x * l, refP.y, refT.z * c); } if (c == col - 1 && l == lin - 2) { endLocation = new Vector3(refT.x * l, refP.y, refT.z * c); } } } startEnd(); prefabGrama.gameObject.SetActive(true); print("true"); }
// Update is called once per frame void Update() { if (gameObject.transform.position.x == lastPositionOfBallX) { tmp++; if (tmp >= 200) { GetComponent <Rigidbody2D>().velocity = new Vector2(GetComponent <Rigidbody2D>().velocity.x + Random.RandomRange(-1, 1), GetComponent <Rigidbody2D>().velocity.y); tmp = 0; } } if (gameObject.transform.position.y == lastPositionOfBallY) { tmp++; if (tmp >= 200) { GetComponent <Rigidbody2D>().velocity = new Vector2(GetComponent <Rigidbody2D>().velocity.x, GetComponent <Rigidbody2D>().velocity.y + Random.RandomRange(-1, 1)); tmp = 0; } } lastPositionOfBallX = gameObject.transform.position.x; lastPositionOfBallY = gameObject.transform.position.y; if (!hasStarted) { LockBallToPaddle(); LanchOnClick(); } }
/// <summary> /// Sets up the outer walls and floor (background) of the game board. /// </summary> public IEnumerator DOBoardSetup() { boardReady = false; GameManager.ResetAll(); //Set our map/maptiles array size. map = new TType[rows + 1, columns + 1]; mapTiles = new Tile[rows + 1, columns + 1]; //Go over each spot on the array and make them all walls. for (int y = 0; y < map.GetLength(1); y++) { for (int x = 0; x < map.GetLength(0); x++) { map[x, y] = TType.Wall; } } //Go over the whole map and spawn tiles, and assign the tile values based on the map. for (int x = 0; x < map.GetLength(0); x++) { for (int y = 0; y < map.GetLength(1); y++) { Tile _tileref = testTile.Spawn(); mapTiles[x, y] = _tileref; _tileref.tilePosition = new TilePosition(x, y); _tileref.transform.position = new Vector3((Mathf.Floor(rows / 2) * tileSize) - (x * tileSize), (Mathf.Floor(columns / 2) * tileSize) - (y * tileSize), 0); PaintTile(x, y); _tileref.gameObject.name = "Tile " + x + "/" + y; _tileref.transform.SetParent(transform); } } yield return(null); //Get a random position to start our tunneler. TilePosition centerPos = new TilePosition(Mathf.FloorToInt(map.GetLength(0) * 0.5f), Mathf.FloorToInt(map.GetLength(1) * 0.5f)); List <TilePosition> aroundCenterPos = BoardMethod.GetTilesAroundTile(centerPos, 4, TType.Wall); TilePosition tunnelerPos = aroundCenterPos[Random.RandomRange(0, aroundCenterPos.Count)]; int amountToDig = Mathf.FloorToInt((map.GetLength(0) - 2) * (map.GetLength(1) - 2) * digTilePct); yield return(null); Commands tunnelerCommand = (Commands)Random.Range(1, 5); while (amountToDig > 0) { yield return(null); if (BoardMethod.getTileType(tunnelerPos.x, tunnelerPos.y) == TType.Wall) { float roomChance = 0.05f; if (BoardMethod.CountTilesAlignedAroundTile(tunnelerPos, 3, TType.Floor) == 2) { roomChance = 0.55f; } if (Random.value < roomChance) { var tilesAllAround = BoardMethod.GetTilesAroundTile(tunnelerPos, 1, TType.Wall); amountToDig -= 3; foreach (TilePosition _tilePosition in tilesAllAround) { TurnToFloor(_tilePosition); } } else { amountToDig--; TurnToFloor(tunnelerPos); } } TilePosition possibleTunnelerPos = BoardMethod.GetTileFromCommand(tunnelerPos, tunnelerCommand); if (BoardMethod.isPositionValid(possibleTunnelerPos)) { tunnelerPos = possibleTunnelerPos; } else { tunnelerCommand = Random.value < 0.5 ? BoardMethod.GetNextCommand(tunnelerCommand) : BoardMethod.GetPrevCommand(tunnelerCommand); } if (Random.value < 0.25f) { tunnelerCommand = Random.value < 0.5 ? BoardMethod.GetNextCommand(tunnelerCommand) : BoardMethod.GetPrevCommand(tunnelerCommand); } } boardReady = true; for (int i = 0; i < 3; i++) { GameManager.get.SpawnEnemy(); } }
void CreateThreeBlock() { //ListCreated.Clear(); HardPoint = 0; Debug.Log(CountBlock); if (CountBlock > 250) { HardPoint = 90; } else if (CountBlock > 200) { HardPoint = 80; } else if (CountBlock > 150) { HardPoint = 50; } else if (CountBlock > 100) { HardPoint = 30; } else if (CountBlock > 80) { HardPoint = 30; } else if (CountBlock > 60) { HardPoint = 20; } else if (CountBlock > 50) { HardPoint = 10; } else if (CountBlock > 30) { HardPoint = 5; } Debug.Log(HardPoint); int random, index; Transform randomObjTransform; for (int i = 0; i < 3; i++) { // Random sprite Transform blockTransform = BlockPool.Pool.Spawn(BlockPrefab); blockTransform.localScale = Vector3.one; // Random block // Check block if (PlayerPrefs.GetString("block") == "true" && PlayerPrefs.GetString("all") == "true" && IsContinue == false) { IsContinue = true; Debug.Log(PlayerPrefs.HasKey("indexSet_" + i)); Score = PlayerPrefs.GetInt("Score"); index = PlayerPrefs.GetInt("indexSet_" + i); sprite = BlockItemSprites[index]; if (i == 2) { if (PlayerPrefs.HasKey("type_" + 1 + "indexSet_" + i)) { index = PlayerPrefs.GetInt("type_" + 1 + "indexSet_" + i); } else { index = PlayerPrefs.GetInt("type_" + 0 + "indexSet_" + i); } } else { index = PlayerPrefs.GetInt("type_" + 0 + "indexSet_" + i); } randomObjTransform = BlocksPrefabs[i].transform; for (int x = 0; x < BlocksPrefabs.Count; x++) { if (index == int.Parse(BlocksPrefabs[x].name.Substring(5))) { randomObjTransform = BlocksPrefabs[x].transform; } } } else { random = Random.Range(0, BlockItemSprites.Count); sprite = BlockItemSprites[random]; SaveGame.instance.saveSprite(i, random); random = Random.RandomRange(0, BlocksPrefabs.Count); randomObjTransform = BlocksPrefabs[random].transform; SaveGame.instance.saveListCreated(0, i, int.Parse(BlocksPrefabs[random].name.Substring(5))); if (i == 2) { if (Random.Range(0, 101) < HardPoint) { // Random block RandomList1(ref HardBlockPrefabs); for (int j = 0; j < HardBlockPrefabs.Count; j++) { randomObjTransform = HardBlockPrefabs[j].transform; if (CheckAbleBlock(randomObjTransform.GetComponent <Block>(), 1) != 0 && CheckCanAddToList(randomObjTransform.gameObject)) { int indexBlock = int.Parse(randomObjTransform.gameObject.name.Substring(5)); SaveGame.instance.saveListCreated(1, i, indexBlock); break; } } } else { // Random block RandomList1(ref BlocksPrefabs); for (int j = 0; j < BlocksPrefabs.Count; j++) { randomObjTransform = BlocksPrefabs[j].transform; if (CheckAbleBlock(randomObjTransform.GetComponent <Block>(), 1) != 0 && CheckCanAddToList(randomObjTransform.gameObject)) { int indexBlock = int.Parse(randomObjTransform.gameObject.name.Substring(5)); SaveGame.instance.saveListCreated(0, i, indexBlock); break; } } } } else { // Random block RandomList1(ref BlocksPrefabs); for (int j = 0; j < BlocksPrefabs.Count; j++) { randomObjTransform = BlocksPrefabs[j].transform; if (CheckAbleBlock(randomObjTransform.GetComponent <Block>(), 1) != 0 && CheckCanAddToList(randomObjTransform.gameObject)) { int indexBlock = int.Parse(randomObjTransform.gameObject.name.Substring(5)); SaveGame.instance.saveListCreated(0, i, indexBlock); break; } } } } ListCreated.Add(randomObjTransform.gameObject); var block = blockTransform.GetComponent <Block>(); block.BlocksContain.eulerAngles = Vector3.zero; foreach (Transform child in randomObjTransform.GetComponent <Block>().BlocksContain) { Transform itemTransform = BlockPool.Pool.Spawn(ItemBlockPrefab, block.BlocksContain); itemTransform.localPosition = child.localPosition; itemTransform.localScale = Vector3.one * 1.38f; itemTransform.GetChild(0).GetComponent <SpriteRenderer>().sprite = Decos[Random.Range(0, Decos.Count)]; itemTransform.GetComponent <BlockItem>().SetNoStar(); } blockTransform.localScale = SmallScale; blockTransform.SetParent(_listSpawnPos[i]); block.Container = _listSpawnPos[i]; // foreach (var item in block.Items) // { // item.transform.localPosition *= 1.05f; // } block.InitItem(); block.SetSprite(sprite); if (ListAngle.Count > 0) { block.BlocksContain.eulerAngles = ListAngle[Random.Range(0, ListAngle.Count)]; while (CheckAbleBlock(block, 2) == 0) { block.BlocksContain.eulerAngles += Vector3.forward * 60; } block.DefaultAngleZ = (int)block.BlocksContain.eulerAngles.z; foreach (var item in block.Items) { item.transform.eulerAngles = Vector3.zero; } } blockTransform.DOKill(); blockTransform.position = _listSpawnPos[i].position + Vector3.down * 4; //Debug.Log("blockTransform.position1" + blockTransform.position); blockTransform.DOMove(_listSpawnPos[i].position, .3f).SetEase(Ease.OutBack); //Debug.Log("blockTransform.position2" + blockTransform.position); if (Random.Range(0, 100) < 50) { // set block has star int blockItemIndex = Random.Range(0, block.Items.Count); block.Items[blockItemIndex].SetHasStar(); } //if (i == 2 || i == 1) //{ // if (_listSpawnPos[i].childCount >= 2) // { // Destroy(_listSpawnPos[i].GetChild(0).gameObject); // } //} } CheckGamever(); if (CheckGamever()) { SaveGame.instance.deleteList(); // Show gameover Debug.Log("GAMEOVER"); _theHiddenBlockCanBeRotated.SetActive(false); ShowGameover(); } }
public static void Airdrop() { int loc = Random.RandomRange(1, 13); string arg = string.Empty; string string_ = string.Empty; string str = string.Empty; Vector3 val = default(Vector3); val = new Vector3(0f, 0f, 0f); switch (loc) { case 1: arg = "Airdrop will fall to the Summerside Peninsula"; string_ = "Airdop was fallen on Summerside Peninsula!"; val = new Vector3(790f, 24f, -450f); str = "Take airdrop on Summerside Peninsula"; break; case 2: arg = "Airdrop will fall to the Burywood"; string_ = "Airdrop was fallen on Burywood!"; val = new Vector3(50f, 23f, 700f); str = "Take airdrop on BuryWood"; break; case 3: arg = "Airdrop will fall to the Courtin Island"; string_ = "Airdrop was fallen on Courtin Island!"; val = new Vector3(890f, 22f, 500f); str = "Take airdrop on Courtin Island"; break; case 4: arg = "Airdrop will fall to the Belfast Airport"; string_ = "Airdrop was fallen on Belfast Airport!"; val = new Vector3(600f, 25f, 468f); str = "Take airdrop on Belfast Airport"; break; case 5: arg = "Airdrop will fall to the Holman Island"; string_ = "Airdrop was fallen on Holman Island!"; val = new Vector3(-770f, 29f, -760f); str = "Take airdrop on Holman Island"; break; case 6: arg = "Airdrop will fall to the O'Leary Military Base"; string_ = "Airdrop was fallen on O'Leary Military Base!"; val = new Vector3(-440f, 26f, 607f); str = "Take airdrop on Military Base"; break; case 7: arg = "Airdrop will fall to the Alberton"; string_ = "Airdrop was fallen on Alberton!"; val = new Vector3(-580f, 19f, 87f); str = "Take airdrop on Alberton"; break; case 8: arg = "Airdrop will fall to the Charlottetown"; string_ = "Airdrop was fallen on Charlottetown!"; val = new Vector3(22f, 18f, -432f); str = "Take airdrop on Charlottetown"; break; case 9: arg = "Airdrop will fall to the Montague"; string_ = "Airdrop was fallen on Montague!"; val = new Vector3(250f, 30f, -100f); str = "Take airdrop on Montague"; break; case 10: arg = "Airdrop will fall to the Oultons Isle"; string_ = "Airdrop was fallen on Oultons Isle!"; val = new Vector3(200f, 28f, -825f); str = "Take airdrop on Oultons Isle"; break; case 11: arg = "Airdrop will fall to the St. Peter's Island"; string_ = "Airdrop was fallen on St. Peter's Island!"; val = new Vector3(-245.4355f, 27.7f, 47.64797f); str = "Take airdrop on St. Peter's Island"; break; case 12: arg = "Airdrop will fall to the Fernwood Farm"; string_ = "Airdrop was fallen on Fernwood Farm!"; val = new Vector3(-244.4423f, 25.5f, -376.0898f); str = "Take airdrop on Fernwood Farm"; break; case 13: arg = "Airdrop will fall to the Wiltshire Farm"; string_ = "Airdrop was fallen on Wiltshire Farm!"; val = new Vector3(-451.6884f, 27.3f, -563.936f); str = "Take airdrop on Wiltishire Farm"; break; } for (int i = 5; i >= 1; i--) { NetworkChat.sendAlert($"{arg} after {i} min"); Thread.Sleep(60000); } NetworkChat.sendAlert(string_); for (int i = 0; i < itemAmountForDrop; i++) { int int_ = items[Random.Range(0, items.Length)]; float num3 = Random.Range(0, 5); float num4 = Random.Range(0, 5); SpawnItems.spawnItem(int_, 1, new Vector3(val.x + num3, val.y, val.z + num4)); } NetworkSounds.askSoundMax("Sounds/spooky/spooky_3", val, 500f, 1f, 700f, 3500f); for (int num5 = 1000; num5 > 0; num5--) { if (announceWhilePlayerTook) { for (int j = 0; j < UserList.users.Count; j++) { BetterNetworkUser val2 = UserList.users[j]; float num6 = Mathf.Abs(Vector3.Distance(val, val2.position)); if (num6 < 10.5f) { NetworkChat.sendAlert(val2.name + " " + str); NetworkSounds.askSoundMax("Sounds/spooky/spooky_0", val, 500f, 1f, 700f, 3500f); return; } } } if (enableEffects) { int num7 = 0; for (int k = 0; k < 25; k++) { NetworkEffects.askEffect("Effects/sparksRed", new Vector3(val.x, val.y + (float)num7, val.z), Quaternion.Euler(-90f, 0f, 0f), 100f); num7 += 2; } NetworkSounds.askSound("Sounds/projectiles/smoke", val, 500f, 1f, 700f); } Thread.Sleep(300); } }