private void Update() { if (completedOperations != maxOperations && Time.time > nextOperationTime) { nextOperationTime = Time.time + delayBetweenOperations; // do a random operation Vector2Int alterationPos = new Vector2Int(Random.Range(0, map.width - 1), Random.Range(minY, maxY)); Map.NodeAlteration alteration = new Map.NodeAlteration(alterationPos, alterations[Random.Range(0, alterations.Count)], true); map.AlterNodes(ref alteration); completedOperations++; if (decendFromTop) { operationsUntilDecent--; if (operationsUntilDecent < 1) { operationsUntilDecent = operationsPerRow; if (maxY < map.height - 1) { minY++; maxY++; } } } } }
private void Update() { //if (Input.GetKeyDown(KeyCode.A)) add = true; //if (Input.GetKeyDown(KeyCode.S)) add = false; if (Input.GetKeyDown(KeyCode.Alpha1)) { curAlteration = alteration1; } else if (Input.GetKeyDown(KeyCode.Alpha2)) { curAlteration = alteration2; } else if (Input.GetKeyDown(KeyCode.Alpha3)) { curAlteration = alteration3; } else if (Input.GetKeyDown(KeyCode.Alpha4)) { curAlteration = alteration4; } else if (Input.GetKeyDown(KeyCode.Alpha5)) { curAlteration = alteration5; } if (Input.GetMouseButtonDown(0)) { Vector3 worldPos = mainCam.ScreenToWorldPoint(Input.mousePosition); Vector2Int alterationCenterNodePos = map.WorldPosToNodePos(worldPos); Vector2Int alterationTopLeft = alterationCenterNodePos - new Vector2Int(curAlteration.GetLength(0) / 2, curAlteration.GetLength(1) / 2); Map.NodeAlteration alteration = new Map.NodeAlteration(alterationTopLeft, curAlteration, !add); map.AlterNodes(ref alteration); } }