public int CalcOffsetBoard(Shape shape) { int w_offset = 0; foreach (Transform child in shape.transform) { Vector2 pos = Vectorf.Round(child.position); if ((int)pos.x == -1) { w_offset -= 1; } else if ((int)pos.x == -2) { w_offset -= 10; } else if ((int)pos.x == m_width) { w_offset += 1; } else if ((int)pos.x == m_width + 1) { w_offset += 10; } } return(w_offset); }
// Start is called before the first frame update void Start() { m_timeToNextKeyLeftRight = Time.time; m_timeToNextKeyDown = Time.time; m_timeToNextKeyRotate = Time.time; //m_gameBoard = GameObject.FindWithTag("Board").GetComponent<Board>(); //m_spawner = GameObject.FindWithTag("Spawner").GetComponent<Spawner>(); m_gameBoard = FindObjectOfType <Board>(); m_spawner = FindObjectOfType <Spawner>(); m_soundManager = FindObjectOfType <SoundManager>(); m_scoreManager = FindObjectOfType <ScoreManager>(); m_ghost = FindObjectOfType <Ghost>(); m_holder = FindObjectOfType <Holder>(); if (!m_gameBoard) { Debug.LogWarning("WARNING! There is no board defined"); } if (!m_soundManager) { Debug.LogWarning("WARNING! There is no Sound Manager defined"); } if (!m_scoreManager) { Debug.LogWarning("WARNING! There is no score manager defined"); } if (!m_spawner) { Debug.LogWarning("WARNING! There is no spawner defined"); } else { 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); } if (m_diagnosticText3) { m_diagnosticText3.text = ""; } m_dropIntervalModed = m_dropInterval; }
// Use this for initialization void Start() { // find spawner and board with GameObject.FindWithTag plus GetComponent; make sure you tag your objects correctly //m_gameBoard = GameObject.FindWithTag("Board").GetComponent<Board>(); //m_spawner = GameObject.FindWithTag("Spawner").GetComponent<Spawner>(); // find spawner and board with generic version of GameObject.FindObjectOfType, slower but less typing m_gameBoard = GameObject.FindObjectOfType <Board>(); m_spawner = GameObject.FindObjectOfType <Spawner>(); m_soundManager = GameObject.FindObjectOfType <SoundManager>(); m_scoreManager = GameObject.FindObjectOfType <ScoreManager>(); m_ghost = GameObject.FindObjectOfType <Ghost>(); m_holder = GameObject.FindObjectOfType <Holder>(); m_timeToNextKeyDown = Time.time + m_keyRepeatRateDown; m_timeToNextKeyLeftRight = Time.time + m_keyRepeatRateLeftRight; m_timeToNextKeyRotate = Time.time + m_keyRepeatRateRotate; if (!m_gameBoard) { Debug.LogWarning("WARNING! There is no game board defined!"); } if (!m_soundManager) { Debug.LogWarning("WARNING! There is no sound manager defined!"); } if (!m_scoreManager) { Debug.LogWarning("WARNING! There is no score manager defined!"); } if (!m_spawner) { Debug.LogWarning("WARNING! There is no spawner defined!"); } else { 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); } m_dropIntervalModded = Mathf.Clamp(m_dropInterval - ((float)m_scoreManager.m_level * 0.1f), 0.05f, 1f); }
// Start is called before the first frame update void Start() { Vector2 originalVector = new Vector2(4.3f, 1.3f); Vector2 newVector = Vectorf.Round(originalVector); Debug.Log(newVector.ToString()); }
// Use this for initialization void Start() { // find spawner and board with GameObject.FindWithTag plus GetComponent; make sure you tag your objects correctly //m_gameBoard = GameObject.FindWithTag("Board").GetComponent<Board>(); //m_spawner = GameObject.FindWithTag("Spawner").GetComponent<Spawner>(); // find spawner and board with generic version of GameObject.FindObjectOfType, slower but less typing m_gameBoard = GameObject.FindObjectOfType <Board>(); m_spawner = GameObject.FindObjectOfType <Spawner>(); if (m_spawner) { if (m_activeShape == null) { m_activeShape = m_spawner.SpawnShape(); } m_spawner.transform.position = Vectorf.Round(m_spawner.transform.position); } if (!m_gameBoard) { Debug.LogWarning("WARNING! There is no game board defined!"); } if (!m_spawner) { Debug.LogWarning("WARNING! There is no spawner defined!"); } }
// Start is called before the first frame update void Start() { m_TimeToNextKeyLeftRight = Time.time + m_keyRepeatRateLeftRight; m_TimeToNextKeyDown = Time.time + m_keyRepeatRateDown; m_TimeToNextKeyRotate = Time.time + m_keyRepeatRateRotate; if (!m_gameBoard) { Debug.LogWarning("WARNING! There is no board definied!"); } if (!m_soundManager) { Debug.LogWarning("WARNING! There is no soundManager definied!"); } if (!m_scoreManager) { Debug.LogWarning("WARNING! There is no scoreManager definied!"); } if (!m_spawner) { Debug.LogWarning("WARNING! There is no spawner definied!"); } else { m_spawner.transform.position = Vectorf.Round(m_spawner.transform.position); if (!m_activeShape) { m_activeShape = m_spawner.SpawnShape(); } } }
private void Start() { //Tag method faster m_gameBoard = GameObject.FindWithTag("Board").GetComponent <Board>(); m_spawner = GameObject.FindWithTag("Spawner").GetComponent <Spawner>(); m_soundManager = GameObject.FindWithTag("SoundManager").GetComponent <SoundManager>(); m_scoreManager = GameObject.FindWithTag("ScoreManager").GetComponent <ScoreManager>(); m_timeToNextKeyLeftRight = Time.time + m_keyRepeatRateLeftRight; m_timeToNextKeyDown = Time.time + m_keyRepeatRateDown; m_timeToNextKeyRotate = Time.time + m_keyRepeatRateRotate; //Alternative Method(This is slow) //m_gameBoard = GameObject.FindObjectOfType<Board>(); //m_spawner = GameObject.FindObjectOfType<Spawner>(); //// //also same //m_gameBoard = GameObject.FindObjectOfType(typeof(Board)) as Board; //m_spawner = GameObject.FindObjectOfType(typeof(Spawner)) as Spawner; if (!m_gameBoard) { Debug.LogWarning("WARNING! MISSING GAME BOARD!!!"); } if (!m_soundManager) { Debug.LogWarning("WARNING! MISSING SOUND MANAGER!!!"); } if (!m_spawner) { Debug.LogWarning("WARNING! MISSING SPAWNER!!!"); } if (!m_scoreManager) { Debug.LogWarning("WARNING! MISSING SCORE MANAGER!!!"); } else { 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); } m_dropIntervalModded = m_dropInterval; }
// Use this for initialization void Start() { //m_gameBoard = GameObject.FindWithTag ("Board").GetComponent<Board>(); //m_spawner = GameObject.FindWithTag ("Spawner").GetComponent<Spawner>(); m_gameBoard = GameObject.FindObjectOfType <Board>(); m_spawner = GameObject.FindObjectOfType <Spawner> (); m_soundManager = GameObject.FindObjectOfType <SoundManager> (); m_scoreManager = GameObject.FindObjectOfType <ScoreManager> (); m_ghost = GameObject.FindObjectOfType <Ghost> (); m_holder = GameObject.FindObjectOfType <Holder> (); m_timeToNextKeyLeftRight = Time.time + m_keyRepeatRateLeftRight; m_timeToNextKeyDown = Time.time + m_keyRepeatRateDown; m_timeToNextKeyRotate = Time.time + m_keyRepeatRateRotate; if (!m_gameBoard) { Debug.LogWarning("WARNING! There is no game board defined!"); } if (!m_soundManager) { Debug.LogWarning("WARNING! There is no sound manager defined!"); } if (!m_scoreManager) { Debug.LogWarning("WARNING! There is no score manager defined!"); } if (!m_spawner) { Debug.LogWarning("WARNING! There is no spawner defined!"); } else { m_spawner.transform.position = Vectorf.Round(m_spawner.transform.position); if (m_activeShape == null) { m_activeShape = m_spawner.SpawnShape(); if (m_activeShape.name == m_spawner.m_allShapes[3].name + "(Clone)") { m_activeShape.MoveRight(); } } } if (m_gameOverPanel) { m_gameOverPanel.SetActive(false); } if (m_pausePanel) { m_pausePanel.SetActive(false); } m_dropIntervalModded = m_dropInterval; m_gridArray = m_gameBoard.GetGridArray(); }
// Start is called before the first frame update void Start() { //call helper script to make sure block be on whole number location Vector2 originalVector = new Vector2(4.3f, 1.3f); Vector2 newVector = Vectorf.Round(originalVector); Debug.Log(newVector.ToString()); }
private void Start() { gameBoard = GameObject.FindObjectOfType <Board>(); spawner = GameObject.FindObjectOfType <Spawner>(); ghost = GameObject.FindObjectOfType <Ghost>(); holder = GameObject.FindObjectOfType <Holder>(); soundManager = GameObject.FindObjectOfType <SoundManager>(); scoreManager = GameObject.FindObjectOfType <ScoreManager>(); timeToNextKeyLeftRight = Time.time + keyRepeatRateLeftRight; timeToNextKeyRotate = Time.time + keyRepeatRateRotate; timeToNextKeyDown = Time.time + keyRepeatRateDown; if (!gameBoard) { Debug.Log("WARNING! There is no game board defined!"); } if (!soundManager) { Debug.Log("WARNING! There is no sound manager defined!"); } if (!scoreManager) { Debug.Log("WARNING! There is no score manager defined!"); } if (!spawner) { Debug.Log("WARNING! There is no spawner defined!"); } else { if (activeShape == null) { activeShape = spawner.SpawnShape(); } spawner.transform.position = Vectorf.Round(spawner.transform.position); } if (gameOverPanel) { gameOverPanel.SetActive(false); } if (pausePanel) { pausePanel.SetActive(false); } dropIntervalModded = dropInterval; }
void Start() { _gameBoard = GameObject.FindObjectOfType <Board>(); _spawner = GameObject.FindObjectOfType <Spawner>(); _soundManager = GameObject.FindObjectOfType <SoundManager>(); _scoreManager = GameObject.FindObjectOfType <ScoreManager>(); _ghost = GameObject.FindObjectOfType <Ghost>(); _holder = GameObject.FindObjectOfType <Holder>(); _timeToNextKeyDown = Time.time + keyRepeatRateDown; _timeToNextKeyLeftRight = Time.time + keyRepeatRateLeftRight; if (!_gameBoard) { Debug.LogWarning("WARNING! There is no game board defined!"); } if (!_soundManager) { Debug.LogWarning("WARNING! There is no sound manager defined!"); } if (!_scoreManager) { Debug.LogWarning("WARNING! There is no score manager defined!"); } if (!_spawner) { Debug.LogWarning("WARNING! There is no spawner defined!"); } else { _spawner.transform.position = Vectorf.Round(_spawner.transform.position); if (!_activeShape) { _activeShape = _spawner.SpawnShape(); } } if (gameOverPanel) { gameOverPanel.SetActive(false); } if (pausePanel) { pausePanel.SetActive(false); } _dropIntervalModded = Mathf.Clamp(dropInterval - ((float)_scoreManager.level * 0.1f), 0.05f, 1f); }
// Use this for initialization void Start() { m_gameBoard = GameObject.FindWithTag("Board").GetComponent <Board>(); m_spawner = GameObject.FindWithTag("Spawner").GetComponent <Spawner>(); m_soundManager = FindObjectOfType <SoundManager>(); m_scoreManager = FindObjectOfType <ScoreManager>(); m_ghost = FindObjectOfType <Ghost>(); m_holder = FindObjectOfType <Holder>(); m_timeToNextKeyDown = Time.time + m_keyRepeatRateDown; m_timeToNextKeyLeftRight = Time.time + m_keyRepeatRateLeftRight; m_timeToNextKeyRotate = Time.time + m_keyRepeatRateRotate; if (!m_gameBoard) { Debug.LogWarning("Warning: No game board defined"); } if (!m_soundManager) { Debug.LogWarning("Warning: No SoundManager defined"); } if (!m_scoreManager) { Debug.LogWarning("Warning: No ScoreManager defined"); } if (!m_spawner) { Debug.LogWarning("Warning: No spawner defined"); } else { if (m_activeShape == null) { m_activeShape = m_spawner.SpawnShape(); } //Make sure spawner spawns on even position to align with grid m_spawner.transform.position = Vectorf.Round(m_spawner.transform.position); } //Make sure gameover and pause panels aren't showing at game start if (m_gameOverPanel) { m_gameOverPanel.SetActive(false); } if (m_pausePanel) { m_pausePanel.SetActive(false); } m_dropIntervalModded = m_dropInterval; }
// Use this for initialization void Start() { m_gameBoard = GameObject.FindObjectOfType <Board>(); m_spawner = GameObject.FindObjectOfType <Spawner>(); m_soundManager = GameObject.FindObjectOfType <SoundManager> (); m_scoreManager = GameObject.FindObjectOfType <ScoreManager> (); m_highScores = GameObject.FindObjectOfType <HighScores>(); m_holder = GameObject.FindObjectOfType <Holder> (); m_input = GameObject.FindObjectOfType <InputField>(); m_timeToNextKeyLeftRight = Time.time + m_keyRepeatRateLeftRight; m_timeToNextKeyDown = Time.time + m_keyRepeatRateDown; m_timeToNextKeyRotate = Time.time + m_keyRepeatRateRotate; if (!m_gameBoard) { Debug.LogWarning("WARNING! There is no game board defined!"); } if (!m_soundManager) { Debug.LogWarning("WARNING! There is no sound manager defined!"); } if (!m_scoreManager) { Debug.LogWarning("WARNING! There is no score manager defined!"); } if (!m_spawner) { Debug.LogWarning("WARNING! There is no spawner defined!"); } else { m_spawner.transform.position = Vectorf.Round(m_spawner.transform.position); if (!m_activeShape) { m_activeShape = m_spawner.SpawnShape(); m_settleTime = 1; } } if (!m_gameOver) { m_gameOverPanel.transform.localScale = new Vector3(0, 0, 0); } if (m_pausePanel) { m_pausePanel.SetActive(false); } }
public void StoreShapeInGrid(Tetrimino tetrimino) { if (tetrimino == null) { return; } foreach (Transform child in tetrimino.transform) { Vector2 position = Vectorf.Round(child.position); m_grid[(int)position.x, (int)position.y] = child; } }
public bool IsValidPosBoard(Shape shape) { foreach (Transform child in shape.transform) { Vector2 pos = Vectorf.Round(child.position); if (!IsWithinBoard((int)pos.x, (int)pos.y)) { return(false); } } return(true); }
/* * store the block into the layout_grid array as a child class */ public void StoreBlock(Blocks block) { if (block == null) { return; } foreach (Transform child in block.transform) { Vector2 position = Vectorf.Round(child.position); layout_grid[(int)position.x, (int)position.y] = child; } }
public bool IsValidPosOccupied(Shape shape) { foreach (Transform child in shape.transform) { Vector2 pos = Vectorf.Round(child.position); if (IsOccupied((int)pos.x, (int)pos.y, shape)) { return(false); } } return(true); }
public void StoreShapeInGrid(Shape shape) { if (shape == null) { return; } foreach (Transform child in shape.transform) { Vector2 pos = Vectorf.Round(child.position); _grid[(int)pos.x, (int)pos.y] = child; } }
void Start() { m_board = FindObjectOfType <Board>(); m_spawner = FindObjectOfType <Spawner>(); m_soundManager = FindObjectOfType <SoundManager>(); m_scoreManager = FindObjectOfType <ScoreManager>(); m_ghost = FindObjectOfType <Ghost>(); m_holder = FindObjectOfType <Holder>(); m_addPlayer = FindObjectOfType <AddPlayer>(); m_getPlayerInfo = FindObjectOfType <GetPlayerInfos>(); m_updatePlayer = FindObjectOfType <UpdatePlayer>(); m_timeToNextKey = Time.time; m_timeToNextKeyLeftRight = Time.time + m_keyRepeatRateLeftRight; m_timeToNextKeyDown = Time.time + m_keyRepeatRateDown; m_timeToNextKeyRotate = Time.time + m_keyRepeatRateRotate; if (!m_spawner || !m_board || !m_soundManager || !m_scoreManager) { Debug.LogWarning("Warning! m_board or m_spawner or m_soundManager or m_scoreManager aren't defined."); } else { if (m_activeShape == null) { m_activeShape = m_spawner.SpawnShape(); } m_spawner.transform.position = Vectorf.Round(m_spawner.transform.position); } if (m_gameOverPanel) { m_gameOverPanel.SetActive(false); } if (m_pausePanel) { m_pausePanel.SetActive(false); } m_dropIntervalModded = m_dropInterval; m_soundManager.m_fxEnabled = SaveManager.Instance.IsFxOn(); m_soundManager.m_musicEnabled = SaveManager.Instance.IsMusicOn(); m_soundManager.m_fxIconToggle.ToggleIcon(m_soundManager.m_fxEnabled); m_soundManager.m_musicIconToggle.ToggleIcon(m_soundManager.m_musicEnabled); m_soundManager.UpdateMusic(); }
void Start() { m_gameBoard = FindObjectOfType<Board>(); m_spawner = FindObjectOfType<Spawner>(); m_timeToNextKey = Time.time; if(m_spawner) { m_spawner.transform.position = Vectorf.Round(m_spawner.transform.position); if(m_activeShape == null) { m_activeShape = m_spawner.SpawnShape(); } } else { Debug.LogWarning("Warning! No spawner defined"); } }
private void Start() { gameOverPanel.SetActive(false); pausePanel.SetActive(false); GetReferences(); MakeAssertions(); spawner.transform.position = Vectorf.Round(spawner.transform.position); if (activeShape == null) { activeShape = spawner.SpawnShape(); } dropIntervalMod = dropInterval; }
public bool IsValidPosition(Tetrimino tetrimino) { foreach (Transform child in tetrimino.transform) { Vector2 position = Vectorf.Round(child.position); if (!IsOnBoard((int)position.x, (int)position.y)) { return(false); } if (IsOccupied((int)position.x, (int)position.y, tetrimino)) { return(false); } } return(true); }
/* * check if each block inside the layout is inside the width boundary */ public bool isValidPosition(Blocks block) { //loop to check if block is in boundary and if it overlaps foreach (Transform child in block.transform) { Vector2 position = Vectorf.Round(child.position); if (!isInLayout((int)position.x, (int)position.y)) { return(false); } if (isOverlay((int)position.x, (int)position.y, block)) { return(false); } } return(true); }
void Start() { InitializeObjects(); InitializeVariables(); ErrorHandling(); if (!m_spawner) { Debug.LogWarning("GAMECONTROLLER START: There is no spawner defined!"); } else { if (!m_activeShape) { m_activeShape = m_spawner.SpawnShape(); } m_spawner.transform.position = Vectorf.Round(m_spawner.transform.position); } }
// Use this for initialization void Start() { // Locate the spawner and boards gameobjects this.gameBoard = GameObject.FindWithTag("Board").GetComponent <Board>(); this.spawner = GameObject.FindWithTag("Spawner").GetComponent <Spawner>(); this.soundManager = GameObject.FindWithTag("SoundManager").GetComponent <SoundManager>(); this.timeToNextKeyLeftRight = Time.time; this.timeToNextKeyRotate = Time.time; this.timeToNextKeyDown = Time.time; this.timeToDrop = Time.time + this.dropInterval; if (!this.gameBoard) { Debug.LogWarning("WARNING! There is no game board defined!"); } if (!this.soundManager) { Debug.LogWarning("WARNING! There is no sound manager defined!"); } if (!this.spawner) { Debug.LogWarning("WARNING! There is no spawner defined!"); } else { // Spawn a new shape if we currently don't have one if (this.activeShape == null) { this.activeShape = this.spawner.SpawnShape(); } this.spawner.transform.position = Vectorf.Round(this.spawner.transform.position); } if (this.gameOverPanel) { this.gameOverPanel.SetActive(false); } }
// Use this for initialization void Start() { // find spawner and board with generic version of GameObject.FindObjectOfType, slower but less typing m_gameBoard = GameObject.FindObjectOfType <Board>(); m_spawner = GameObject.FindObjectOfType <Spawner>(); m_scoreManager = GameObject.FindObjectOfType <ScoreManager>(); m_timeToNextKeyDown = Time.time + m_keyRepeatRateDown; m_timeToNextKeyLeftRight = Time.time + m_keyRepeatRateLeftRight; m_timeToNextKeyRotate = Time.time + m_keyRepeatRateRotate; if (!m_gameBoard) { Debug.LogWarning("WARNING! There is no game board defined!"); } if (!m_scoreManager) { Debug.LogWarning("WARNING! There is no score manager defined!"); } if (!m_spawner) { Debug.LogWarning("WARNING! There is no spawner defined!"); } else { 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); } m_dropIntervalModded = Mathf.Clamp(m_dropInterval - ((float)m_scoreManager.m_level * 0.1f), 0.05f, 1f); }
// Use this for initialization void Start() { m_gameBoard = FindObjectOfType <Board>(); m_spawner = FindObjectOfType <Spawner>(); m_scoreManager = FindObjectOfType <ScoreManager>(); if (!m_gameBoard) { Debug.Log("There is no game board"); } if (!m_scoreManager) { Debug.Log("There is no scoreManager"); } if (!m_spawner) { Debug.Log("There is no spawner"); } else { m_spawner.transform.position = Vectorf.Round(m_spawner.transform.position); if (m_activeShape == null) { m_activeShape = m_spawner.SpawnShape(); } } if (m_gameOverPanel) { m_gameOverPanel.SetActive(false); } if (m_pausePanel) { m_pausePanel.SetActive(false); } m_dropIntervalModded = m_dropInterval; }
// method that takes shape as an argument // loops through all the shape squares that's within board public bool IsValidPosition(Shape shape) { // for each loop: loop through each individual square of the shape foreach (Transform child in shape.transform) { Vector2 pos = Vectorf.Round(child.position); // if any of those squares fails the condition, then the shape is in invalid position if (!IsWithinBoard((int)pos.x, (int)pos.y)) { // then return false return(false); } // Each child square will have 2 checks, // verify that each square is both on the board. // and not on a square that's been taken if (IsOccupied((int)pos.x, (int)pos.y, shape)) { return(false); } } return(true); }
// Store the shape in board's grid array public void StoreShapeInGrid(Shape shape) { // Make sure the shape isn't nothing if (shape == null) { return; } // it will loop through the shape and // on each child square we will find the rounded x, y coordinate that // We will store child square into the grid // The array index comes from the x and y coordinate // We must use (int) for explicit cast, because pos.x and pos.y are float, and // the array index is an integer // You potentially lose the value converting from float to an integer, so // c# makes you cast it explicitly. foreach (Transform child in shape.transform) { Vector2 pos = Vectorf.Round(child.position); m_grid[(int)pos.x, (int)pos.y] = child; } }
void Start() { timeToNextKey = Time.time; board = GameObject.FindWithTag("Board").GetComponent <Board>(); spawner = GameObject.FindWithTag("Spawner").GetComponent <Spawner>(); spawner.transform.position = Vectorf.Round(spawner.transform.position); activeShape = getSpawnShape(spawner); soundManager = FindObjectOfType <SoundManager>(); scoreManager = FindObjectOfType <ScoreManager>(); ghost = FindObjectOfType <Ghost>(); if (pausePanel) { pausePanel.SetActive(false); } if (restartPanel) { restartPanel.SetActive(false); } dropIntervalModded = dropInterval; }