public override void UseBonus(CellScript targetCell) { BoxScript bonusBox = targetCell.cellObject as BoxScript; if (bonusBox != null) { CheckCell(targetCell.topNeighbor); if (targetCell.topNeighbor != null) { CheckCell(targetCell.topNeighbor.leftNeighbor); CheckCell(targetCell.topNeighbor.rightNeighbor); } CheckCell(targetCell.bottomNeighbor); if (targetCell.bottomNeighbor != null) { CheckCell(targetCell.bottomNeighbor.leftNeighbor); CheckCell(targetCell.bottomNeighbor.rightNeighbor); } CheckCell(targetCell.leftNeighbor); CheckCell(targetCell.rightNeighbor); Instantiate(explosionPrefab, targetCell.transform.position, Quaternion.identity); } else { throw new UnityException("Бонусу передана ссылка на клетку не содержащую ящика"); } }
private void OnButtonDown() { RaycastHit2D hit = Physics2D.GetRayIntersection(mainCamera.ScreenPointToRay(Input.mousePosition)); if (hit.collider != null) { BoxScript hitBox = hit.collider.gameObject.GetComponent <BoxScript>(); if (hitBox != null) { if (currentAnimal == null) { currentAnimal = hitBox.GetAnimal(); if (currentAnimal != null) { currentAnimal.transform.SetParent(transform); } } else { if (!hitBox.IsFull()) { hitBox.PutAnimnal(currentAnimal); currentAnimal = null; if (IsEnd()) { //Debug.Log("END"); SummaryPopup.SummaryPopupInstance.ShowPopup(); } } } } } }
public void SelectBox(BoxScript box) { if (Box1 == null) { Box1 = box; return; } ; if (box == Box1) { return; } ; if (Box2 == null) { Box2 = box; } ; if (Box1.CatType == Box2.CatType) { Box1.Terminate(); Box2.Terminate(); Box1 = null; Box2 = null; } else { Box1.Close(); Box2.Close(); Box1 = null; Box2 = null; } }
private void AddPiontToScore(BoxScript bs) { if (bs.pointNumber >= 0) { if (bs.pointNumber < User.Instance.powerLevel) { GameManager.scoreUp += bs.pointNumber; } else { GameManager.scoreUp += User.Instance.powerLevel; } if (BonusManager.getbonusDamageBall()) { bs.pointNumber -= User.Instance.powerLevel * 2; bs.color(); } else { bs.pointNumber -= User.Instance.powerLevel; bs.color(); } } }
private IEnumerator playCoroutine() { BoxScript g = null; bool canPlay = true; while (canPlay) { g = PlanMove(); if (g != null) { canPlay = true; yield return(new WaitForSeconds(1)); Vector3 destination = g.gameObject.transform.position; destination = new Vector3(destination.x, destination.y + 10, destination.z + 5); while (CameraScript.instance.gameObject.transform.position != destination) { CameraScript.instance.gameObject.transform.position = Vector3.MoveTowards( CameraScript.instance.gameObject.transform.position, destination, 5.0f * Time.deltaTime); yield return(new WaitForEndOfFrame()); } yield return(new WaitForSeconds(0.5f)); enemyState.BoxAction(g); yield return(new WaitForSeconds(0.5f)); } else { canPlay = false; yield return(new WaitForSeconds(1)); } } enemyState.ConfirmAction(); }
void LancarPergunta() { Question.gameObject.SetActive(true); devePerguntar = false; gerarValores(); Question.text = "Quanto é " + primeiroValor.ToString() + " " + sinal + " " + segundoValor.ToString() + "?"; teste += 1; Debug.Log(cam.transform.position.x); a1 = Instantiate(caixa, new Vector3(cam.transform.position.x + 150.0f + 10.0f, 49.90f, 4.7f), Quaternion.Euler(new Vector3(4.0f, -4.0f, -6.0f))); BoxScript box1 = a1.GetComponent <BoxScript>(); box1.setResult(resp1); a2 = Instantiate(caixa, new Vector3(cam.transform.position.x + 150.0f + 5.0f, 49.92f, 0.0f), Quaternion.Euler(new Vector3(0.0f, 0.0f, -10.0f))); BoxScript box2 = a2.GetComponent <BoxScript>(); box2.setResult(resp2); a3 = Instantiate(caixa, new Vector3(cam.transform.position.x + 150.0f, 49.89f, -4.7f), Quaternion.Euler(new Vector3(-4.0f, 4.0f, -0.0f))); BoxScript box3 = a3.GetComponent <BoxScript>(); box3.setResult(resp3); }
//проверяет совпадает ли цвет данного ящика //с цветом ящика в клетке переданного в аргументе cell //возвращает true если цвет совпадает //возвращает false если: //- цвет не совпадает //- в клетке нет ящика //- клетки нет (cell равен null) //цвет сравнивается с цветом ящика для которого вызван метод private bool CompareColor(CellScript cell) { if (cell == null) { return(false); } else { BoxScript box = cell.cellObject as BoxScript; if (box == null) { return(false); } else { if (box.boxColor == boxColor) { return(true); } else { return(false); } } } }
public void Activate() { RaycastHit hit; //if (state == transformations.GIGANT) { if (actions == Comport.CARGANDO) { bxSript.Soltar(); actions = Comport.IDDLE; } Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * 10, Color.yellow); if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit, 10)) { if (hit.transform.gameObject.layer == 10) { bxSript = hit.transform.GetComponent <BoxScript>(); bxSript.Agarre(); Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * 10, Color.red); Debug.Log("Did Hit"); actions = Comport.CARGANDO; } } //} }
void Awake() { if (instance == null) { instance = this; } // initialize objects if (gameObject.transform.GetChild(0).GetComponent <TextMeshPro>().text.Length > 0) { Letter = gameObject.transform.GetChild(0).GetComponent <TextMeshPro>().text; } if (scoreText == null) { scoreText = GameObject.Find("Score").GetComponent <Text>(); } if (selectedScore == null) { selectedScore = GameObject.Find("SelectedScore").GetComponent <Text>(); } if (celebrationParticleSystem == null) { celebrationParticleSystem = GameObject.Find("CelebrationParticles"); } originalBlockColor = new Color(0.04f, 0.52f, 0.89f, 0.79f); }
public static void ClearAllSelectedTiles() { currentWord = ""; // remove all coloring foreach (Vector2 v in currentSelection) { BoxScript box = grid[(int)v.x, (int)v.y].gameObject.GetComponent <BoxScript>(); box.ResetTileColors(); box._isSelected = false; } currentSelection.Clear(); /****************************************************************** * FEATURE: Display currently selected score ******************************************************************/ // Calculate currently selected score and change the text on screen selectedScore.text = ""; /****************************************************************** * FEATURE: Disable the play word button if it exists ******************************************************************/ if (GameManagerScript.obstructionProductive || GameManagerScript.obstructionUnproductive) { GameManagerScript.gameManager.UpdatePlayButton(); } }
public override void UseBonus(CellScript targetCell) { BoxScript targetBox = targetCell.cellObject as BoxScript; if (targetBox == null) { throw new UnityException("Бонусу передана ссылка на клетку не содержащую ящика"); } else { for (int i = 0; i < GameFieldScript.instance.height; i++) { for (int j = 0; j < GameFieldScript.instance.width; j++) { CellScript cell = GameFieldScript.instance[i, j]; BoxScript cellBox = cell.cellObject as BoxScript; if (cellBox != null && cellBox.boxColor == targetBox.boxColor) { cellBox.DestroyBox(); Instantiate(sniperEffect, cell.transform.position, Quaternion.identity); } } } } }
public void LoadGameState() { ResetGame(); if (PlayerPrefs.HasKey("Board")) { string prefString = PlayerPrefs.GetString("Board"); board = StringToIntList(prefString).ToArray(); for (int i = 0; i < actualBoard.Length; i++) { BoxScript boardControl = actualBoard[i].GetComponent <BoxScript>(); if (board[i] == -1) { boardControl.TouchBox(); moveCount++; } else if (board[i] == 1) { boardControl.ComputerTouch(); } else { boardControl.Reset(); } } } else { print("No board to load!"); } }
public void Reset() { // reset all important variables initialLog = true; gameHasBegun = false; isBombAudioPlaying = false; myHighestScoringWord = ""; myHighestScoringWordScore = 0; myRarestWord = ""; myRarestWordRarity = 0; myHighScoreUpdated = false; counter = 5; GameObject boxes = GameObject.Find("SpawnBoxes"); foreach (Transform child in boxes.transform) { child.gameObject.GetComponent <SpawnBoxScript>().Reset(); } // reset all important BoxScript variables BoxScript.Reset(); ResetTimer(); UpdatePlayButton(); gameOverPanel.SetActive(false); int scene = SceneManager.GetActiveScene().buildIndex; SceneManager.LoadScene(scene); // eventually delete the key "currentPath" // PlayerPrefs.DeleteKey("currentPath"); }
/** * Creates a new spawnbox with the given letter (in caps, e.g. 'A', 'B', 'C', etc) at this location */ public void SpawnNewBox(char letter) { Transform box = Instantiate(boxPrefab, transform.position, Quaternion.identity); BoxScript script = box.GetComponent <BoxScript>(); script.SetLetter(letter); }
//сброс ящика private void DropBox() { box.currCell = currCell; currCell.cellObject = box; box.canFall = true; box.transform.SetParent(transform.parent); box = null; }
// Play word! public void PlayWord() { BoxScript.PlayWord(); //Debug.Log("Play word pressed."); // display the high score? //Debug.Log("Top score: " + DBManager.instance.topScore); }
public void Play(Vector3 hitPoint, BoxScript box) { if (isEnabled) { isEnabled = false; StartCoroutine(PlayCoroutine(hitPoint, box)); } }
private void OnTriggerEnter(Collider collision) { if (collision.transform.tag.Equals(BoxScript.sBox) || collision.transform.tag.Equals(BoxScript.sMoving_Box) || collision.transform.tag.Equals(BoxScript.sDownUp_Box)) { BoxScript bs = collision.transform.GetComponent <BoxScript>(); AddPiontToScore(bs); Destroy(transform.gameObject); } }
public void UpdatePlayButton() { if (BoxScript.currentWord.Length >= 3 && BoxScript.GetWordRank(BoxScript.currentWord) > -1) { playButton.GetComponent <Button>().interactable = true; } else { playButton.GetComponent <Button>().interactable = false; } }
public static void RemoveTilesPastIndex(int index) { if (index >= currentSelection.Count) { //Debug.Log("Error: tried to remove tiles past index out of bounds."); return; } for (int i = currentSelection.Count - 1; i > index; --i) { // get the last selected letter tile and remove it from the list (and unhighlight it) Vector2 v = currentSelection[currentSelection.Count - 1]; BoxScript box = grid[(int)v.x, (int)v.y].gameObject.GetComponent <BoxScript>(); box.ResetTileColors(); box._isSelected = false; currentSelection.Remove(v); /****************************************************************** * FEATURE: If juiciness is on, play particles when deselecting! ******************************************************************/ if (GameManagerScript.juiceProductive || GameManagerScript.juiceUnproductive) { box.PlayShinySelectParticles(); } } // log the removed letters Logger.LogAction("BNW_LetterDeselected", currentWord.Substring(index + 1), -1, -1); // Remove the letters currentWord = currentWord.Substring(0, index + 1); /***************************************************************** * FEATURE: Highlighting color gradient based on frequency feature *****************************************************************/ DisplayHighlightFeedback(); /****************************************************************** * FEATURE: Display currently selected score ******************************************************************/ DisplaySelectedScore(); /****************************************************************** * FEATURE: Obstructions- enable/disable play button based on word ******************************************************************/ if (GameManagerScript.obstructionProductive || GameManagerScript.obstructionUnproductive) { GameManagerScript.gameManager.UpdatePlayButton(); } // Play sound effect AudioManager.instance.Play("Select"); }
public void PlayButtonClick() { // increase number of interactions BoxScript.totalInteractions++; // Play sound AudioManager.instance.Play("Sparkle1"); //=========FEATURE: Unproductive Juice================================= // CAMERA SHAKE when pressing button //===================================================================== if (GameManagerScript.juiceUnproductive) { CameraShaker.instance.ShakeOnce(3f, 4f, .1f, .6f); } //=========FEATURE: Productive Obstruction============================= // Display prompt if productive //===================================================================== if (GameManagerScript.obstructionProductive) { // get score long score = BoxScript.GetScore(BoxScript.currentWord, null); // get rarity float rarity = BoxScript.GetWordRank(BoxScript.currentWord); if (rarity < 0) { rarity = 0; } // update text promptText.text = "Are you sure you want to submit " + BoxScript.currentWord + "?"; rarityText.text = "Rarity: " + (rarity * 100).ToString("0.00") + "%"; pointsText.text = "Points: " + score; submitPromptPanel.SetActive(true); // Turn on the timer for logging GameManagerScript.submitPromptOn = true; // Disable touch of the rest of the screen TouchInputHandler.inputEnabled = false; // Log the action LogPlayButtonClick(BoxScript.currentWord, rarity, score); } else { BoxScript.PlayWord(); } }
//команда движения игрока в указаном направлении //dir - направление движения public void Move(MoveDirection dir) { CellScript targetCell; MoveDirection targetDir; if (dir == MoveDirection.Left) { targetCell = currCell.leftNeighbor; targetDir = MoveDirection.Left; } else { targetCell = currCell.rightNeighbor; targetDir = MoveDirection.Right; } if (moving) { //если во время прыжка поступит команда движение , то игрок сместится влево после прыжка if (currMove == MoveType.Jump && targetCell != null) { nextMove = MoveType.Move; nextDir = targetDir; } //если во время движения поступила команда прыжка а затем команда движения, то прыжок отменится else if (nextMove == MoveType.Jump) { nextMove = MoveType.Stay; } } else if (targetCell != null) { if (targetCell.cellObject == null) { StartMove(targetCell); } else //попытка толкнуть ящик { BoxScript box = targetCell.cellObject as BoxScript; if (box != null) { if (box.TryPush(targetDir, moveSpeed)) { StartMove(targetCell); } } else { throw new UnityException("Непредвиденный тип объекта в клетке"); } } } }
public void SubmitButtonClick() { // Play the currently selected word BoxScript.PlayWord(); // Enable input to the rest of the screen TouchInputHandler.inputEnabled = true; // close window promptPanel.SetActive(false); ResetSubmitPromptTimer(); }
// used to detect collisions with obstacles void OnTriggerEnter(Collider other) { if (other.collider.gameObject.tag == "Box") // (colliderCooldown <= 0 && { BoxScript thisBoxScript = other.collider.gameObject.GetComponent <BoxScript>(); thisBoxScript.GetHit(gameObject, false); if (thisBoxScript.boxType <= 0 && playerHP > 0) { PlayerTakeDamage(1, "Box"); } } }
public void OpenSettingsMenu() { // TODO: Log this action through Firebase // TODO: deactivate touch input for the rest of the game TouchInputHandler.touchEnabled = false; // deselect all currently selected letters (just to make it easier for highlighting feature changes, etc BoxScript.ClearAllSelectedTiles(); // Open the settings panel settingsPanel.SetActive(true); }
// If something intersects with the Lid, it is not completely in the box anymore private void LidEnter(BoxScript <Contained> subject) { if (body.Has(subject.gameObject)) { // subject.transform.parent = null; Box.RemoveFromBox(subject.contained); contained.Remove(subject.gameObject); // TODO call functions in child classes // box.ShowBoxContents(); OnObjectRemoved(); } UpdateShippable(); }
public override void UseBonus(CellScript targetCell) { BoxScript box = targetCell.cellObject as BoxScript; if (box != null) { box.boxScore += scoreAmount; } else { throw new UnityException("Бонусу передана ссылка на клетку не содержащую ящика"); } }
// public BoxScript boxScript; // Use this for initialization void Start() { boxes = new GameObject[columns * rows]; if (width > 1) { width = 1; } if (height > 1) { height = 1; } float worldHeight = 2f * Camera.main.orthographicSize; float worldWidth = worldHeight * Camera.main.aspect; // int numberOfBoxes = columns * rows; float boxWidth = (worldWidth * width) / columns; float boxHeight = (worldHeight * height) / rows; // boxWidth = Camera.main.WorldToScreenPoint (boxWidth); // boxHeight = Camera.main.WorldToScreenPoint (boxHeight); lanes = new float[rows]; laneAvailable = new bool[rows]; Vector3 worldBottomLeft = new Vector3(-worldWidth / 2 + boxWidth / 2, -worldHeight / 2 + boxHeight / 2, 0); enemyArea = new Rect(worldBottomLeft.x + left + width * worldWidth, worldBottomLeft.y + bottom, worldWidth - width * worldWidth - left, worldHeight * height); // Vector2 upperLeftCorner = new Vector2 (-screenWidth / 2, -screenHeight / 2); int counter = 0; for (int i = 0; i < columns; i++) { for (int j = 0; j < rows; j++) { GameObject box = (GameObject)Instantiate(tilePrefab, worldBottomLeft + new Vector3(i * boxWidth + left, j * boxHeight + bottom, 0), tilePrefab.transform.rotation); boxes[counter] = box; BoxScript boxScript = box.GetComponent <BoxScript>(); boxScript.Generate(counter, boxWidth, boxHeight); counter++; if (i == 0) { lanes[j] = (worldBottomLeft + new Vector3(i * boxWidth + left, j * boxHeight + bottom, 0)).y; laneAvailable[j] = true; } } } }
static bool CheckIfBoxesAreFalling() { bool falling = false; for (int i = 0; i < BoxScript.GridWidth; ++i) { if (BoxScript.IsBoxInColumnFalling(i) || !BoxScript.IsColumnFull(i)) { falling = true; break; } } return(falling); }
private void LidExit(BoxScript <Contained> subject) { // If the thing exiting the lid is in the body, it is fully in the box if (body.Has(subject.gameObject)) { //containing.Add(subject); // subject.transform.SetParent(transform); Box.AddToBox(subject.contained); contained.Add(subject.gameObject); subject.OnAddedToBox(); // box.ShowBoxContents(); OnObjectAdded(); } UpdateShippable(); }