// Use this for initialization void Start() { pfc = FindObjectOfType <PlayfieldController>(); activePlayer = 0; gameState = GameState.PlayerStart; }
public void WallKick(int sign) { Rotate(sign, basicOffsets); if (!PlayfieldController.ValidPosition(this)) { Rotate(-sign, basicOffsets); foreach (OffsetList ol in offsetsList) { Rotate(sign, ol.offsets); if (PlayfieldController.ValidPosition(this)) { break; } Rotate(-sign, ol.offsets); } } SetGhostPosition(matrixPosition); CancelLock(); }
IEnumerator IEPlay() { LoadingController.LoadScene(1); yield return(new WaitUntil(() => !LoadingController.isLoading)); PlayfieldController.Setup(startLevel); PlayfieldController.StartSpawn(); }
IEnumerator LockDelay() { yield return(new WaitForSeconds(.5f)); if (PlayfieldController.ValidPosition(this)) { blocks.ForEach(block => block.Lock()); PlayfieldController.ClearRows(); PlayfieldController.SpawnTetromino(); PlayfieldController.canHold = true; Destroy(gameObject); } else { PlayfieldController.GameOver(); } }
public bool Move(Vector2Int position) { Vector2Int lastPosition = matrixPosition; SetPosition(matrixPosition + position); CancelLock(); if (!PlayfieldController.ValidPosition(this)) { SetPosition(lastPosition); return(false); } SetGhostPosition(matrixPosition); return(true); }
void SetGhostPosition(Vector2Int position) { ghost.gameObject.SetActive(false); int y = position.y - 1; do { SetPosition(new Vector2Int(matrixPosition.x, y--)); } while(PlayfieldController.ValidPosition(this)); Vector2Int ghostPosition = matrixPosition + Vector2Int.up; SetPosition(position); ghost.position = (Vector2)ghostPosition; ghost.gameObject.SetActive(true); }
// Start is called before the first frame update void Start() { if (mother == null || father == null) { genome = new EnemyGenome(); } else { genome = new EnemyGenome(father, mother); } pfc = GameObject.FindWithTag("GameController").GetComponent <PlayfieldController>(); nav = GetComponent <UnityEngine.AI.NavMeshAgent>(); nav.speed = genome.speed; StartCoroutine("makeUpMind"); }
public void Drop() { if (isLanded) { return; } bool fall = Move(Vector2Int.down); Vector2Int lastPosition = matrixPosition; SetPosition(matrixPosition + Vector2Int.down); if (!PlayfieldController.ValidPosition(this)) { landed = StartCoroutine(LockDelay()); if (fall) { SoundController.PlaySfx(GameData.GetAudioClip("Land")); } } SetPosition(lastPosition); }
void Start() { pfc = GameObject.FindWithTag("GameController").GetComponent <PlayfieldController>(); start = Time.time; }