void Start() { m_gameBoard = GameObject.FindWithTag("Board").GetComponent <Board>(); m_spawner = GameObject.FindWithTag("Spawner").GetComponent <Spawner>(); m_score = GameObject.FindObjectOfType <ScoreScript>(); if (m_spawner) { m_spawner.transform.position = VectorF.Round(m_spawner.transform.position); if (!m_activeShape) { m_activeShape = m_spawner.SpawnShape(); } } if (m_gameOverPanel) { m_gameOverPanel.SetActive(false); } if (m_pausePanel) { m_pausePanel.SetActive(false); } }
public bool PutInBoard(Shape shape) { foreach (Transform transform in shape.transform) { Vector3 position = VectorF.Round(transform.position); if (position.x < 0) { MoveRight(); if (PutInBoard(shape)) { if (shape.indexShape == 0) { shape.rotateIn9 = false; shape.rotateIn2 = true; } break; } } else if (position.x >= mWidth) { MoveLeft(); if (PutInBoard(shape)) { if (shape.indexShape == 0) { shape.rotateIn2 = false; shape.rotateIn9 = true; } break; } } } return(true); }
public void StoreShapeInGrid(Shape shape) { foreach (Transform chield in shape.transform) { Vector3 position = VectorF.Round(chield.transform.position); m_grid[(int)position.x, (int)position.y] = chield; } }
void Start() { if (glowSquareTag != "") { m_glowSquareFx = GameObject.FindGameObjectsWithTag(glowSquareTag); } Vector2 oringalVector = new Vector2(4.3f, 1.3f); Vector2 newVector = VectorF.Round(oringalVector); Debug.Log(newVector.ToString()); }
public void StoreShapeInGrid(Shape shape) { if (shape == null) { return; } foreach (Transform child in shape.transform) { Vector2 pos = VectorF.Round(child.position); m_grid[(int)pos.x, (int)pos.y] = child; } }
public bool isValidPosition(Shape shape) { foreach (Transform child in shape.transform) { Vector3 position = VectorF.Round(child.position); if (!IsWithInTheBoard((int)position.x, (int)position.y) || isOccupied((int)position.x, (int)position.y, shape)) { return(false); } } return(true); }
public bool BelowTheBoard(Shape shape) { foreach (Transform child in shape.transform) { Vector3 position = VectorF.Round(child.position); if ((int)position.y <= 0) { return(true); } } return(false); }
public bool IsLeftOrRightOut(Shape shape) { foreach (Transform child in shape.transform) { Vector3 position = VectorF.Round(child.position); if (!IsWithInTheBoard((int)position.x, (int)position.y)) { return(false); } } return(true); }
//store shape in boards grid Array public void StoreShapeInGrid(Shape shape) { if (shape == null) { return; } foreach (Transform child in shape.transform) { Vector2 pos = VectorF.Round(child.position); //store child in grid. cast float to int. since grid is world space.float m_grid[(int)pos.x, (int)pos.y] = child; } }
public bool IsValidPosition(Shape shape) { foreach (Transform child in shape.transform) //Принимает коллекцию (массив) { Vector2 pos = VectorF.Round(child.position); //Вектор pos принимает округленное значение элемента массива if (!IsWithinBoard((int)pos.x, (int)pos.y)) //Если коорд заходят ниже границы, то "ложь" { return(false); } if (IsOccupied((int)pos.x, (int)pos.y, shape)) { return(false); } } return(true); //Во всех других случаях "тру" }
//this is to determine when the shape has hit the button of the board //2- is square occupited by another shape. Will be called from GameController. So public public bool IsValidPosition(Shape shape) { //if you use FOREACH on transform, It will go through every child of transform foreach (Transform child in shape.transform) { Vector2 pos = VectorF.Round(child.position); if (!IsWithinBoard((int)pos.x, (int)pos.y)) { return(false); } //if on board and not on a space thats taken if (IsOccupied((int)pos.x, (int)pos.y, shape)) { return(false); } } //this is a valid space for the shape return(true); }
// AdsScript ads; // Use this for initialization void Start () { // this.ads = GameObject.FindObjectOfType<AdsScript>(); // OverLoadPanel.SetActive(false); Screen.orientation = ScreenOrientation.Portrait; this.m_GameOverPanel = GameObject.FindObjectOfType<GameOver>(); m_PausedPanel.SetActive(false); this.m_timeToNextKeyLeftRight = Time.time+ m_keyRepeatRateLeftRight; this.m_timeToNextKeyDown = Time.time+ m_keyRepeatRateDown; this.m_timeToNextKeyRotate = Time.time+ m_keyRepeatRateRotate; this.score_manager = GameObject.FindObjectOfType<ScoreManager>(); this.m_Board = GameObject.FindObjectOfType<Board>(); this.m_Spawner = GameObject.FindObjectOfType<Spawner>(); this.m_soundManager = GameObject.FindObjectOfType<SoundManager>(); this.m_ghostShape = GameObject.FindObjectOfType<GhostShape>(); this.m_holder = GameObject.FindObjectOfType<HolderShape>(); this.m_GameOverPanel.HideGameOverPanel(); if (m_activeShape == null) { m_activeShape = m_Spawner.SpawnShape(); } m_Spawner.transform.position = VectorF.Round(m_Spawner.transform.position); m_dropIntervalModded = m_dropInterval; }
void Start() { m_gameBoard = GameObject.FindWithTag("Board").GetComponent <Board>(); m_spwaner = GameObject.FindWithTag("Spawner").GetComponent <Spawner>(); m_soundManager = GameObject.FindObjectOfType <SoundManager>(); m_scoreManager = GameObject.FindObjectOfType <ScoreManager>(); m_ghost = GameObject.FindObjectOfType <Ghost>(); m_holder = GameObject.FindObjectOfType <Holder>(); //or the below is the same (But Slower according to UNITY docs) //m_gameBoard = FindObjectOfType<Board>(); //m_spwaner = FindObjectOfType<Spawner>(); m_timeToNextKeyLeftRight = Time.time + m_keyReaptRateLeftRight; m_timeToNextKeyDown = Time.time + m_keyRepeatRateDown; m_timeToNextKeyRotate = Time.time + m_timeToNextKeyRotate; if (!m_scoreManager) { Debug.Log("There is no SCORE MANAGER defined"); } if (!m_gameBoard) { Debug.Log("There is no game Board defined"); } if (!m_soundManager) { Debug.LogWarning("Warning! There is no sound manager"); } if (!m_spwaner) { Debug.Log("There is no Spawner defined"); } else { m_spwaner.transform.position = VectorF.Round(m_spwaner.transform.position); //this will spawn shapes if (!m_activeShape) { //will make shape spawn from top m_activeShape = m_spwaner.SpawnShape(); } } if (m_gameOverPanel) { m_gameOverPanel.SetActive(false); } if (m_pausePanel) { m_pausePanel.SetActive(false); } m_dropIntervalModded = m_dropInterval; /* * if (diagnostext3) * { * diagnostext3.text = ""; * } */ }
void Start() { Vector2 originalVector = new Vector2(4.3f, 1.3f); //Вектор2 originalVector с коор-ами 4.3f, 1.3f Vector2 newVector = VectorF.Round(originalVector); //Вектор2 newVector возвр округл коорд originalVector }